이것은 제가 작업중인 thumnbail 스크립트이며 손상된 33 바이트 이미지를 생성합니다. 문제는 ifif_imagetype if 문에 있다고 생각하지만 확실하지 않습니다. 나는 어떤 도움을 주셔서 감사합니다.PHP가 손상된 thumnbail을 만듭니다
// Original image
$filename = 'images/T' . $neutralName;
// Get dimensions of the original image
list($current_width, $current_height) = getimagesize($filename);
// The x and y coordinates on the original image where we
// will begin cropping the image
$left = 10;
$top = 5;
// This will be the final size of the image (e.g. how many pixels
// left and down we will be going)
$crop_width = 140;
$crop_height = 100;
// Resample the image
$canvas = imagecreatetruecolor($crop_width, $crop_height);
if ((exif_imagetype($_FILES['photo']['tmp_name'])) == IMAGETYPE_JPEG) {
$current_image = imagecreatefromjpeg($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagejpeg($canvas, $filename, 100);
} else if ((exif_imagetype($_FILES["photo"]['tmp_name'])) == IMAGETYPE_GIF) {
$current_image = imagecreatefromgif($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagegif($canvas, $filename, 100);
} else {
$current_image = imagecreatefrompng($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagepng($canvas, $filename, 100);
}
더 많은 코드가 있습니까? 그 성명서 뒤에 $ 캔버스로 무엇을하고 있습니까? – mikevoermans
이미지의 내부 내용은 무엇입니까? 어쩌면 그것은 33 심볼의 오류 메시지입니까? –
모든 코드가 바로 거기에 있습니다. 캔버스가 if 문 바로 위에 정의되어 있습니다. 그리고 그래, 나는 33 가지의 오류가 있다고 믿는다. 어떤 그림이 PNG인지 계속 생각하므로 JPG 일지라도 첫 번째 및 두 번째 테스트가 실패한 것입니다. – Ramin