User Guide Cancel

ImageRead

 

Description

Reads the on-disk or in-memory source pathname or URL and creates a ColdFusion image.

Returns

A ColdFusion image.

Category

Image functions

Function syntax

ImageRead(path)
ImageRead(path)
ImageRead(path)

History

ColdFusion 8: Added this function.

See also

cfimageImageNewImageReadBase64ImageWriteIsImageFile

Parameters

Parameter

Description

path

Required. On-disk or in-memory pathname or URL of the source image.

Usage

The ImageRead function performs the same operation as the cfimage read action. However, you cannot use the cfimage tag to read and create a ColdFusion image variable in the cfscript tag. Use the ImageRead function within the cfscript tag to read ColdFusion images.The following example reads the image file aiden01.jpg into a variable called myImage and displays the image in the browser:

<cfset myImage=ImageRead("../cfdocs/images/artgallery/aiden01.jpg")>
<cfimage action="writeToBrowser" source="#myImage#">
<cfset myImage=ImageRead("../cfdocs/images/artgallery/aiden01.jpg")> <cfimage action="writeToBrowser" source="#myImage#">
<cfset myImage=ImageRead("../cfdocs/images/artgallery/aiden01.jpg")> 
<cfimage action="writeToBrowser" source="#myImage#">

For a list of valid image formats, see the supported image file formats listed in cfimage. To retrieve a list of readable formats on the server where the ColdFusion application is deployed, use the GetReadableImageFormats function.

Example

<cfscript>
myImage=ImageRead("http://www.google.com/images/logo.gif");
ImageWrite(myImage,"google-logo.gif");
</cfscript>
<p>This image has been downloaded by ColdFusion:</p>
<img src="google-logo.gif">
<p>This is the original image:</p>
<img src="http://www.google.com/images/logo.gif"/>
<cfscript> myImage=ImageRead("http://www.google.com/images/logo.gif"); ImageWrite(myImage,"google-logo.gif"); </cfscript> <p>This image has been downloaded by ColdFusion:</p> <img src="google-logo.gif"> <p>This is the original image:</p> <img src="http://www.google.com/images/logo.gif"/>
<cfscript>
myImage=ImageRead("http://www.google.com/images/logo.gif");
ImageWrite(myImage,"google-logo.gif");
</cfscript>
<p>This image has been downloaded by ColdFusion:</p>
<img src="google-logo.gif">
<p>This is the original image:</p>
<img src="http://www.google.com/images/logo.gif"/>

Get help faster and easier

New user?