Skip to content

Instantly share code, notes, and snippets.

@PintuKumarPal
Created November 25, 2013 20:36
Show Gist options
  • Save PintuKumarPal/7648424 to your computer and use it in GitHub Desktop.
Save PintuKumarPal/7648424 to your computer and use it in GitHub Desktop.
<!--- Upload file. --->
<cfset UploadPath="x:\abc\uploads">
<cfset ThumbnailHeight="200">
<cfset ThumbnailWidth="200">
<!---Logofile is the name of form fields--->
<cffile action="upload" filefield="#Logofile#" destination="#UploadPath#" nameconflict="MakeUnique">
<cfset LogoFile = #File.ServerFile#>
<cfset SourcePic = UploadPath & "/" & LogoFile>
<cfimage action="info" structname="imagetemp" source="#SourcePic#">
<cfset x=max(imagetemp.width,imagetemp.height)>
<cfset newheight=imagetemp.height*ThumbnailHeight/x>
<cfset newwidth=imagetemp.width*ThumbnailWidth/x>
<cfimage action="resize" source="#UploadPath#/#LogoFile#" width="#newwidth#" height="#newheight#" destination="#UploadPath#/t_#LogoFile#" overwrite="true">
<!---This is another way to create image thumbnail without losing dimension ratio.--->
<cffile action="upload" filefield="#Logofile#" destination="#UploadPath#" nameconflict="MakeUnique">
<cfset LogoFile = #File.ServerFile#>
<cfset SourcePic = UploadPath & "/" & LogoFile>
<cfimage source="#SourcePic#" name="SourceImage">
<cfset info=ImageInfo(SourceImage)>
<cfif Info.Width GE Info.Height>
<cfimage source="#SourcePic#" action="resize" width="219" height="" destination="#UploadPath#/t_#LogoFile#" overwrite="No">
<cfelse>
<cfimage source="#SourcePic#" action="resize" width="" height="234" destination="#UploadPath#/t_#LogoFile#" overwrite="No">
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment