Thursday, November 8, 2012

ColdFusion: How to Get Image Dimensions

Starting with ColdFusion 8, you can easily check the dimensions of an image server side. No, I am not referring to <cfimage> which is overkill for many image related tasks IMHO. What I am referring to is imageInfo. The process is actually simple: create a ColdFusion image variable then check the properties of the image.

<cfset cfImage = imageNew(newfile)>
<cfset imageData = imageInfo(cfImage )>
<cfset vars.imageWidth = imageData.width>
<cfset vars.imageHeight = imageData.height>

Raymond Camden has an excellent write-up on this HERE, which is summarized above.

No comments:

Post a Comment