My webserver uses:

PHP Version 4.4.2
Zend Optimizer v2.5.10

gd
GD Support enabled
GD Version bundled (2.0.28 compatible)
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

I am simply tring to use imagecreatefromgif() to create a gif. I keep getting the following error:

Warning: imagecreatefromgif(): '/home/omnipcs/public_html/devel/example/components/com_mtree/img/listings/34_test.gif' is not a valid GIF file in /home/omnipcs/public_html/devel/example/components/com_example/includes/example.image.functions.php on line 36

The file is indeed where it should be, it exists, and is a gif that I JUST created in photoshop. I cannot seem to get around this error and I have found nothing on the web to help me.

Can anyone here shed any light onto why I am getting this error? This is how the function is being called:

$logo = imagecreatefromgif($image);

Image points to: /home/omnipcs/public_html/devel/example/components/com_mtree/img/listings/34_test.gif

Which like I said, exists and is in fact a gif.

    If u open a php manul u will notice a Note:

    Note:
    Since all GIF support was removed from the GD library in version 1.6, this function is not available if you are using that version of the GD library.

      GD Version bundled (2.0.28 compatible)

      i have also tested to see if gifs are supported, they are...

      not to mention the phpinfo output I displayed above

      thanks for your input though

        This is another example from php manual:

        Example to handle an error during creation (courtesy vic at zymsys dot com)
        
        function LoadGif ($imgname) { 
           $im = @imagecreatefromgif ($imgname); /* Attempt to open */ 
           if (!$im) { /* See if it failed */ 
               $im = imagecreate (150, 30); /* Create a blank image */ 
               $bgc = imagecolorallocate ($im, 255, 255, 255); 
               $tc = imagecolorallocate ($im, 0, 0, 0); 
               imagefilledrectangle ($im, 0, 0, 150, 30, $bgc); 
               /* Output an errmsg */ 
               imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc); 
           } 
           return $im; 
        } 

        I think u should try it ...

        And here is also a link: http://www.boutell.com/gd/

          ok, looking at the gd link and then following it to http://www.nyphp.org/content/presentations/GDintro/

          i came across using getImageSize to print out the images pertinent info. I am getting this:

          Array ( [0] => 220 [1] => 136 [2] => 2 [3] => width="220" height="136" [bits] => 8 [channels] => 3 [mime] => image/jpeg ) 

          for a gif. Note the mime setting. Why on earth would this happen? Could it be an improper server config?

            ok, here is the weirdness....

            obviously the mime-type of my gif is being altered upon upload and storage on the server. when I manually upload and run this code, all is well. when I upload from my browser, it breaks.

            Anyone have any insight?

              I figured it out. The 3pd application I was using makes painstaking efforts to check the input files yet regardless if they are gif, jpg, or png ends up writing them as jpg's.

              switch($imginfo[2]) {
              						case 'JPG':
              							$src_img = imagecreatefromjpeg($this->tmpFile);
              							break;
              
              					case 'PNG':
              						$src_img = imagecreatefrompng($this->tmpFile);
              						break;
              
              					case 'GIF':
              						$src_img = imagecreatefromgif($this->tmpFile);
              						break;
              				}
              
              				if (!$src_img){
              					$ERROR = $lang_errors['invalid_image'];
              					return false;
              				}
              				$dst_img = imagecreatetruecolor($destWidth, $destHeight);
              				imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
              
              				imagejpeg($dst_img, $this->directory.$this->imageName, $this->quality);

              awesome... good stuff, yay even

                Write a Reply...