X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FImage.php;h=4645a8678a59fd1e330614315a364dfb01005a07;hb=d936cc5a5c2755a0056ff12a297bf0fa25dc6bf1;hp=b69682ca6140bf301572ebf1cade688a4a49b66c;hpb=ee8689cc899beecaf0943ac175550a7fb49cf199;p=friendica.git diff --git a/src/Object/Image.php b/src/Object/Image.php index b69682ca61..4645a8678a 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -22,7 +22,6 @@ namespace Friendica\Object; use Exception; -use Friendica\Core\System; use Friendica\DI; use Friendica\Util\Images; use Imagick; @@ -123,7 +122,11 @@ class Image $this->image->setFormat($format); // Always coalesce, if it is not a multi-frame image it won't hurt anyway - $this->image = $this->image->coalesceImages(); + try { + $this->image = $this->image->coalesceImages(); + } catch (Exception $e) { + return false; + } /* * setup the compression here, so we'll do it only once @@ -538,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 @@ -567,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