2009-04-03 6 views
2

PNG에 텍스트를 넣고 JPG/GIF 이미지를 병합하는 방법이 있습니까?텍스트와 이미지를 병합

+0

질문을 좀 더 자세하게 설명해 주실 수 있습니까? jpg/gif 이미지와 함께 병합 PNG로 무엇을 의미합니까? – Alekc

답변

1

내가 어떻게하는지.

/* load the image */ 
$im = imagecreatefrompng("image.png"); 

/* black for the text */ 
$black = imagecolorallocate($im, 0, 0, 0); 

/* put the text on the image */ 
imagettftext($im, 12, 0, 0, 0, $black, "arial.ttf", "Hello World"); 

/* load the jpg */ 
$jpeg = imagecreatefromjpeg("image.jpeg"); 

/* put the png onto the jpeg */ 
/* you can get the height and width with getimagesize() */ 
imagecopyresampled($jpeg,$im, 0, 0, 0, 0, $jpeg_width, $jpeg_height, $im_width, $im_height); 

/* save the image */ 
imagejpeg($jpeg, "result.jpeg", 100); 

이것은 매우 간단한 예입니다.

관련 문제