Solved

Get image size in pixels

Posted on 2004-08-05
7
367 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now