Solved

Get image size in pixels

Posted on 2004-08-05
7
373 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

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.
What You Need to Know when Searching for a Webhost Provider
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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