[geeklog-cvs] geeklog-1.3/system/classes upload.class.php,1.36,1.37

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Tue Oct 12 05:41:13 EDT 2004


Update of /var/cvs/geeklog-1.3/system/classes
In directory www:/tmp/cvs-serv14746/system/classes

Modified Files:
	upload.class.php 
Log Message:
Dropped the on-the-fly conversion from GIF to PNG when using GDLIB.


Index: upload.class.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/classes/upload.class.php,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** upload.class.php	11 Oct 2004 18:30:25 -0000	1.36
--- upload.class.php	12 Oct 2004 09:41:11 -0000	1.37
***************
*** 584,629 ****
                            . $this->_getDestinationName();
  
-                 // Detect filetype
-                 if ($this->_currentFile['type'] == 'image/gif') {
-                     if (!function_exists ('imagecreatefromgif')) {
-                         $this->_addError ('Sorry, this version of the GD library does not support GIF images.');
-                         $this->printErrors ();
-                         exit;
-                     }
-                     // If file is GIF do a quick PNG conversion first
-                     $this->_addDebugMsg ('converting GIF to PNG');
-                     $image_size = getimagesize ($filename);
-                     $image_source = imagecreatefromgif ($filename);
-                     $image_dest = imagecreatetruecolor ($image_size[0],
-                                                         $image_size[1]);
-                     imagecopy ($image_dest, $image_source, 0, 0, 0, 0,
-                                $image_size[0], $image_size[1]);
-                     $png_filename = $this->_fileUploadDirectory . '/'
-                                   . eregi_replace ("\.gif", ".png",
-                                     $this->_getDestinationName ());
-                     if (!imagepng ($image_dest, $png_filename)) {
-                         $this->_addError ('Error creating PNG from GIF: '
-                                           . $png_filename);
-                         $this->printErrors ();
-                         exit;
-                     } else {
-                         // GIF converted to PNG, delete original file
-                         $this->_addDebugMsg ('Deleting GIF: ' . $filename);
-                         if (!unlink ($filename)) {
-                             $this->_addError ('Unable to delete original GIF: '
-                                               . $filename);
-                             $this->printErrors ();
-                             exit;
-                         }
-                     }
-                     // change file type to PNG
-                     $this->_currentFile['type'] = 'image/png';
- 
-                     // change file name to .png
-                     $filename = $this->_fileUploadDirectory . '/'
-                               . eregi_replace ("\.gif", ".png",
-                                 $this->_getDestinationName ());
-                 }
- 
                  if (!$this->_keepOriginalFile ($filename)) {
                      exit;
--- 584,587 ----
***************
*** 656,659 ****
--- 614,629 ----
                          exit;
                      }
+                 } elseif ($this->_currentFile['type'] == 'image/gif') {
+                     if (!function_exists ('imagecreatefromgif')) {
+                         $this->_addError ('Sorry, this version of the GD library does not support GIF images.');
+                         $this->printErrors ();
+                         exit;
+                     }
+                     if (!$image_source = imagecreatefromgif ($filename)) {
+                         $this->_addError ('Could not create image from GIF: '
+                                           . $filename);
+                         $this->printErrors ();
+                         exit;
+                     }
                  } else {
                      $this->_addError ('MIME type ' . $this->_currentFile['type']
***************
*** 688,691 ****
--- 658,667 ----
                          exit;
                      }
+                 } elseif ($this->_currentFile['type'] == 'image/gif') {
+                     if (!imagegif ($image_dest, $filename)) {
+                         $this->_addError ('Could not create GIF: ' . $filename);
+                         $this->printErrors ();
+                         exit;
+                     }
                  }
              }




More information about the geeklog-cvs mailing list