Strona 1 z 1

supplied argument is not a valid Image resource

PostNapisane: Pt lip 01, 11 16:27
przez matzmu
Witam , napisalem skrypt do minaturyzacji zdjec ,jednak wyskakują mi bledy:

imagesx(): supplied argument is not a valid Image resource
imagedestroy(): supplied argument is not a valid Image resource in

Jaki jest tego powód? Czy miał ktoś już podobny problem ??
Pozdrawiam !

Re: supplied argument is not a valid Image resource

PostNapisane: So lip 02, 11 10:24
przez wargo
Pokaż kod

Re: supplied argument is not a valid Image resource

PostNapisane: So lip 02, 11 11:45
przez matzmu
Kod: Zaznacz cały
function makeThumb($org_image, $dest_width = 0,$dest_height = 0){
   if($org_image == null)
         return false;
         
   if(preg_match('/\.gif$/i', $org_image )){
         $org_image = imagecreatefromgif($org_image);
   }else if( preg_match('/\.png$/i', $org_image )){
         $org_image = imagecreatefrompng($org_image);
   }else if(preg_match('/\.bmp$/i', $org_image )){
         $org_image = imagecreatefromwbmp($org_image);
   }else{
      $org_image = imagecreatefromjpeg($org_image);
   }
         
   $org_width = imagesx($org_image);
   $org_height = imagesy($org_image);

   if($dest_width > 0 && $dest_height > 0 ){
      if($dest_width >= $org_width && $dest_height >= $org_height ){
         return $org_image;         
      }   else {
         $dest_image = imagecreatetruecolor($dest_width, $dest_height);
      }
   }else if( ($dest_width > 0) && ($dest_height == 0) ){
         $many =  round(($org_width/$dest_width),1);   
         if($many > 1.0){
               $dest_width = round($org_width/$many);
               $dest_height  = round($org_height/$many);
         }else{
            $dest_width = $org_width;
            $dest_height = $org_height;         
         }
         $dest_image = imagecreatetruecolor($dest_width, $dest_height);   
   }else if(  ($dest_width == 0) && ($dest_height > 0) ){
         $many =  round(($org_height/$dest_height),1);   
         if($many > 1.0){
               $dest_width = round($org_width/$many);
               $dest_height  = round($org_height/$many);
         }else{
            $dest_width = $org_width;
            $dest_height = $org_height;
         }
         $dest_image = imagecreatetruecolor($dest_width, $dest_height);   
   }else{
         $dest_width = 100;
         $dest_height = 100;
         $dest_image = imagecreatetruecolor($dest_width, $dest_height);   
   }
   

   imagecopyresampled($dest_image, $org_image, 0, 0, 0, 0, $dest_width, $dest_height, $org_width ,$org_height );
   return $dest_image;
}





duzo If-ow ,bo chcialem miec funkcje 1 uniwersalna.
A i $org_image to najczesciej $_FILES['picture']['name'][$pic] zdjecie dopiero wczytane

Re: supplied argument is not a valid Image resource

PostNapisane: So lip 02, 11 21:21
przez wargo
Może tak:
Kod: Zaznacz cały
if(preg_match('/\.gif$/i'$org_image )){
         
$new_image imagecreatefromgif($org_image);
   }else if( 
preg_match('/\.png$/i'$org_image )){
         
$new_image imagecreatefrompng($org_image);
   }else if(
preg_match('/\.bmp$/i'$org_image )){
         
$new_image imagecreatefromwbmp($org_image);
   }else{
      
$new_image imagecreatefromjpeg($org_image);
   }
         
   
$org_width imagesx($new_image);
   
$org_height imagesy($new_image); 

Kod: Zaznacz cały
imagecopyresampled($dest_image$new_image0000$dest_width$dest_height$org_width ,$org_height ); 

Re: supplied argument is not a valid Image resource

PostNapisane: Pn lip 04, 11 11:38
przez matzmu
Nie to tez nie to ,tak jak wczesniej pisalem ,nie widzi mi metod imagesx() itp . Czy ugu ma bliboteke GD ??
BO wyglada jak by nie mial, chyba ze trzeba ją jakos zainstalowac

ps. na localhost kod działa
Pozdrawiam