Nice. =)

Does this work on Linux implementations of CFMX as well?

-JM

Bryan Stevenson wrote:

>No you don't need to buy anything....use this method (I've posted it at 
>least 5-6 times by now)....drop it in a CFC and away you go....will work on 
>MX 6.x/7
>
>No need for any Java classes/jars to be added to CF
>
>  <!---(Function: 
>ThumbIt)------------------------------------------------------
>  Date Created:   December 1, 2003
>  Author:         Bryan Stevenson
>  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 dimensions --->
>    <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>
>
>Hope that does the trick
>
>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 
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:212451
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to