For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

ImageNew

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Description

Creates a ColdFusion image.

Returns

A ColdFusion image.

Category

Image functions

Function syntax

ImageNew([source, width, height, imageType, canvasColor])

See also

cfimage, ImageCopy, ImageRead, ImageReadBase64, ImageSetDrawingColor, IsImageFile

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

source

Optional. The source image on-disk or in-memory pathname, URL, a ColdFusion variable that is read into the new ColdFusion image, or a Java buffered image.

width

Optional. The width of the new ColdFusion image. Valid when the height is specified and the source is not.

height

Optional. The height of the new ColdFusion image. Valid when the width is specified and the source is not.

imageType

Optional. The type of the ColdFusion image to create:

  • rgb
  • argb
  • grayscale
    Valid only when width and height are specified.

canvasColor

Optional. Color of the image canvas:

  • Hexadecimal value of RGB color. For example, specify the color white as ##FFFFFF or FFFFFF.
  • String value of color (for example, "black", "red", "green"). The default value of the drawing color is "black".
  • List of three numbers for (R,G,B) values. Each value must be in the range 0-255.

Usage

You can pass the ImageNew function any of the following parameters:

  • Absolute or relative pathname: The image file located at the specified pathname on a disk is read and returned as a ColdFusion image.
  • URL: The image from the specified URL is read and returned as a ColdFusion image.
  • Width and height (imageType is optional): A blank ColdFusion image with the specified attributes is returned.
  • ColdFusion image variable: An image variable in memory; for example, #myImage#.
  • A BLOB from a database that contains image data.
  • A byte array that contains Base64 image data.
  • A Java buffered image.ColdFusion generates an error when the passed attributes cannot create a valid ColdFusion image.The ImageNew function and the{{cfimage}} read action support the SQL Server Image Column data type.To read Base64 images, use the ImageReadBase64 function.If the color value is a string, specify a supported named color; see the valid HTML named colors in cfimage. For a hexadecimal value, use the form "##xxxxxx" or "xxxxxx", where x = 0-9 or A-F; use two number signs or none.

    Note: If you specify the ARGB image type, the image is white; however, if you specify RGB or grayscale, the image is black. To create blank images consistently, use the canvasColor parameter.

Example

Example 1

<!--- Use the ImageNew function to create a 200x200-pixel image in ARGB format. ---> 
<cfset myImage = ImageNew("",200,200,"argb")> 
<cfimage action="writeTobrowser" source="#myImage#">

Example 2

<!--- This example shows how to create a ColdFusion image from a BLOB in a database. ---> 
<cfquery 
name="GetBLOBs" datasource="myblobdata"> 
SELECT LastName,Photo 
FROM Employees 
</cfquery> 
<cfset i = 0> 
<table border=1> 
<cfoutput query="GetBLOBS"> 
<tr> 
<td> 
#LastName# 
</td> 
<td> 
<cfset i = i+1> 
<cfset myImage=ImageNew("#GetBLOBS.Photo#")> 
<cfset ImageWrite(myImage,"photo#i#.png")> 
</td> 
</tr> 
</cfoutput> 
</table>

Example 3

<!--- This example shows how to create a ColdFusion image from a URL. ---> 
<cfset myImage = ImageNew("http://www.google.com/images/logo_sm.gif")> 
<cfset ImageWrite(myImage,"google_via_imagenew.png")> 
<img src="google_via_imagenew.png">

Example 4

<!--- This example shows how to use the cffile tag to convert an image file to binary format and pass it as a variable to the ImageNew function. ---> 
<!---Use the cffile tag to read an image file, convert it to binary format, and write the result to a variable. ---> 
<cffile action = "readBinary" file = apple.jpg" 
variable = "aBinaryObj"> 
<!--- Use the ImageNew function to create a ColdFusion image from the variable. ---> 
<cfset myImage = ImageNew(aBinaryObj)>

Example 5

<!--- This example shows how to use the cffile tag to write a ColdFusion image to a file. ---> 
<!--- Use the ImageNew function to create a ColdFusion image from a JPEG file. ---> 
<cfset myImage = ImageNew("../cfdocs/images/artgallery/aiden01.jpg")> 
<!--- Turn on antialiasing to improve image quality. ---> 
<cfset ImageSetAntialiasing(myImage,"on")> 
<!--- Resize the image. ---> 
<cfset ImageResize(myImage,"50%","")> 
<!--- Pass the image object to the cffile tag and write the result to a file on the local drive. ---> 
<cffile file="#myImage#" action="write" output="c:\test_myImage.jpg"> 
<cfimage action="writeToBrowser" source="#myImage#">

Example 6

<!--- This example uses cfscript to pass a Java buffered image to the ImageNew function. ---> 
<cfscript> 
bufferedImage = createObject("java", "java.awt.image.BufferedImage"); 
bufferedImage.init(JavaCast("int", 100), JavaCast("int", 100), BufferedImage.TYPE_4BYTE_ABGR); 
myImage = imageNew(bufferedImage); 
</cfscript>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices