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