结果:
http://i.stack.imgur.com/p1kVz.png
我正在尝试将PNG复制到另一个PNG,但我不知道为什么他们这样返回
<?php // File and new size
$filename = 'watermark.png';
// Get new sizes
list($width, $height) = getimagesize($filename);
// Load
$resim = 'http://www.petrominpng.com.pg/images/logo_big.png';
$ext = end(explode('.', $resim));
if($ext == "jpeg" || $ext == "jpg")
{
$thumb = imagecreatefromjpeg($resim);
}
else if($ext == "png")
{
$thumb = imagecreatefrompng($resim);
}
$sx = imagesx($thumb);
$sy = imagesy($thumb);
if($sx >= $sy)
{
$sxd = $sx/2;
$degisim = $sxd/$width;
/*
echo $sxd." ".$width." ";
echo $sxd-$width." |";
*/
$sxy = $height * $degisim;
/*
echo " $sxy $height | $degisim";
exit();
*/
}
else
{
$sxy = $sy/2;
$degisim = $sxy/$height;
/*
echo $sxd." ".$width." ";
echo $sxd-$width." |";
*/
$sxd = $width * $degisim;
/*
echo " $sxy $height | $degisim";
exit();
*/
}
$source = imagecreatefrompng($filename);
// Resize
imagecopyresized($thumb, $source, $sx/5, $sy/4, 0, 0, $sxd, $sxy, $width, $height);
// Output
header('Content-type: image/png');
imagepng($thumb);
imagedestroy($thumb);
?>
你可以看到,我有图像问题我怎么能做对吗?
我的水印
http://i.stack.imgur.com/TZFCa.png
最佳答案 您的代码工作正常,基本PNG图像(而不是水印)似乎有问题,因为如果您尝试使用另一个png的代码,它可以正常工作,使用jpg,它也可以正常工作.
这似乎是因为原始的PNG是PNG8,因为当转换为PNG32时它工作正常.