diff options
author | zotlabs <mike@macgirvin.com> | 2020-01-14 13:34:56 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2020-01-14 13:34:56 -0800 |
commit | 293d411efb28b8f20a0208e3c52883e9fbb8cea7 (patch) | |
tree | a8b0af66015815d56342daf8301ab5ae095eda0a /Zotlabs/Photo/PhotoImagick.php | |
parent | 2a287e6def5ab54037222c963ab0875faf62fc1a (diff) | |
parent | d96f4340e80207a29a5c1c49cae8c25e3934d5ae (diff) | |
download | volse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.tar.gz volse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.tar.bz2 volse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'Zotlabs/Photo/PhotoImagick.php')
-rw-r--r-- | Zotlabs/Photo/PhotoImagick.php | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/Zotlabs/Photo/PhotoImagick.php b/Zotlabs/Photo/PhotoImagick.php index a7026e8ca..0a08d19e6 100644 --- a/Zotlabs/Photo/PhotoImagick.php +++ b/Zotlabs/Photo/PhotoImagick.php @@ -8,19 +8,16 @@ namespace Zotlabs\Photo; class PhotoImagick extends PhotoDriver { public function supportedTypes() { - return [ + + $ret = [ 'image/jpeg' => 'jpg', 'image/png' => 'png', - 'image/gif' => 'gif', + 'image/gif' => 'gif' ]; - } + if(\Imagick::queryFormats("WEBP")) + $ret['image/webp'] = 'webp'; - private function get_FormatsMap() { - return [ - 'image/jpeg' => 'JPG', - 'image/png' => 'PNG', - 'image/gif' => 'GIF', - ]; + return $ret; } @@ -42,8 +39,8 @@ class PhotoImagick extends PhotoDriver { * Setup the image to the format it will be saved to */ - $map = $this->get_FormatsMap(); - $format = $map[$type]; + $map = $this->supportedTypes(); + $format = strtoupper($map[$type]); if($this->image) { $this->image->setFormat($format); @@ -58,6 +55,7 @@ class PhotoImagick extends PhotoDriver { * setup the compression here, so we'll do it only once */ switch($this->getType()) { + case 'image/png': $quality = get_config('system', 'png_quality'); if((! $quality) || ($quality > 9)) @@ -73,11 +71,21 @@ class PhotoImagick extends PhotoDriver { $quality = $quality * 10; $this->image->setCompressionQuality($quality); break; + case 'image/jpeg': $quality = get_config('system', 'jpeg_quality'); if((! $quality) || ($quality > 100)) $quality = JPEG_QUALITY; $this->image->setCompressionQuality($quality); + break; + + case 'image/webp': + $quality = get_config('system', 'webp_quality'); + if((! $quality) || ($quality > 100)) + $quality = WEBP_QUALITY; + $this->image->setCompressionQuality($quality); + break; + default: break; } |