Pablo Varando's ColdFusion Blog

ColdFusion 5 - Get Image Information....

There are a couple of ways to achieve this... I've found out once again.... It's been a while since I used CF 5... WOW what a difference 8 is to it... anyways, back to the topic.

The first way

<cfset imgFile = createObject("java","javax.swing.ImageIcon").init(expandPath('/images/fileName.jpg'))>
<cfset imgFile.getImage()>
<cfset imgWidth = imgFile.getIconWidth()>
<cfset imgHeight = imgFile.getIconHeight()>

For this however, Java must be installed on the server. I know it's installed by default with ColdFusion MX or higher... but not the case all the time with CF 5.

There are a few tags (This is the one I recommend) that will also do the trick; however some are cheap, some are free and the one I used costs around $100 bucks.

The tag is Efflare ImageCR (you can get it here: http://www.efflare.com )

You can read the documentation, but since the library is written in c++ it is compatible with CF 5... so there goes that... let me know if you have any questions!

Comments
Ryan's Gravatar We used to use a COM object called ASPImage from Server Objects (serverobjects.com). It's $70 but it's makes working with images in pre-CF 8 pretty painless, well almost.
# Posted By Ryan | 12/8/08 2:23 PM