2011-05-04 6 views
0

이 스크립트로 내 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

+0

'resizeImage()'를 호출하면 실제로'$ fil'가 채워 집니까? 당신의'clean()'함수는'mysql_real_escape_string()'을 통해이 기능을 사용하는데, mysql 연결이 활성화되어 있지 않으면 실패합니다. 'error_reporting (E_ALL)'을 위에 올려 놓으면 E_WARNINGs가 출력 될 것입니다. – Fanis

+0

로컬 호스트와 서버가 동일한 버전의 GD를 실행하고 있는지 확인하고, 더 중요한 것은'$ filename'을 읽을 수 있고'imagecreatefrompng()'가 성공한 것입니다. – Orbling

답변

0

는 mysql_real_escape_string는 MySQL의에 이미 열려있는 연결이 필요합니다 여기 스크립트입니다. 마지막으로 열었던 연결을 사용합니다. 존재하지 않으면 false를 반환합니다. 아마도 이것이 당신이 누락 된 데이터 일 것입니다.

+0

기능을 제거하려고했지만 작동하지 않았습니다. 또한 스크립트 상단의 데이터베이스에 연결하려고 시도했지만 작동하지 않았습니다. S – Tomas