Script to resize images
This code loops through all dmImages and resizes them according to dmImage form tools properties. This is great if there is an existing image library but the requirements have changed. Instead of going through every image and re-saving, just run this script.
"resizeImages.cfm"
<cfsetting requesttimeout="10000000"> <cfset oImageFormTool=createObject("component", "farcry.core.packages.formtools.image") /> <cfquery name="qImages" datasource="#application.dsn#"> SELECT * FROM dmImage where sourceImage != '' and status='approved' </cfquery> <cfloop query="qImages" > <cfscript > stargs=structnew(); stargs.source="#application.path.imageRoot#/#qImages.sourceImage#"; stargs.destination="#application.path.imageRoot#/#application.stCoapi.dmImage.stProps.ThumbnailImage.METADATA.ftdestination#"; stargs.width= application.stCoapi.dmImage.stProps.ThumbnailImage.METADATA.ftimagewidth; stargs.height=application.stCoapi.dmImage.stProps.ThumbnailImage.METADATA.FTIMAGEHEIGHT; stargs.interpolation=application.stCoapi.dmImage.stProps.ThumbnailImage.METADATA.ftinterpolation; stargs.resizeMethod=application.stCoapi.dmImage.stProps.ThumbnailImage.METADATA.FTAUTOGENERATETYPE; streturn=oImageFormTool.generateImage(argumentCollection=stargs); stargs=structnew(); stargs.source="#application.path.imageRoot#/#qImages.sourceImage#"; stargs.destination="#application.path.imageRoot#/#application.stCoapi.dmImage.stProps.standardImage.METADATA.ftdestination#"; stargs.width= application.stCoapi.dmImage.stProps.standardImage.METADATA.ftimagewidth; stargs.interpolation=application.stCoapi.dmImage.stProps.standardImage.METADATA.ftinterpolation; stargs.resizeMethod=application.stCoapi.dmImage.stProps.standardImage.METADATA.FTAUTOGENERATETYPE; streturn=oImageFormTool.generateImage(argumentCollection=stargs); </cfscript> <cfoutput> #qImages.title# done.. <br/> <cfflush /> </cfoutput> </cfloop>