Bryan,

How is the quality on the resizes for that? I've used some java stuff
like that before and had issues with the quality. Things seemed to come
out a little distorted. From what I can see in the component, it doesn't
seem like there's any kind of argument for the quality. Let me know if
you've had similar experiences. For some of the people I've tried doing
this for, they're artists and bands and people who are a little more
particular about the resize quality so I really need it to be top notch.
Let me know.


John Burns
Certified Advanced ColdFusion MX Developer
Wyle Laboratories, Inc. | Web Developer
 

-----Original Message-----
From: Bryan Stevenson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 05, 2005 11:36 AM
To: CF-Talk
Subject: Re: image manipulation in coldfusion?

......and for those that care (Tony got his offlist)....here's the FREE
code I was on about yesterday.....enjoy!!

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

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

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:220132
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