Cold Fusion Development
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Dev Articles Community ForumsProgrammingCold Fusion Development

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
Unread Dev Articles Community Forums Sponsor:
Old July 29th, 2009, 09:43 AM
edzvq edzvq is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
Join Date: Jul 2009
Posts: 1 edzvq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 16 sec
Reputation Power: 0
Resize image and Upload

Please help me figure this out, my code to upload and resize an image works, but it cannot handle a large 5mega pxl image. It tries to upload the image first and then it resizes it. I need help for this code to first resize the image before it uploads.

<!--- set the full path to the images folder --->
<cfset mediapath = ExpandPath("myimages")>

<!--- set the desired image height ---->
<cfset thumbsize = 75>

<!--- set the desired image width --->
<cfset imagesize = 400>

<cffile action="upload"

<!--- read the image ---->
<cfimage name="uploadedImage"
source="#MediaPath#/#file.serverFile#" >

<!--- figure out which way to scale the image --->
<cfif uploadedImage.width gt uploadedImage.height>
<cfset thmb_percentage = (thumbsize / uploadedImage.width)>
<cfset percentage = (imagesize / uploadedImage.width)>
<cfset thmb_percentage = (thumbsize / uploadedImage.height)>
<cfset percentage = (imagesize / uploadedImage.height)>

<!--- calculate the new thumbnail and image height/width --->
<cfset thumbWidth = round(uploadedImage.width * thmb_percentage)>
<cfset thumbHeight = round(uploadedImage.height * thmb_percentage)>

<cfset newWidth = round(uploadedImage.width * percentage)>
<cfset newHeight = round(uploadedImage.height * percentage)>

<!--- see if we need to resize the image, maybe it is already smaller than our desired size --->
<cfif uploadedImage.width gt imagesize>
<cfimage action="resize"

<!--- end --->


Reply With Quote

Viewing: Dev Articles Community ForumsProgrammingCold Fusion Development > Resize image and Upload

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap