header("image/jpeg");
$image = imagecreatefromjpeg($_GET[img]);
$result = imagecreate(100,75);
$fg = imagecolorallocate($result,255,255,255);
imagefilledrectangle($result,0,0,100,75,$fg);
$w = imagesx($image);
$h = imagesy($image);
$wscale = 100 / $w;
$hscale = 75 / $h;
if ($wscale < $hscale) {
$xresult = 100;
$yresult = $h * $wscale;
$xoffset = 0;
$yoffset = (75 - $yresult)/2;
} else {
$yresult = 75;
$xresult = $w * $hscale;
$xoffset = (100 - $xresult) / 2;
$yoffset = 0;
}
ImageCopyresized($result,$image,$xoffset,$yoffset,0,0,$xresult,$yresult,$w,$h);
imagejpeg ($result);
(http://www.wellho.net)
Bury
< / ?php
header("image/jpeg");
$image = imagecreatefromjpeg($_GET[img]);
$result = imagecreate(100,75);
$fg = imagecolorallocate($result,255,255,255);
imagefilledrectangle($result,0,0,100,75,$fg);
$w = imagesx($image);
$h = imagesy($image);
$wscale = 100 / $w;
$hscale = 75 / $h;
// Following reduces image size to maintain aspect ratio
// Switch < to > to provide cropped thumbnails
// Just use simple constants to let aspect ratio change and distort images
if ($wscale < $hscale) {
$xresult = 100;
$yresult = $h * $wscale;
$xoffset = 0;
$yoffset = (75 - $yresult)/2;
} else {
$yresult = 75;
$xresult = $w * $hscale;
$xoffset = (100 - $xresult) / 2;
$yoffset = 0;
}
ImageCopyresized($result,$image,$xoffset,$yoffset,0,0,$xresult,$yresult,$w,$h);
imagejpeg ($result);
? / >