IsImageFile

Description

Verifies whether an image file is valid.

Returns

True, if the value is a valid image file; False, otherwise.

Function syntax

IsImageFile("path")

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

path

Required. The pathname of the on-disk or in-memory file to be checked. The pathname can be absolute or relative to the CFM page and must be enclosed in quotation marks.

Usage

Use this function to determine whether an image file is valid. This function returns a False value if the image file format is not supported by the server where ColdFusion is deployed, or if the pathname to the image file is null or invalid.

For a list of standard image file formats supported by ColdFusion, see the supported image file formats provided in cfimage. To determine which image file formats are supported on the server where ColdFusion is deployed, use the GetReadableImageFormats and GetWriteableImageFormats.

Example

<!--- Use the IsImageFile function to determine whether an image retrieved from the artwork table in the cfartgallery database is a valid image file. ---> 
<cfif IsImageFile("images/#artwork.largeImage#")> 
    <cfset myImage=ImageNew("images/#artwork.largeImage#")> 
    <cfset ImageResize(myImage,50,"")> 
    <cfimage action="writeToBrowser" source="#myImage#"> 
<cfelse> 
    <p>I'm sorry, there is no image associated with the title you selected. Please click the Back button and try again.</p> 
    </p> 
</cfif>