Created
February 13, 2012 22:36
-
-
Save chrisdpeters/1821076 to your computer and use it in GitHub Desktop.
Super-Slow ColdFusion Image Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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