Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get image size in pixels

Posted on 2004-08-05
7
Medium Priority
?
376 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 450 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

688 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