Quantcast
Channel: bitPrison.net - Web development
Viewing all articles
Browse latest Browse all 23

PHP GD2 vs Imagick

$
0
0

Original

GD2 thumbnail

Imagick thumbnail

<?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;
?>

Viewing all articles
Browse latest Browse all 23

Trending Articles