I have a situation where I need to generate multiple images (different sizes
and cropping) from a single uploaded image. I have to build five different
images for uses in different ways. Essentially I upload the image to a temp
file, then run it through a function (I had one, now I have five - one for each
image result... one function is below).
Anyway, it works great the first and second time you upload an image, but it
slows down and degrades with each subsequent use. Anyone have any thoughts on
what I'm missing here?
Thanks
<cffunction name="crescendo_custom_full" returntype="any"
access="public" output="false">
<cfargument name="tempImage_name" type="string" required="true"
/> <!--- name of temp image file --->
<cfargument name="finalImage_name" type="string"
required="true" /> <!--- name of the final image file --->
<cfargument name="tempImage_width" type="string"
required="true" />
<cfargument name="tempImage_height" type="string"
required="true" />
<cfargument name="rootpath" type="string" required="true" />
<!--- name of the final image file --->
<cfset tempImage_path="#rootpath#\assets\project_gallery\temp">
<cfset fullImage_max_width=300>
<cfset fullImage_max_height=188>
<cfset
fullImage_path="#rootpath#\assets\project_gallery\tmb_full">
<!--- BUILD FULL IMAGE --->
<cfset
newfullImage=ImageRead("#tempImage_path#\#tempImage_name#")>
<cfset scale_width=0>
<cfset scale_height=0>
<cfset w_scaling=tempImage_width/fullImage_max_width>
<cfset h_scaling=tempImage_height/fullImage_max_height>
<cfif w_scaling gt h_scaling>
<cfset scale_height=1>
<cfelseif h_scaling gt w_scaling>
<cfset scale_width=1>
</cfif>
<!--- resize image to limit image --->
<cfif scale_width eq 1 or scale_height eq 1>
<cfif scale_width eq 1>
<cfset
ImageScaletoFit(newfullImage,fullImage_max_width,"","highPerformance")>
<cfelseif scale_height eq 1>
<cfset
ImageScaletoFit(newfullImage,"",fullImage_max_height,"highPerformance")>
</cfif>
</cfif>
<cfset curHeight=ImageGetHeight(newfullImage)>
<cfset curWidth=ImageGetWidth(newfullImage)>
<cfif scale_width eq 1>
<cfset yCrop=Fix(curHeight-fullImage_max_height)/2>
<cfset ImageCrop(newfullImage, 0, yCrop, curWidth,
fullImage_max_height)>
<cfelseif scale_height eq 1>
<cfset xCrop=Fix(curWidth-fullImage_max_width)/2>
<cfset ImageCrop(newfullImage, xCrop, 0,
fullImage_max_width, curHeight)>
</cfif>
<cfimage action="write" source="#newfullImage#"
destination="#fullImage_path#\#finalImage_name#" overwrite="yes" quality=".75">
<cfset newfullImage="">
<!--- end build full image --->
</cffunction>
Robert Harrison
Director of Interactive Services
Austin & Williams
Advertising I Branding I Digital I Direct
125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788
T 631.231.6600 X 119 F 631.434.7022
http://www.austin-williams.com
Blog: http://www.austin-williams.com/blog
Twitter: http://www.twitter.com/austin_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355887
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm