ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 26th, 2005, 10:52 PM
erikd erikd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: NYC
Posts: 81 erikd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 19 sec
Reputation Power: 5
File Upload resize image based on height and width

I have a form that lets a user upload an image file with other description fields as well. I want to show a preview of the file or resize the file(would rather resize it) and then insert it into a database so that I can retrieve it later, either way I want to resize the file based on a ratio of the original file's height and width.
I know you can't find the height and width of an image uploaded with just cffile (I have CF MX 6.1). I found a custom tage and installed .dll within the CF Admin successfully. I got the custom tag from:
http://www.chestysoft.com/jpegresize/manual.htm

So I have the following example below on my site once a user has submitted the form it takes them to this code below. However it doesn't resize the file and most files look distorted. Does anyone have any experience with this or have any suggestions for me. Thanks.

<cfcache action="flush">
<cfx_jpegresize action="resize" width="200" source="C:\path\to\file\big\#file.serverfile#" filename="C:\path\to\file\big\#file.serverfile#">
<cfcontent type="image/jpeg" file="C:\path\to\file\big\#file.serverfile#" deletefile="no">
<cffile action="UPLOAD" filefield="file_path" accept="image/*" destination="C:\path\to\file\big" nameconflict="MAKEUNIQUE">
<cfset uploadedfile = "C:\path\to\file\big\#file.serverfile#">
<p align="center">Click the confirm button to insert into the database</p>
<cfoutput><img src="big/#file.serverfile#" border="1" height="200" width="300"></cfoutput><cfoutput>Title of Catch: #form.title# <br> Species: #form.species# <br> Fish Dog Product: #form.product# <br> Weight: #form.weight# lbs <br> Comments: #form.comments# Image:#file.ServerFile#</cfoutput>
<cfoutput>
<form action="thebigfish.cfm" method="post">

<input type="submit" name="InsertIt" value="Click to confirm">
<input name="Image" type="hidden" value="#file.ServerFile#"><input name="Image" type="hidden" value="#file.ServerFile#">
</form> </cfoutput>

Reply With Quote
  #2  
Old April 27th, 2005, 08:32 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
Unfortunately no, the only tags I've used are cfx_image and the Alagad image component. You can also make calls directly to the Java Advanced Imaging API classes which are part of the Java Runtime.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old April 27th, 2005, 02:15 PM
erikd erikd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: NYC
Posts: 81 erikd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 19 sec
Reputation Power: 5
nm

Reply With Quote
  #4  
Old April 27th, 2005, 02:16 PM
erikd erikd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: NYC
Posts: 81 erikd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 19 sec
Reputation Power: 5
Thanks for the CFX_Image, I was able to find it. One question I have though is that it came with two .dll files, I installed the first one correctly: cfx_image_mx.dll
The other dll was Image.dll
Do I need to install this file as well the same why I did the first one.

When I run the following tag I get an error "Element SERVERFILE is undefined in FILE"

<CFX_Image ACTION="RESIZE" FILE="C:\path\to\file\bigfish\#form.file_path#" OUTPUT="C:\path\to\file\bigfish\ok.jpg" BITCOUNT="24" QUALITY="100" X="250">

I just made up the image name ok.jpg, I didn't know how to get it to assign a name to the new resized image. Any help on that would be greatly appreciated. I was hoping to have a thumbnail of the image as well as a regular size of the image, but have no idea how to do this.

Thanks again

Reply With Quote
  #5  
Old April 29th, 2005, 12:42 AM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
First off i have no idea what im talking about...that said

why dont you resize the image and for the persons profile show that image and then for the thumbnail make the sizes uniform, in other words the thumnails are all the same size. you can do this with plain html ie. width="50" height="50". Probably not what ur looking for my bad in advance.

-Alas

Reply With Quote
  #6  
Old April 29th, 2005, 08:15 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
Alas's idea is indeed a viable solution in certain situations. The problem is that let's say the actual image is 640x480. If you force it to 50x50 in the img tag, the download size of the image is still 640x480 (so it's big), and the image you see that is at 50x50 will be extremely distored and "smushed". So this woudn't really work well for big images. But if you know that most of the images will be relatively small, just forcing the display to 50x50 in the img tag might work.

Reply With Quote
  #7  
Old April 29th, 2005, 09:52 AM
erikd erikd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: NYC
Posts: 81 erikd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 19 sec
Reputation Power: 5
Yea, that is why i started in on resizing the images, a)size b)they look distorted, and if a person uploads a file that is say 50x50 and I have the image tag set to 250x250, then that looks terrible as well. Most of the images that will be uploaded will come straight from a digital camera and will have a large resolution, so I am trying to resize them with coldfusion so the person doesn't have to wait on me to take the image into photoshop, resize it, and then upload it to their account. But I guess I will have to do this, if I can't get the images to look half way presentable with CFX_Image. BTW, I am not too concerned about making them all into thumbnails, I just want an image that is uploaded as 1200x1400 to have the same resized ratio as that of an image 400x100. I hope this makes sense.

Will the CFX_Image tag I have not take care of this problem?
Does anyone have a simple example of a CFX_Image tag they can post to show me how it works, so that I can see if this is viable before I get too deep into the problem. Thanks.

Reply With Quote
  #8  
Old April 29th, 2005, 10:44 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
cfx_image should definitely be able to do it. I don't know of an example on the web but i thought the download had some documentation. In any event the tag is fairly straightforward to use.

Reply With Quote
  #9  
Old May 12th, 2005, 02:53 AM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
im intentionally bumping this thread the dating site i built is beggining to encounter this same problem. im gonna check out the tag you guys mentioned but i have seen pictures resized proportionalty in the html of a page and when clicked the full image comes out.

An example of 1 of the places ive seen this is http://www.deviantart.com i know its not written in coldfusion.

Any thoughts?

Reply With Quote
  #10  
Old May 12th, 2005, 08:35 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
cfx_image or the Alagad Image Component will do image resizing. You can also download and use the Java Advanced Imaging API available from Sun. Basically there are two images, the thumbnail and the full image. When you click the thumbnail, it gives you the full image.

Reply With Quote
  #11  
Old May 25th, 2005, 01:46 AM
dunskii dunskii is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 45 dunskii User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 21 m 14 sec
Reputation Power: 4
i am in the process of using cfx_image for the first time and works great, though is there a way to check if the height or width is larger before resizing the image. ie if the height is large than width, the image will need to be resize by height, or visa versa.

cheers,ad

Reply With Quote
  #12  
Old May 25th, 2005, 08:18 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
Not that I know of, you'll probably have to use the tag to check the width and height and then resize based on that.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > File Upload resize image based on height and width


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 |