]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Image.php
Merge pull request #10086 from nupplaphil/feat/install_testrewrite
[friendica.git] / src / Object / Image.php
index d69b01ad4d9e016180cca7916f2d4178116b2565..4645a8678a59fd1e330614315a364dfb01005a07 100644 (file)
@@ -541,7 +541,12 @@ class Image
                        do {
                                // FIXME - implement horizontal bias for scaling as in following GD functions
                                // to allow very tall images to be constrained only horizontally.
-                               $this->image->scaleImage($dest_width, $dest_height);
+                               try {
+                                       $this->image->scaleImage($dest_width, $dest_height);
+                               } catch (Exception $e) {
+                                       // Imagick couldn't use the data
+                                       return false;
+                               }
                        } while ($this->image->nextImage());
 
                        // These may not be necessary anymore
@@ -570,6 +575,21 @@ class Image
                return true;
        }
 
+       /**
+        * Convert a GIF to a PNG to make it static
+        */
+       public function toStatic()
+       {
+               if ($this->type != 'image/gif') {
+                       return;
+               }
+
+               if ($this->isImagick()) {
+                       $this->type == 'image/png';
+                       $this->image->setFormat('png');
+               }
+       }
+
        /**
         * @param integer $max maximum
         * @param integer $x   x coordinate