Does php merge text on png images? RT needs to synthesize some text on a png image, but why is there a black background? The source image is, but the image I generated is the result of this browser. I need to combine some words in the blank space under the source image in the center. please help me! Does php merge text on png images?
RT
Some text needs to be synthesized on a png image, but why is there a black background?
SOURCE image is
However, the image I generated is like this.
Browser effect
I need to merge some words in the center in the blank space under the source image. please help me! Share:
------ Solution --------------------
Isn't all y coordinate 400 out of the image?
$ Url = 'http: // img.bbs.csdn.net/upload/201310/29/1383042869_349074.png ';
$ Im1 = imagecreatefrompng ($ url );
// These lines must exist. Otherwise, the shadow layer of the source image cannot pass.
$ Im2 = imagecreatetruecolor (imagesx ($ im1), imagesy ($ im1 ));
$ Bg = imagecolorallocate ($ im2, 255,255,255 );
Imagefill ($ im2, 0, 0, $ bg );
Imagecopy ($ im2, $ im1, 0, 0, 0, 0, imagesx ($ im1), imagesy ($ im1 ));
# Set the watermark font color
$ Color = imagecolorallocatealpha ($ im2, 0,100 );
# Set the font file path
$ Fontfile = "msyhbd. ttf ";
$ Fontfile = "c:/windows/fonts/FZJZJW. TTF ";
# Watermark text
$ Str = "We are all good children ";
$ Str = iconv ('gbk', 'utf-8', $ str );
# Watermarking
Imagettftext ($ im2, 20, 20, 20,100, $ color, $ fontfile, $ str );
Imagettftext ($ im2, 20, 20, 30,200, $ color, $ fontfile, $ str );
Imagettftext ($ im2, 20, 20, 40,300, $ color, $ fontfile, $ str );
Imagepng ($ im2 );