Original
Image may be NSFW.
Clik here to view.
GD2 thumbnail
Image may be NSFW.
Clik here to view.
Imagick thumbnail
Image may be NSFW.
Clik here to view.
<?php
//include('tmp/Timer.php');
function gd_thumbnail($filename, $width = 200, $height = 200) {
$source = imageCreateFromString(file_get_contents($filename));
$x = imageSX($source);
$y = imageSY($source);
if ($x > $y) { // landscape orientation
$height = intval($y/($x/$width));
} else { // square or portrait orientation
$width = intval($x/($y/$height));
}
$destination = ImageCreateTrueColor($width,$height);
imageCopyResampled($destination,$source,0,0,0,0,$width,$height,$x,$y);
imagejpeg($destination);
}
function im_thumbnail($filename, $width= 200, $height = 200) {
$image = new Imagick($filename);
$image->thumbnailImage($width, $height, TRUE);
echo $image;
}
header('Content-type: image/jpeg');
//$t = new Timer();
im_thumbnail('IMG_4449.JPG');
//echo $t;
?>