2013-12-08 3 views
4

결과 : http://i.stack.imgur.com/p1kVz.png추가 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

답변

1

귀하의 코드가 잘 작동 다른 PNG로 코드를하려고하면, 그것은 잘 작동 있기 때문에 (하지 워터 마크) 뭔가 이미지를 PNG 기본 잘못된 것 같습니다, 도트 JPG로, 그것은 또한 잘 작동합니다.

원래 PNG는 PNG32이기 때문에 PNG32로 변환하면 제대로 작동하기 때문인 것 같습니다.

+0

어떻게 PNG32 –

+0

FYI로 변환 할 수 있습니까?포토샵에서 32 비트 PNG를 만들라고하더라도 8 비트 PNG를 생성합니다. – Homer6

+0

imagick으로 가능합니다 $ im = new Imagick ($ image); $ im-> setImageDepth (32); $ im-> setImageFormat ('PNG32'); $ im-> writeImage ($ filename); –

0

워터 마크 이미지는 다음과 같은 권장 형식 중 하나에 있어야합니다 :

  • PNG-8 (권장)
  • 색상 : 256 이하
  • 투명성 : 온/오프

  • gif

  • 색상 : 25 6 이하
  • 투명성 : 온/오프

  • JPEG

  • 색상에 : 트루 컬러
  • 투명성 : N/A

imagecopymerge 기능이 제대로 PNG-을 처리하지 않습니다 24 이미지; 따라서 권장되지 않습니다.

파일 형식 : PNG-8,

을 비는 인터레이스를

당신은 워터 마크 이미지를 만들 어도비 포토샵을 사용하는 경우, 그것은 는 다음과 같은 설정 명령 "웹으로 저장"을 사용하는 것이 좋습니다

색상 줄이기 : 선택적, 256 색

디더링 : 확산, 88 %

투명성 : 매트,에 : 없음

투명 디더 : 확산 투명 디더, 100 %

+0

내가 방금 말한 것을 좋아했을 때, http://u1312.hizliresim.com/1j/8/vb7hn.png 지금은 –

0

당신이 시도 할 수 있습니다. 그것은 내 프로젝트에서 잘 작동합니다.

$stamp = imagecreatefrompng('watermark.png'); 
$im = imagecreatefrompng('source.png'); 

// Set the margins for the stamp and get the height/width of the stamp image 
$marge_right = 1; 
$marge_bottom = 1; 
$sx = imagesx($stamp); 
$sy = imagesy($stamp); 

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp)); 

// OUTPUT IMAGE: 
header("Content-Type: image/png"); 
imagesavealpha($im, true); 
imagepng($im, NULL);