aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Photo/PhotoGd.php
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-12-07 20:14:17 +0100
committerMario <mario@mariovavti.com>2019-12-07 20:14:17 +0100
commitaed682305173a67b2af1a56b8595445bec690e2b (patch)
treea022f3769332331a9c30f4b96a81a6b854690767 /Zotlabs/Photo/PhotoGd.php
parent96f9e515466b749d1e1640aad3fd25bc19399f1a (diff)
downloadvolse-hubzilla-aed682305173a67b2af1a56b8595445bec690e2b.tar.gz
volse-hubzilla-aed682305173a67b2af1a56b8595445bec690e2b.tar.bz2
volse-hubzilla-aed682305173a67b2af1a56b8595445bec690e2b.zip
Add .webp image format support
Diffstat (limited to 'Zotlabs/Photo/PhotoGd.php')
-rw-r--r--Zotlabs/Photo/PhotoGd.php18
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();