How to resize jpg file by PHP?
It's now开发者_Go百科 925*1139,I want to change it to 90*110.
try the imagecopyresampled
PHP function or the imagecopyresized
function from the GD library.
Basically using GD is pretty easy 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);
Again check the blog for details.
here's a resizing class called SimpleImage that you can use. Or take a look at the source and see how they tackle the problem:
SimpleImage Code
I haven't done PHP in a while (why am I even in this tag?) but you should check out GDLib. iirc, its better integrated than imagemagick.
http://php.net/manual/en/book.image.php
精彩评论