imagecratefrompng を実行しようとすると、PHP の gd ライブラリに問題が発生します。ユーザーがテキストを入力すると、事前に作成された画像に追加されるスクリプトを実行しています。問題は、画像を出力すると画像が壊れていることです。
私のスクリプト/画像に何か問題がある場合、誰かが指摘するのを助けることができますか?
画像は PNG、600x956、220kb のファイル サイズです。
GD ライブラリが有効になっています。PNG、JPEG、GIF のサポートが有効になっています。
これがコードです。
// Text inputed by user
$text = $_POST['text'];
// Postion of text inputed by the user
$text_x = 50;
$text_y = 817;
// Color of the text
$text_color = imagecolorallocate($img, 0, 0, 0);
// Name of the file (That is in the same directory of the PHP file)
$nomeDaImagem = "Example";
$img = imagecreatefrompng($nomeDaImagem);
//Text is retrieved by Post method
imagestring($img, 3, $text_x, $text_y, $text, $text_color);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);