|
PHP:
$thumbsize = 150;
$imginfo = getimagesize($imgfile);
$width = $imginfo[0];
$height = $imginfo[1];
$imgratio = $width / $thumbsize;
$imgratio = max($imgratio, 1.0);
$newwidth = (int)($width / $imgratio);
$newheight = (int)($height / $imgratio);
$thumb = ImageCreateTrueColor($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, (int)$newheight, $width, $height);
imagejpeg($thumb,"../images/gallery/main/main_".$filename,100);
font>
: |
code:
function imageresize($path, $newwidth) {
list($width, $height) = @getimagesize($path);
$newheight = $height/($width/$newwidth);
$new = @imagecreatetruecolor($newwidth, $newheight);
$source = @imagecreatefromjpeg($path);
@imagecopyresized($new, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
@imagejpeg($new, $path);
}
code:
$imginfo = getimagesize($imgfile);
$width = $imginfo[0];
$height = $imginfo[1];
$cropStartX = round($width/2)-80;
$cropStartY = round($height/2)-60;
$cropW = 144;
$cropH = 119;
$origimg = imagecreatefromjpeg($imgfile);
$cropimg = imagecreatetruecolor($cropW,$cropH);
list($width, $height) = getimagesize($imgfile);
imagecopyresized($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width, $height);
imagejpeg($cropimg,"../images/gallery/main/main_".$filename,100);
imagedestroy($cropimg);
imagedestroy($origimg);