I just posted this to the "cool things about cf" thread as an easy, useful
example of java instantiation.

<cfscript>
function bhimginfo(imgfile){
        jFileIn = createObject("java","java.io.File").init(imgfile);
        ImageInfo = StructNew();
        ImageObject =
createObject("java","javax.imageio.ImageIO").read(jFileIn);

        imageFile = CreateObject("java", "java.io.File"); 
        imageFile.init(imgfile); 
        sizeb = imageFile.length(); 
        sizekb = numberformat(sizeb / 1024, "999999999.99");
        sizemb = numberformat(sizekb / 1024, "99999999.99");
        
        bhImageInfo = StructNew();
        bhImageInfo.ImgWidth = ImageObject.getWidth();
        bhImageInfo.ImgHeight = ImageObject.getHeight();
        bhImageInfo.SizeB = sizeb;
        bhImageInfo.SizeKB = sizekb;
        bhImageInfo.SizeMB = sizemb;
}
</cfscript>

It builds a structure called bhImageInfo that holds width, height and file
size (b, kb, and mb) about the image passed to it.

Just call it like so...

#bhimginfo('d:\path\to\image.jpg')#

Then dump bhimginfo to see everything returned

Also... dump imageFile to see a TON of other methods/properties that could
be used.




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 10, 2006 11:38 AM
To: CF-Talk
Subject: CFFILE action="upload"

All,

Does anyone know a way to check a image file's height and width before or
after an image has been uploaded? I'm restrictinig the file type for *.jpg
only.

I want to take the height and width values of the image being uploaded and 
see if the values fall within an acceptable height and width range.

Thanks.

D



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259907
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to