Jump to content

Image resizing after upload


Ninjakreborn

Recommended Posts

I have a form that loads up a file to the server.  So far I am taking the file, deleting the old one, and moving the new one as well as databasing the name.  Now that I am done with all of that I have an image file that is sitting on the server and I have the path name to it.  I need to resize them down to a specific height and width. Is there a way to take the path of the image and just resize the image where it is located...I am not looking for a lot of detail, just someone to point me in the right direction.

Link to comment
Share on other sites

There are a couple of ways of doing this.

 

firstly, entirely in your own custom code, you can load the image with the appropriate imagecreatefrom...() function like imagecreatefromjpeg(), and then use the imagecreatetruecolor() function to create a new image, and load your image into this using imagecopyresampled(), then save it to a new or the original filename with the appropriate image...() function, like imagejpeg()

 

Secondly, you can use a script like phpthumb, which does all this for you, normally on the fly for display, but can be used for saving the resultant image.

 

I have written a site which makes extensive use of phpthumb for varous sized images from the one uploaded fullsize image, and this is done without saving the resized images.

 

See this on www.skateperception.com

 

Best regards

John 

JML

 

Link to comment
Share on other sites

http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php

I thought I would share this.

After what you said about image magick and the other library (Which I had already known about but had never used)

I found this really cool class. I popped it into Zend Framework and I was able to load an image that was saved, resize it

however I want (perfectly) and save it right back over the old file with no issues. This worked perfectly, thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.