png にテキストを配置し、それを jpg/gif 画像とマージする方法はありますか?
6421 次
3 に答える
3
ttf または type1 フォントを使用して gd で画像内または画像上に任意のテキストを描画できます (php の gd で有効になっている場合)。
于 2009-04-03T08:08:07.110 に答える
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);
これはかなり単純な例ですが。
于 2009-04-03T09:20:13.083 に答える
0
使用している言語はわかりませんが、Imagemagickにはいくつかの異なる言語の API があります ( http://www.imagemagick.org/script/api.php )。
于 2009-04-03T08:16:48.213 に答える