2011-07-01, 03:51:55
cyklades Wrote:Alienate, can you show us new updated code? ( pic.php with crop function)
starting from line 30...
Code:
$dwidth = 150; // width I want to use
$dheight = 100; // height I want to use
$width = imagesx($src);
$height = imagesy($src);
$ratiowidth = $width / $dwidth;
$ratioheight = $height / $dheight;
$cx = 0;
$cy = 0;
if($ratioheight < $ratiowidth) {
$tempwidth = $width;
$width = $dwidth * $ratioheight;
$cx = ($tempwidth - $width) / 2;
}
if($ratiowidth < $ratioheight) {
$tempheight = $height;
$height = $dheight * $ratiowidth;
$cy = ($tempheight - $height) / 2;
}
$dst = imagecreatetruecolor($dwidth, $dheight);
imagecopyresampled($dst, $src, 0, 0, $cx, $cy, $dwidth, $dheight, $width, $height);
there's no control on maxWidth and maxHeight, which I don't use