Ninjakreborn Posted January 12, 2010 Share Posted January 12, 2010 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. Quote Link to comment Share on other sites More sharing options...
jl5501 Posted January 12, 2010 Share Posted January 12, 2010 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 Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 12, 2010 Share Posted January 12, 2010 the easiest way is to use imagemagick, so if you have that installed, I have an example code here: http://beta.phpsnips.com/snippet.php?id=111 if you do not have imagemagick installed, then there is another way of doing this using the GD library: http://beta.phpsnips.com/snippet.php?id=5 Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 12, 2010 Author Share Posted January 12, 2010 Cool thanks. Gives me some choices and some different ways to study. Thanks again. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 14, 2010 Author Share Posted January 14, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.