If all you're doing is resizing...try my function:

  <!---(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>


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
----- Original Message ----- 
From: "DRE" <[EMAIL PROTECTED]>
To: "CF-Talk" <[email protected]>
Sent: Tuesday, April 12, 2005 12:17 PM
Subject: cfx image?


> Hi,
> I've fiddled with some image manipulation tags and found some of them
> to make jagged images on resize. Anybody know how good cfx image is at
> resizing?
>
> I previously used imagemagic which seems very good but the docs say it
> doesnt work with mx because of issues with cfexecute. Anybody knows if
> this is ok now?
>
> Thanks!
>
> -- 
> DRE
> http://www.webmachineinc.com
> http://www.theanticool.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:202463
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

Reply via email to