does anyone know how i can resize an image when someone tries to upload a file to my site but not as a thumbnail actually resize the image ??
Three answers:
2007-12-26 23:13:27 UTC
i think the bellow fuction can resize the image thez going to be uploaded to your size..
bool imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
?
2007-12-29 10:07:39 UTC
There are various ways...
The first problem is that you cannot know te image size on the server BEFORE it is uploaded!
So, you can limit the upload size (use MAXSIZE in file transfer).
When it is uploaded, use the function "getimagesize" to find out its size.
Then use the function above (resize).
Check the functions at www.php.net, search "getimagesize", and on the left, you have all image functions.
Very useful.
General Cucombre
2007-12-27 06:05:06 UTC
I don't think GD will do.
Invoke 'convert' utility from ImageMagick via exec() - it is available on most Unix hosting platforms:
For example:
convert -geometry 400x200 file1.jpg file2.jpg
Of course, there's more to that, but I hope you get the idea.
---
On the second thought, GD seems to be capable of image resizing, however, I haven't verified that.
Check this:
http://us2.php.net/imagecopyresized
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.