supplied argument is not a valid Image resource

Problemy związane ze stronami PHP

supplied argument is not a valid Image resource

Postprzez matzmu » Pt lip 01, 11 16:27

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 !
matzmu
 
Posty: 3
Dołączył(a): Pt lip 01, 11 16:24

Re: supplied argument is not a valid Image resource

Postprzez wargo » So lip 02, 11 10:24

Pokaż kod
wargo
 
Posty: 1353
Dołączył(a): Cz lip 05, 07 16:59
Lokalizacja: Pleszew

Re: supplied argument is not a valid Image resource

Postprzez matzmu » So lip 02, 11 11:45

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
matzmu
 
Posty: 3
Dołączył(a): Pt lip 01, 11 16:24

Re: supplied argument is not a valid Image resource

Postprzez wargo » So lip 02, 11 21:21

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 ); 
wargo
 
Posty: 1353
Dołączył(a): Cz lip 05, 07 16:59
Lokalizacja: Pleszew

Re: supplied argument is not a valid Image resource

Postprzez matzmu » Pn lip 04, 11 11:38

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
matzmu
 
Posty: 3
Dołączył(a): Pt lip 01, 11 16:24


Powrót do PHP

Copyright © 2007-2011 ugu.pl
Wszelkie prawa zastrzeżone.
Polityka prywatności

cron