diff options
author | Mario <mario@mariovavti.com> | 2020-11-05 08:46:42 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-11-05 08:46:42 +0000 |
commit | bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6 (patch) | |
tree | 8929845be585b09d0f420621281c5531e1efad3e /Zotlabs/Photo/PhotoGd.php | |
parent | 6f93d9848c43019d43ea76c27d42d657ba031cd7 (diff) | |
parent | fdefa101d84dc2a9424eaedbdb003a4c30ec5d01 (diff) | |
download | volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.gz volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.bz2 volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.zip |
Merge branch '5.0RC'5.0
Diffstat (limited to 'Zotlabs/Photo/PhotoGd.php')
-rw-r--r-- | Zotlabs/Photo/PhotoGd.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Zotlabs/Photo/PhotoGd.php b/Zotlabs/Photo/PhotoGd.php index 4054e1866..c54fa6a7d 100644 --- a/Zotlabs/Photo/PhotoGd.php +++ b/Zotlabs/Photo/PhotoGd.php @@ -13,12 +13,16 @@ class PhotoGd extends PhotoDriver { * @see \Zotlabs\Photo\PhotoDriver::supportedTypes() */ public function supportedTypes() { + $t = []; + $t['image/jpeg'] = 'jpg'; if(imagetypes() & IMG_PNG) $t['image/png'] = 'png'; if(imagetypes() & IMG_GIF) $t['image/gif'] = 'gif'; + if(imagetypes() & IMG_WEBP) + $t['image/webp'] = 'webp'; return $t; } @@ -142,6 +146,7 @@ class PhotoGd extends PhotoDriver { * @see \Zotlabs\Photo\PhotoDriver::imageString() */ public function imageString() { + if(! $this->is_valid()) return false; @@ -150,23 +155,32 @@ class PhotoGd extends PhotoDriver { ob_start(); switch($this->getType()){ + case 'image/png': $quality = get_config('system', 'png_quality'); if((! $quality) || ($quality > 9)) $quality = PNG_QUALITY; - \imagepng($this->image, NULL, $quality); break; + + case 'image/webp': + $quality = get_config('system', 'webp_quality'); + if((! $quality) || ($quality > 100)) + $quality = WEBP_QUALITY; + \imagewebp($this->image, NULL, $quality); + break; + case 'image/jpeg': // gd can lack imagejpeg(), but we verify during installation it is available + default: $quality = get_config('system', 'jpeg_quality'); if((! $quality) || ($quality > 100)) $quality = JPEG_QUALITY; - \imagejpeg($this->image, NULL, $quality); break; } + $string = ob_get_contents(); ob_end_clean(); |