3
<?php

header('Content-type:image/gif');
header('Content-Disposition: attachment; filename="animated.gif"');

require_once('GIFEncoder.class.php');

$image = imagecreatefrompng('source01.png');

$width = 50;
$height = 50;
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, 200, 115); 

$text_color = imagecolorallocate($image, 50, 50, 50);
imagestring($image, 5, 5, 5,  '', $text_color);

/* $imageMagick = new Imagick($image);
$imageMagick->adaptiveResizeImage(50,50); */

ob_start();
imagegif($image);
$frames[]=ob_get_contents();
$framed[]=40; 
ob_end_clean();


$gif = new GIFEncoder($frames,$framed,0,2,0,0,0,'bin');
echo $gif->GetAnimation();

//$fp = fopen('animegif.gif', 'w');
//fwrite($fp, $gif->GetAnimation());
//fclose($fp);

?>

コードで .png 画像のサイズを静的な 50x50px 値に変更する方法はありますか? ありがとう

4

2 に答える 2

4

imagecopyresampledを使用します

次のように使用できます。

$width = 50;
$height = 50;
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $image.getWidth)=(), $image.getHeight());
于 2012-04-21T21:34:15.147 に答える
0

そのためにimagemagicを使用できます

http://www.php.net/manual/en/imagick.resizeimage.php

http://www.php.net/manual/en/imagick.adaptiveresizeimage.php

于 2012-04-21T21:35:16.810 に答える