How can I tell the dimensions of an image in ColdFusion?
ColdFusion does not have native image support (i.e., the ability to manipulate images) although it has been confirmed for the next version. However, there are multiple products that add this capability to ColdFusion. For this entry, we will look at ImageCFC, a free and open source solution created by Rick Root. This component provides multiple image manipulation options. To simply check the size of an image, you can use this code:
<cfset image = createObject("component", "image")>
<cfset info = image.getImageInfo("", expandPath("./storm.jpg"))>
<cfdump var="#info#">
The getImageInfo method returns a structure of data that contains information about the image, including its height and width. The same method can also be used to determine if a file is a valid image. If used against a non-image file, the returned structure will contain an error code with a value less than 0.
This question was written by Raymond Camden
It was last updated on December 26, 2006.