이 스크립트로 내 minecraft 스킨의 크기를 조정하는 데 문제가 있습니다. localhost에서 테스트 할 때 모든 것이 100 % 정상적으로 작동하지만 내 서버에 업로드하면 콘텐츠가없는 크기가 조정 된 투명 이미지 만 표시됩니다.png의 크기 조정 문제
<?php
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
// File and new size
$fil = clean($_GET['skin']);
header('Content-type: image/png');
//$myimage = resizeImage('filename', 'newwidthmax', 'newheightmax');
function resizeImage($filename, $newwidth, $newheight){
list($width, $height) = getimagesize($filename);
$thumb = imagecreatetruecolor($newwidth, $newheight);
$transparent = imagecolorallocate($thumb, 200, 255, 200);
imagefill($thumb, 0, 0, $transparent);
imagecolortransparent($thumb, $transparent);
$source = imagecreatefrompng($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
return imagepng($thumb);
}
$myimage = resizeImage($fil, '640', '320');
print $myimage;
?>
당신은 여기에 출력을 볼 수는 : link
'resizeImage()'를 호출하면 실제로'$ fil'가 채워 집니까? 당신의'clean()'함수는'mysql_real_escape_string()'을 통해이 기능을 사용하는데, mysql 연결이 활성화되어 있지 않으면 실패합니다. 'error_reporting (E_ALL)'을 위에 올려 놓으면 E_WARNINGs가 출력 될 것입니다. – Fanis
로컬 호스트와 서버가 동일한 버전의 GD를 실행하고 있는지 확인하고, 더 중요한 것은'$ filename'을 읽을 수 있고'imagecreatefrompng()'가 성공한 것입니다. – Orbling