Solved

Get image size in pixels

Posted on 2004-08-05
7
371 Views
Last Modified: 2013-12-24
Trying to figure out if CF has any way to capture the size (width and height) of an image in pixels--without using any special custom tags or other special means.  CFFILE doesn't seem to get the job done on this.

I have seen other questions on the site, but my account seems to be acting funky and i cannot access the answers (it just brings me to a credit card page when i click on the link to view the detail of the search result).


Thanks!

M
0
Comment
Question by:mcarr1
7 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 11729152
Hi mcarr1,
I do not think so you can do it without custom tags.

Regards,
---Pinal
0
 

Accepted Solution

by:
speshal earned 150 total points
ID: 11732931
I've been using the code below, not sure where i got it.  Will work on gif's and jpg's as far as I know:

<cfobject type="java" action="create" name="jtk" class="java.awt.Toolkit">
<cfobject type="java" action="create" name="jimg" class="java.awt.Image">
<cfset jimg = jtk.getDefaultToolkit().getImage("C:\full\path\to\image.gif")>
<cfoutput>
       #jimg.getWidth()#
      #jimg.getHeight()#
</cfoutput>
0
 
LVL 11

Expert Comment

by:hart
ID: 11734061
you can not do this byuing just cffile tag
speshal has kind of given you the solution...

but for it to work u need the class file created in java.
You  will have to install it using cf admin and then use it...

There is no other way to do it in CF ...

Regards
Hart

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 4

Expert Comment

by:eclipse2k
ID: 11734648
i am using some java code VERY similar to speshal's solution (based on same java commands) so please note that the code might not work with all JPGs. i guess it probably depends of the compression of the file, or something different.

i used it to calculate images from different sources and some images return "-1" for getWidth and getHight, so you should take care.

as far i know there is no other possibility, but i am quite sure that there are similar solutions based on Microsofts COM Objects.


eclipse2k
0
 

Author Comment

by:mcarr1
ID: 11739436
speshal: do you have any idea where one could find the class file for that code?

Thanks for the effort.

Seems like Macromedia should look into this capability for future versons, since it would really help to have the ability to check, say, a banner to make sure it is of a certain size.
0
 
LVL 4

Expert Comment

by:eclipse2k
ID: 11739568
When you are using Coldfusion MX 6.1 (guess, 6.0 is also ok), the JRE classes are already included, since Coldfusion is completely buid on Java Enterprise Server technology.
0
 

Expert Comment

by:speshal
ID: 11743126
Yes, I am using Coldfusion MX 6.1 as well, and already had the classes.  You can dowload sun's jre or jdk which contains the java.awt classes at http://java.sun.com.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
What You Need to Know when Searching for a Webhost Provider
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question