Here ya go Mike & Ray.....3 methods (get file size, get image width/height,
resize image).
No need to add anything....will simply work on any MX version (AFAIK)
Let me know if you guys need any help....alll you should need is to wrap
these ina CFC and call them ;-)
Cheers
<!---(Function:
FileSize)------------------------------------------------------
Date Created: March 12, 2004
Author: Phil
Arguments: FileLoc - full path of file (string) required
Purpose: Gets the size of a file in bytes
Returns: File Size in bytes (numeric)
--->
<cffunction name="FileSize" returnType="numeric" access="public">
<cfargument name="FileLoc" type="string" required="Yes">
<cfset jFileIn =
CreateObject("java","java.io.File").init(ARGUMENTS.FileLoc)>
<cfreturn jFileIn.Length()>
</cffunction>
<!---(Function:
ImageSize)------------------------------------------------------
Date Created: November 28, 2003
Author: Bryan
Arguments: FileLoc - full path of image to get details for (string)
required
Purpose: returns file width/height
Returns: ImageInfo structure with ImgWidth/ImgHeight keys
--->
<cffunction name="ImageSize" returnType="struct" access="public">
<cfargument name="FileLoc" type="string" required="Yes">
<cfset jFileIn =
createObject("java","java.io.File").init(ARGUMENTS.FileLoc)>
<cfset ImageInfo = StructNew()>
<cfset ImageObject =
createObject("java","javax.imageio.ImageIO").read(jFileIn)>
<cfset ImageInfo.ImgWidth = ImageObject.getWidth()>
<cfset ImageInfo.ImgHeight = ImageObject.getHeight()>
<cfreturn ImageInfo>
</cffunction>
<!---(Function:
ThumbIt)------------------------------------------------------
Date Created: December 1, 2003
Author: Bryan
Arguments: FileLoc - full path of image to be thumbnailed (string)
required
ThumbPrefix - string to append to the filename to name the
thumbnail (string) not required
ScaleBy - which dimension to scale by "W or H" (string)
required
ScaleValue - the measurement of the dimension specified in
ScaleBy to use to calculate proper scale (string) required
Purpose: shrink an image
Returns: N/A
--->
<cffunction name="ThumbIt" access="public">
<cfargument name="FileLoc" type="string" required="Yes">
<cfargument name="ThumbPrefix" type="string"required="No" default="">
<cfargument name="ScaleBy" type="string" required="Yes">
<cfargument name="ScaleValue" type="string"required="Yes">
<cfset jFileIn =
createObject("java","java.io.File").init(ARGUMENTS.FileLoc)>
<!--- build new file loc and name --->
<cfset DirPath = GetDirectoryFromPath(ARGUMENTS.FileLoc)>
<cfset FileName = GetFileFromPath(ARGUMENTS.FileLoc)>
<cfset ThumbFileLoc = DirPath & ARGUMENTS.ThumbPrefix & FileName>
<cfset jFileOut =
createObject("java","java.io.File").init(ThumbFileLoc)>
<!--- set dimiensions --->
<cfset inBufferedImg =
createObject("java","javax.imageio.ImageIO").read(jFileIn)>
<cfset ImgWidth = inBufferedImg.getWidth()>
<cfset ImgHeight = inBufferedImg.getHeight()>
<!--- calculate scale --->
<cfif UCase(ARGUMENTS.ScaleBy) eq "W">
<cfset Scale = ARGUMENTS.ScaleValue / ImgWidth>
<cfelseif UCase(ARGUMENTS.ScaleBy) eq "H">
<cfset Scale = ARGUMENTS.ScaleValue / ImgHeight>
</cfif>
<!--- define thumbnail dimensions --->
<cfset ScaledWidth = (Scale * ImgWidth)>
<cfset ScaledHeight = (Scale * ImgHeight)>
<!--- create image output --->
<cfset outBufferedImg =
createObject("java","java.awt.image.BufferedImage").init(JavaCast("int",
ScaledWidth), JavaCast("int", ScaledHeight), JavaCast("int", 1))>
<!--- create the AffineTransform --->
<cfset jTransform =
createObject("java","java.awt.geom.AffineTransform").init()>
<cfset temp = jTransform.Scale(Scale, Scale)>
<!--- initialize a Graphics2D object --->
<cfset jGraphics2D = outBufferedImg.createGraphics()>
<!--- draw the thumbnail --->
<cfset temp = jGraphics2D.drawRenderedImage(inBufferedImg, jTransform)>
<cfset temp = jGraphics2D.dispose()>
<!--- write the thumbnail image to disk --->
<cfset fileWritten =
createObject("java","javax.imageio.ImageIO").write(outBufferedImg, "jpg",
jFileOut)>
</cffunction>
Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
phone: 250.480.0642
fax: 250.480.1264
cell: 250.920.8830
e-mail: [EMAIL PROTECTED]
web: www.electricedgesystems.com
----- Original Message -----
From: "Mike Soultanian" <[EMAIL PROTECTED]>
To: "CF-Talk" <[email protected]>
Sent: Wednesday, September 14, 2005 8:57 AM
Subject: Re: cfx_image or cfximage
> Well, let's see.
>
> Right now, here's what I use the tag for. I have a user upload a
> picture. Then, I rename the picture to a random filename. Next, I use
> cfximage to resize that image to 4 different sizes and store the output
> of each of those sizes to an appropriate name: filenameT, filenameS,
> filenameM, filenameL. I figured I would do the image processing ahead
> of time instead of on the fly because then it's only a web request for
> those images later on.
>
> I don't *think* I'm going to get any more advanced than that. As far as
> formats, I will allow uploads of jpg or gif.
>
> Any thoughts?
>
> Thanks,
> Mike
>
> Bryan Stevenson wrote:
>> Hey Mike,
>>
>> Perhaps knowing what you are planning on doing with these image tags will
>> help us guide you ;-)
>>
>> There are other options to those tags....Java comes to mind...faster and
>> free...all depends on what you're trying to do.
>>
>> For example if you simply want to re-size images....use Java...I'll give
>> you
>> the code!!
>>
>> HTH
>>
>> Cheers
>>
>> Bryan Stevenson B.Comm.
>> VP & Director of E-Commerce Development
>> Electric Edge Systems Group Inc.
>> phone: 250.480.0642
>> fax: 250.480.1264
>> cell: 250.920.8830
>> e-mail: [EMAIL PROTECTED]
>> web: www.electricedgesystems.com
>>
>>
>>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:218247
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54