Created
May 31, 2010 08:20
-
-
Save mgng/419651 to your computer and use it in GitHub Desktop.
透過pngのリサイズ(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 | |
/** | |
* @param string $in | |
* @param string $out | |
* @param int $per | |
*/ | |
function resizePng($in, $out, $per) { | |
$size = getimagesize($in); | |
if ($size === false || $size['mime'] !== 'image/png') { | |
return false; | |
} | |
$w = $size[0]; | |
$h = $size[1]; | |
$nw = floor($w*$per/100); | |
$nh = floor($h*$per/100); | |
$image = new Imagick(); | |
$image->readImage($in); | |
$image->setImageFileName($out); | |
$image->resizeImage($nw, $nh, imagick::FILTER_SINC, 1); | |
$image->writeImage(); | |
return true; | |
} | |
resizePng('test1.png', 'test1_imagick_resize.png', 50); | |
resizePng('test2.png', 'test2_imagick_resize.png', 50); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment