Cool, I will try it...:)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ken Ferguson
Sent: Friday, January 21, 2005 10:27 AM
To: [email protected]
Subject: RE: image manipulation

Ron, I'm actually doing all of this in PHP and not in CF. Here's my code
and I think you can use the script that Adrian posted to do something
similar! I tested the CF code below and it works, so let me know if you
have any other questions or if I can help any more.

------------------------
//this is inside a loop
$imgInf = @getimagesize($arr_grouping[$i]["image"]);
        $imageWidth = $imgInf[0];
        $imageHeight = $imgInf[1];
        if( $imageWidth > 200 ) {
                $wdiff = ($imageWidth/200);
                $wdisp = 200;
                $hdisp = $imageHeight/$wdiff;
        }
        else{
                $hdisp = $imageHeight;
                $wdisp = $imageWidth;
        }
$ImgDisp .= "<img src='".$arr_grouping[$i]["image"]."'
alt='".$arr_grouping[$i]["url"]."' width='".$wdisp."'
height='".$hdisp."' border='0' />";
        }
//end loop after all that
------------------------

So, something like this will work in CF:

------------------------
<cfscript>
tk = CreateObject("java", "java.awt.Toolkit");

// "myImage" has to have the full physical path and file name.
myImage = "D:\fitzandfloyd2\immagini\featureditem.gif";

img = tk.getDefaultToolkit().getImage(myImage);

width = img.getWidth();
height = img.getHeight();

if(width gt 50){
        wdiff = width/50;
        wdisp = 50;
        hdisp = height/wdiff;
}
else{
        hdisp = height;
        wdisp = width;
}
</cfscript>
<cfoutput>
        #wdisp#<br>#hdisp#<br>#width#<br>#height#
        <img src="featureditem.gif" width="#variables.wdisp#"
height="#variables.hdisp#">
</cfoutput>
------------------------

Of course, this is quick and dirty. You could use config-type variables
for your display ranges so you aren't hard-coding numbers in there.

--Ferg

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ron Mast
Sent: Friday, January 21, 2005 9:20 AM
To: [email protected]
Subject: RE: image manipulation

Ken what custom tag are you using to change the w and h of your images?
Cause the one I'm using only allows me to change the width I believe.
That can be good or bad.  Good that the images that gets uploaded will
never be distorted unless it was distorted in the first place.  Bad that
the image uploaded may exceed the height criteria.     

Ron

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ken Ferguson
Sent: Friday, January 21, 2005 8:33 AM
To: [email protected]
Subject: RE: image manipulation

I don't know what Kevin is trying to do exactly, but there could be many
reasons -- "I'm sorry, you can't upload images greater than 200*200" or
"Your image is 50*50 and may appear distorted when the site displays it
at the 300*300 default setting" ... You can use this information for any
number of purposes. I do something similar in a PHP app that I have so
people don't upload logos that are bigger in dimension than I want to
show. But I still allow them to upload images of custom width and height
as long as they don't exceed my maximums... 

Also, I have images of products that could be 300*300. They could be
280*280, or they could be 300* 225. If I want to show those images at
something like 90 pixels wide. I need to know the width and height so I
can manipulate them without distorting the image if it isn't square.

--Ferg

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dan Blackman
Sent: Friday, January 21, 2005 8:11 AM
To: [email protected]
Subject: RE: image manipulation

The curious question here is "Why would you want to find the height and
width of a client side object?"

Curious!?

Dan

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Adrian J. Moreno
Sent: Thursday, January 20, 2005 11:30 PM
To: [email protected]
Subject: Re: image manipulation

Found via Google: http://www.sitepoint.com/blog-post-view.php?id=168133

Quick and Dirty Way to get Image Dimensions by David Medlock

However I can't see the need to invoke java.awt.Image as he has, so I 
removed the call. I also shoved everything into <cfscript>.

-------------------- <code> --------------------
<cfscript>
tk = CreateObject("java", "java.awt.Toolkit");

// "myImage" has to have the full physical path and file name.
myImage = "C:\fi_logo.gif";

img = tk.getDefaultToolkit().getImage(myImage);

width = img.getWidth();
height = img.getHeight();
</cfscript>

<cfoutput>
W: #variables.width#
<br />
H: #variables.height#
</cfoutput>
-------------------- </code> --------------------

Edit: Daniel's post showed up just before I hit submit. Tested on my 
local Win2k desktop (CFMX on JBoss via cygwin), but this code should run

anywhere java runs.

Booyah!

-- Adrian


Kevin Fricke wrote:
> Yes but I am trying to find out if there is a way for Coldfusion to
> determine the size of the image....WxH?
> 
> Any ideas?
>   -----Original Message-----
>   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>   Sent: Thursday, January 20, 2005 1:15 PM
>   To: [EMAIL PROTECTED]
>   Subject: Re: image manipulation
> 
> 
>   Doesn't photoshop give you this info when you check on Image size?
> 

----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm




----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm




----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm




----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm




----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm




----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe:
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
   http://www.dfwcfug.org/form_MemberRegistration.cfm


Reply via email to