2010-10-30 58 views

回答

2

您必须指定输出图像的宽度,我选择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); 
+0

谢谢你的男人,真的帮了我.... – gadlol 2010-10-31 16:53:33