How to resize jpg file in PHP?
It is now 925 * 1139, I want to change it to 90 * 110.
+2
Mask
source
to share
4 answers
try imagecopyresampled
PHP Function or imagecopyresized
from GD Library .
+6
Patrice bernassola
source
to share
Basically using GD is pretty straightforward once you know what to do.
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width, $height) = getimagesize($uploadedfile);
$tmp = imagecreatetruecolor(800, 600);
$filename = '/path/to/images/' . $_FILES['file']['name'];
imagecopyresampled($tmp, $src, 0, 0, 0, 0, 800, 600, $width, $height);
imagejpeg($tmp, $filename, 100);
Check the blog again for details.
+3
Savas Vedova
source
to share
Here you can change a class called SimpleImage. Or take a look at the source and see how they solve the problem:
SimpleImage code
0
GSto
source
to share
I haven't done PHP in a while (why am I even in this tag?), But you should check out GDLib. iirc, it's better integrated than imagemagick.
http://php.net/manual/en/book.image.php
0
Oren mazor
source
to share