1
我想重新大小的照片在PHP中的,而循環,但我不斷收到類似的錯誤:錯誤試圖重新大小的圖像時
Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in C:\Users\Bob\xampp\htdocs\house\allphotos.php on line 17
Warning: imagecreatefromjpeg(): 'userphotos/27_1366493160164_BMW.jpg' is not a valid JPEG file in C:\Users\Bob\xampp\htdocs\house\allphotos.php on line 17
Warning: imagecopyresized() expects parameter 2 to be resource, boolean given in C:\Users\Bob\xampp\htdocs\house\allphotos.php on line 27
然後一噸的隨機字符...
在下面,我試圖回顯出2張照片用新的尺寸選擇。 我認爲這與$image
有關,我沒有使用該功能嗎?
ini_set("gd.jpeg_ignore_warning", 1); //just added
if ($getphotos->execute()){
while ($array = $getphotos->fetch(PDO::FETCH_ASSOC)){
$image = imagecreatefromjpeg('userphotos/'.$array['photoname'].'');
list($image_width, $image_height, $type, $attr) = getimagesize('userphotos/'.$array['photoname'].'');
$new_size = ($image_width + $image_height)/($image_width*($image_height/100));
$new_width = $image_width * $new_size;
$new_height = $image_height * $new_size;
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height);
$imagearray = imagejpeg($new_image, null);
echo $imagearray;
//echo '<img src="userphotos/'.$array['photoname'].'">';
}
} else { die('Query Error'); }
好的感謝您的解決方案,我剛剛添加它,你可以看到我的編輯,但它仍然無法正常工作。我幾乎肯定錯誤來自'$ image = imagecreatefromjpeg ...'行。是否有某種類型的替代品可以用來使其發揮作用? – user2127833 2013-04-21 03:45:38
唯一的其他建議是查看你的主機是否可以升級'jpglib'軟件包 – duellsy 2013-04-21 03:51:14
原來這與特定照片有關,我刪除了照片並且工作正常。 – user2127833 2013-04-21 18:34:43