When i add webp to supportedTypes() id PhotoGD.php it will use PHP GD lib for .webp?
blueimp
SabreDAV
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.phpindex 6a88513dc..59c23c002 100644--- a/Zotlabs/Module/Embedphotos.php+++ b/Zotlabs/Module/Embedphotos.php@@ -68,6 +68,8 @@ class Embedphotos extends \Zotlabs\Web\Controller { $ext = '.png'; elseif($r[0]['mimetype'] === 'image/gif') $ext = '.gif';+ elseif($r[0]['mimetype'] === 'image/webp')+ $ext = '.webp'; else $ext = EMPTY_STR; diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.phpindex f1b1acaef..58ac5fa35 100644--- a/Zotlabs/Module/Help.php+++ b/Zotlabs/Module/Help.php@@ -66,6 +66,9 @@ class Help extends \Zotlabs\Web\Controller { case IMAGETYPE_PNG: header("Content-Type: image/png"); break;+ case IMAGETYPE_WEBP:+ header("Content-Type: image/webp");+ break; default: break; }diff --git a/Zotlabs/Photo/PhotoGd.php b/Zotlabs/Photo/PhotoGd.phpindex 4054e1866..f88bf9f25 100644--- a/Zotlabs/Photo/PhotoGd.php+++ b/Zotlabs/Photo/PhotoGd.php@@ -19,6 +19,8 @@ class PhotoGd extends PhotoDriver { $t['image/png'] = 'png'; if(imagetypes() & IMG_GIF) $t['image/gif'] = 'gif';+ if(imagetypes() & IMG_WEBP)+ $t['image/webp'] = 'webp'; return $t; }@@ -157,6 +159,9 @@ class PhotoGd extends PhotoDriver { \imagepng($this->image, NULL, $quality); break;+ case 'image/webp':+ \imagewebp($this->image)+ break; case 'image/jpeg': // gd can lack imagejpeg(), but we verify during installation it is available default:diff --git a/Zotlabs/Photo/PhotoImagick.php b/Zotlabs/Photo/PhotoImagick.phpindex a7026e8ca..7a8dbfee1 100644--- a/Zotlabs/Photo/PhotoImagick.php+++ b/Zotlabs/Photo/PhotoImagick.php@@ -8,19 +8,14 @@ namespace Zotlabs\Photo; class PhotoImagick extends PhotoDriver { public function supportedTypes() {- return [+ $ret = [ 'image/jpeg' => 'jpg', 'image/png' => 'png',- 'image/gif' => 'gif',- ];- }-- private function get_FormatsMap() {- return [- 'image/jpeg' => 'JPG',- 'image/png' => 'PNG',- 'image/gif' => 'GIF',+ 'image/gif' => 'gif' ];+ if(\Imagick::queryFormats("WEBP"))+ $ret['image/webp'] = 'webp';+ return $ret; } @@ -42,8 +37,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);@@ -78,6 +73,9 @@ class PhotoImagick extends PhotoDriver { if((! $quality) || ($quality > 100)) $quality = JPEG_QUALITY; $this->image->setCompressionQuality($quality);+ break;+ case 'image/webp':+ break; default: break; }diff --git a/boot.php b/boot.phpindex bc1e2a319..6d25af3ad 100755--- a/boot.php+++ b/boot.php@@ -913,7 +913,9 @@ class App { 'ttf'=>'font/ttf', 'woff'=>'font/woff', 'woff2'=>'font/woff2',- 'svg'=>'image/svg+xml'];+ 'svg'=>'image/svg+xml',+ 'webp'=>'image/webp'+ ]; if (array_key_exists($filext, $serve_rawfiles) && file_exists(self::$cmd)) { $staticfilecwd = getcwd();diff --git a/include/attach.php b/include/attach.phpindex 80efe0838..347dbe1f9 100644--- a/include/attach.php+++ b/include/attach.php@@ -62,6 +62,7 @@ function z_mime_content_type($filename) { 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml',+ 'webp' => 'image/webp', // archives 'zip' => 'application/zip',diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.phpindex c11580bdc..284206161 100644--- a/include/photo/photo_driver.php+++ b/include/photo/photo_driver.php@@ -135,6 +135,8 @@ function guess_image_type($filename, $headers = '') { $type = 'image/gif'; elseif(strpos(strtolower($filename),'png') !== false) $type = 'image/png';+ elseif(strpos(strtolower($filename),'webp') !== false)+ $type = 'image/webp'; } }diff --git a/include/text.php b/include/text.phpindex eba41521d..87ed9f658 100644--- a/include/text.php+++ b/include/text.php@@ -2992,6 +2992,7 @@ function getIconFromType($type) { 'image/jpeg' => 'fa-picture-o', 'image/png' => 'fa-picture-o', 'image/gif' => 'fa-picture-o',+ 'image/webp' => 'fa-picture-o', 'image/svg+xml' => 'fa-picture-o', //Archive 'application/zip' => 'fa-file-archive-o',
If it supported by PHP GD or ImageMagic
dev