Solved

Get image size in pixels

Posted on 2004-08-05
7
374 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
What You Need to Know when Searching for a Webhost Provider
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

626 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