Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2496

PostPosted: Fri Dec 10, 2004 12:03 pm Reply with quote

I know your not still using the infamously buggy My eGallery but if you wanted to with GD thumbnails and your server isn't as old as this addon.
Find in modules/My_eGallery/imageFunctions.php
replace function RatioResizeImgGD() with this one.
Code:


// GD Library
function RatioResizeImgGD($src_file, $dest_file, $newWidth) {
   global
      $gallerypath
   ;
   // find the image size & type
   if(!function_exists('imagecreate')){return $src_file;}

   $imginfo = @getimagesize($src_file);
   switch($imginfo[2]) {
      case 1: $type = IMG_GIF; break;
      case 2: $type = IMG_JPG; break;
      case 3: $type = IMG_PNG; break;
      case 4: $type = IMG_WBMP; break;
      default: return $src_file; break;
   }
   
   switch($type) {
      case IMG_GIF:
         if(!function_exists('imagecreatefromgif')){return $src_file;}
         $srcImage = @imagecreatefromgif("$src_file");
         break;
      case IMG_JPG:
         if(!function_exists('imagecreatefromjpeg')){return $src_file;}
         $srcImage = @ImageCreateFromJpeg($src_file);
         break;
      case IMG_PNG:
         if(!function_exists('imagecreatefrompng')){return $src_file;}
         $srcImage = @imagecreatefrompng("$src_file");
         break;
      case IMG_WBMP:
         if(!function_exists('imagecreatefromwbmp')){return $src_file;}
         $srcImage = @imagecreatefromwbmp("$src_file");
         break;
      default: return $src_file;
   }
   
   if($srcImage){
      // height/width
      $srcWidth = $imginfo[0];
      $srcHeight = $imginfo[1];
      $ratioWidth = $srcWidth/$newWidth;
      $destWidth = $newWidth;
      $destHeight = $srcHeight / $ratioWidth;
      // resize
      $destImage = @imagecreatetruecolor($destWidth, $destHeight);
                if (function_exists("imagecopyresampled")) {
                imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth,(int)$destHeight, $srcWidth, $srcHeight);
                }else{
                  imagecopyresized($destImage, $srcImage, 0, 0, 0, 0, $destWidth,(int)$destHeight, $srcWidth, $srcHeight);
                }
      // create and save final picture
      
      switch($type){
         case IMG_GIF: @imagegif($destImage, "$dest_file", 100); break;
         case IMG_JPG: @imagejpeg($destImage, "$dest_file", 100); break;
         case IMG_PNG: @imagepng($destImage, "$dest_file", 100); break;
         case IMG_WBMP: @imagewbmp($destImage, "$dest_file", 100); break;
      }

      // free the memory
      @imagedestroy($srcImage);
      @imagedestroy($destImage);

      return $dest_file;
   }
   else
   {
      return $src_file;
   }
}

_________________
[b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©