1
假设我有一个宽度为1px,高度为40px的图片。 我想加载它让我们说imagecreatefrompng并希望x重复它,就像css repeat-x一样。如何使用php gd加载和重复图像?
PHP GD可以这样吗?
假设我有一个宽度为1px,高度为40px的图片。 我想加载它让我们说imagecreatefrompng并希望x重复它,就像css repeat-x一样。如何使用php gd加载和重复图像?
PHP GD可以这样吗?
您必须指定输出图像的宽度,我选择1024
证明:
$srcfile = 'bg.jpg';
$outfile = 'background.jpg';
list($src_w,$src_h,$src_type) = getimagesize($srcfile);
$out_w = 1024;
$out_h = $src_h;
$src = imagecreatefromjpeg($srcfile);
$out = imagecreatetruecolor($out_w, $out_h);
$curr_x = 0;
while($curr_x < $out_w){
imagecopy($out, $src, $curr_x, 0, 0, 0, $src_w, $src_h);
$curr_x += $src_w;
}
imagejpeg($out, $outfile, 100);
imagedestroy($src);
imagedestroy($out);
谢谢你的男人,真的帮了我.... – gadlol 2010-10-31 16:53:33