문제

현재 데이터베이스에서 이미지 내용을 가져 오는 스크립트가 있고 CreateImageFromString ()을 사용하여 디스플레이를 위해 크기가 크기가 크기 (리 샘플) 이미지를 반환합니다.

$max_width = 170;

// Get the image

@mysql_connect('host', 'user', 'pass');
@mysql_select_db('db');

$query = "SELECT `thumbnail_contents`, `thumbnail_mimetype` FROM `videos` WHERE video_number  = '$video_number'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_object($result);

// Resize if pic bigger than $max_width
// Set the header
header('Content-type:' . $row->thumbnail_mimetype);

// Get original size of image
$image = imagecreatefromstring($row->thumbnail_contents);
$current_width = imagesx($image);
$current_height = imagesy($image);

// Set thumbnail width
$widths = array($current_width, $max_width);
$new_width = min($widths);

// Calculate thumbnail height from given width to maintain ratio
$new_height = $current_height / $current_width*$new_width;

// Create new image using thumbnail sizes
$thumb = imagecreatetruecolor($new_width,$new_height);

// Copy original image to thumbnail
imagecopyresampled($thumb,$image,0,0,0,0,$new_width,$new_height,imagesx($image),imagesy($image));

// Show thumbnail on screen
$show = imagejpeg($thumb);

// Clean memory
imagedestroy($image);
imagedestroy($thumb);

현재이 스크립트는 대부분의 축소판에 대해 작동하며 원하는대로 화면에 표시합니다. 그러나 1000px가 넘는 폭이 높은 이미지를 업로드하면 데이터베이스에 저장되지만 스크립트에는 리 샘플링 이미지가 표시되지 않습니다.

문제를 해결하기 위해 DB를 확인했으며 쿼리에서 출력을 인쇄 _r '했습니다. 모든 것이 정리 한 것 같습니다 ... 누군가 그런 행동을 일으킬 수있는 이유를 말해 줄 수 있습니까? 모든 도움이나지도에 감사드립니다!

도움이 되었습니까?

해결책

$ 5에 따르면 PHP는 메모리가 부족하다고 말합니다. PHP 오류 로그를 확인하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top