結果:http://i.stack.imgur.com/p1kVz.png添加PNG水印PNG圖片PHP
我試圖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
如何將其轉換爲PNG32 –
僅供參考...在Photoshop中,即使你說要創建一個32位PNG,它仍然會生成一個8位PNG – Homer6
這可能與imagick $ im = new Imagick($ image); $ im-> setImageDepth(32); $ im-> setImageFormat('PNG32'); $ im-> writeImage($ filename); –