|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
nm
|
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
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 |
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||
|
|||
|
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. |
|
#8
|
|||
|
|||
|
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.
|
|
#9
|
||||
|
||||
|
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? |
|
#10
|
|||
|
|||
|
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.
|
|
#11
|
|||
|
|||
|
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 |
|
#12
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > File Upload resize image based on height and width |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|