Skip to content

Instantly share code, notes, and snippets.

@mgng
Created March 19, 2012 02:17
Show Gist options
  • Select an option

  • Save mgng/2090800 to your computer and use it in GitHub Desktop.

Select an option

Save mgng/2090800 to your computer and use it in GitHub Desktop.
PECL::Imagick で画像リサイズ処理する場合どれ使えばいいか
<?php
$a = isset($argv[1])? $argv[1] : exit;
if ( !preg_match('/^[arst]$/', $a) ) { exit; }
$w = 350;
$h = 234;
$i = new Imagick('sample.jpg');
$s = microtime(true);
switch ( $a ) {
case 'a': $i->adaptiveResizeImage($w, $h); break;
case 'r': $i->resizeImage($w, $h, Imagick::FILTER_POINT, 0); break;
case 's': $i->scaleImage($w, $h); break;
case 't': $i->thumbnailImage($w, $h); break;
default : break;
}
$e = microtime(true);
$i->writeImage("sample_thumb_{$a}.jpg");
$i->clear();
$i->destroy();
echo $e - $s, PHP_EOL;
$ php bench.php a
0.060811996459961
$ php bench.php r
0.095463991165161
$ php bench.php s
0.24654102325439
$ php bench.php t
0.25227499008179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment