> Recently, someone has posted how to check image sizes using java in CF.
> This was not posted by me, but it was in response to my query. Works
great. My thanks to the person who first posted it.
<!--- function to get the properties of the image file --->
<cfscript>
function get_imageinfo(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");
get_imginfo = StructNew();
get_imginfo.ImgWidth = ImageObject.getWidth();
get_imginfo.ImgHeight = ImageObject.getHeight();
get_imginfo.SizeKB = sizekb;
get_imginfo.SizeMB = sizemb;
get_imginfo.ImageFormat = ListLast(ListLast(imgfile, "\"), ".");
}
</cfscript>
<cfset tmp = get_imageinfo("MYPATH\MYFILENAME") /> <!--- this is
the image file to get --->
<cfset width=#get_imginfo.ImgWidth#> <!--- this is
the resulting image width --->
<cfset height=#get_imginfo.ImgHeight#> <!--- this is
the resulting image height --->
<!--- now define what to test width and height against and what to
do --->
<cfif width gt MYMAXWIDTH or height gt MYMAXHEIGHT>
File To Large
<cfelse>
File OK
</cfif>
Robert B. Harrison
Director of Interactive services
Austin & Williams
125 Kennedy Drive, Suite 100 Hauppauge NY 11788
T : 631.231.6600 Ext. 119
F : 631.434.7022
www.austin-williams.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:305231
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4