Not Politics - A ColdFusion Image Tip

So, I'm currently working on a new application for the next DRK. I can't say much about it (it's code named Harlan), but I can talk about an issue I ran into. I needed a quick way to determine the height and width of an image. Normally I would use Alagad for this type of task. I really like Alagad - it's like the Bass-O-Matic of Image tools, and the price is right. But - it's not free, so I can't include it in the DRK. However, I did find this nice tip by David Medlock:

<cfobject type="JAVA" action="Create" name="tk" class="java.awt.Toolkit">
<cfobject type="JAVA" action="Create" name="img" class="java.awt.Image">
<cfscript>
img = tk.getDefaultToolkit().getImage(fname);
width = img.getWidth();
height = img.getHeight();
</cfscript>

Archived Comments

Comment 1 by Barneyb posted on 6/16/2005 at 8:19 PM

There was an AIC Lite included in one DRK or another that was free. Not that you still need a solution, but that is out there.

Comment 2 by Raymond Camden posted on 6/16/2005 at 8:27 PM

Yea, the Lite version is also very powerful - but it would require users to have the DRK. Now this is an app for _another_ DRK, so that may be safe, but I don't want any dependancies on other DRKs.

Comment 3 by Marcos Placona posted on 6/16/2005 at 8:47 PM

I already did a ColdFusion function using this code on the start of 2004 and sent it to CFLIB.ORG, but it was never online.

Regards,

Marcos

Comment 4 by Raymond Camden posted on 6/16/2005 at 8:52 PM

That's because we had one already. It did it via reading in file bits.

Comment 5 by Pete Freitag posted on 6/16/2005 at 9:16 PM

The second CFOBJECT call is not necessary in your code sample.

Comment 6 by Marcos Placona posted on 6/16/2005 at 9:22 PM

Ray, you mean this one: http://cflib.org/udf.cfm?ID...

It's very complicated, maybe you should add this different way.

Comment 7 by Pete Freitag posted on 6/16/2005 at 9:35 PM

Marcos, the one in CFLib is nice though because it doesn't require AWT, so on some unix servers that is good.

Maybe you could add this one as AWTImageSize or something.

Comment 8 by Brian Rinaldi posted on 6/16/2005 at 9:36 PM

Another free solution that I have used is tmt_img by Massimo Foti. It is available here http://www.olimpo.ch/tmt/cf...

Comment 9 by tony petruzzi posted on 6/16/2005 at 11:04 PM

It's amazing that alot of CF programmers I have talked to forget that you can leverage Java extremly easy in CFMX.

I use Java ALOT in the application that I write because I find alot of times CFMX doesn't have a function that I need or simply can't do what I need it to do practically.