2013-04-21 1 views
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'); } 

답변

2

GD는 당신이 등, 당신은 경고를 supress하고 다음과의 메리 길을 계속하도록 할 수 있습니다 열 때 이론적으로 파일이 잘 작동하지만, 조금 떨어져있는 사진과에 대한 용서가 될 수 있습니다

ini_set("gd.jpeg_ignore_warning", 1); 

이렇게하면 처리가 계속되고 경고는 무시됩니다. 이미지가 문제없이 계속 처리 될 가능성이 높습니다.

+0

솔루션을 사용해 주셔서 감사 드리며 수정 한 내용에서 볼 수 있듯이 추가했지만 여전히 작동하지 않았습니다. 오류는'$ image = imagecreatefromjpeg ...'줄에서 기인한다고 나는 거의 긍정적이다. 작동시키기 위해 사용할 수있는 대체품이 있습니까? – user2127833

+0

유일한 제안은 호스트가'jpglib' 패키지를 업그레이드 할 수 있는지 확인하는 것입니다. – duellsy

+0

특정 사진과 관련된 것이 있었지만 사진을 삭제하면 효과가있었습니다. – user2127833

관련 문제