Skip to content

Instantly share code, notes, and snippets.

@chrisdpeters
Created February 13, 2012 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdpeters/1821076 to your computer and use it in GitHub Desktop.
Save chrisdpeters/1821076 to your computer and use it in GitHub Desktop.
Super-Slow ColdFusion Image Processing
<cffunction name="setImageSizes" access="private" hint="Resizes image in queue, moves new resized files to 'production,' and removes `tempUploadId` from DB.">
<cfset var loc = {}>
<cfif isUploadingNewFile()>
<!--- Read image --->
<cflog file="siteScreenshotResize" text="Reading #this.imageFile#">
<cfset loc.image = ImageRead("#variables.UPLOAD_QUEUE_DIRECTORY##this.imageFile#")>
<!--- Turn on antialiasing to improve image quality --->
<cfset ImageSetAntialiasing(loc.image, "on")>
<cfthread
action="run"
name="loc[#CreateUuid()#]"
priority="low"
image="#loc.image#"
dsn="#get('dataSourceName')#"
thisId="#this.id#"
>
<!--- Resize full size --->
<cfset resizeImage(image, "full", 1)>
<!--- Resize medium size --->
<cfset resizeImage(image, "medium", 0.9)>
<!--- Resize thumbnail --->
<cfset resizeThumbnail(image, "thumb", 0.8)>
<!--- Update DB to reflect new status
(Use query because model doesn't seem to be working inside of thread) --->
<cfquery datasource="#dsn#">
UPDATE
sitescreenshots
SET
tempuploadid = NULL
WHERE
id =
<cfqueryparam cfsqltype="cf_sql_integer" value="#thisId#">
</cfquery>
</cfthread>
</cfif>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment