Created
March 19, 2012 02:17
-
-
Save mgng/2090800 to your computer and use it in GitHub Desktop.
PECL::Imagick で画像リサイズ処理する場合どれ使えばいいか
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 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