이미지가 브라우저에 잘로드되지만 이미지 위에 텍스트를 쓰려고하면 이미지가 깨집니다 (예 : http://www.tradenepal.com.np/test.php). imagettftext()를 주석 처리하면 이미지가 다시로드되지 않습니다. 내 localhost에서 이런 일이 일어나고 WampServer 버전 2.5를 사용합니다. inetrnet에 대한 많은 의견을 들었지만 문제가 무엇인지 알 수 없습니다. 어떤 도움을 주시면 감사하겠습니다. 고맙습니다. 내 코드 :PHP imagettftext()가 imagecreatefrompng, imagecreatefromjpeg 및 imagecreatefromgif를 사용하면 이미지가 깨집니다.
<?php
//Set content type
header('Content-type: image/jpeg');
// Create image from existing image
$jpgImage = imagecreatefromjpeg('file.jpg');
// Allocate color for text
$white = imagecolorallocate($jpgImage, 255, 255, 255);
// Set Path to Font File
$font = 'arialbd.ttf';
// Text to print to image
$text = 'Testing text output';
// Print Text On Image
imagettftext($jpgImage, 75, 0, 50, 400, $white, $font, $text);
// Send Image to Browser
imagejpeg($jpgImage);
// Clear Memory
imagedestroy($jpgImage);
?>
먼저 이미지를 배치하여 테스트를 배치 할만큼 충분히 큰지 확인하십시오. 두 번째로'arialbd.ttf' 파일이 지정한 위치에 정확히 위치하는지 확인하십시오. – RiggsFolly
감사합니다. RiggsFolly, 나는 질문을 한 후에 나중에 알아 냈습니다. – HazardPJ