summaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2021-01-17 21:09:31 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2021-01-19 20:17:10 +0100
commit6d4afca7ace0b62f4256b18a0cab60f180ebbc07 (patch)
treed9659629bbfa8bf45dabffb2ad2c4387e161d16e /lib/private/legacy
parent3406032cf8ff3062329dd7a18937a2ec3dbfbf8d (diff)
downloadnextcloud-server-6d4afca7ace0b62f4256b18a0cab60f180ebbc07.tar.gz
nextcloud-server-6d4afca7ace0b62f4256b18a0cab60f180ebbc07.zip
Add support for webp
Including handling in OC_Image But also a preview provider Of course only works if your php actually supports webp Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/OC_Image.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php
index b97413aa922..f1b9101045a 100644
--- a/lib/private/legacy/OC_Image.php
+++ b/lib/private/legacy/OC_Image.php
@@ -555,7 +555,7 @@ class OC_Image implements \OCP\IImage {
*/
public function loadFromFile($imagePath = false) {
// exif_imagetype throws "read error!" if file is less than 12 byte
- if (!@is_file($imagePath) || !file_exists($imagePath) || filesize($imagePath) < 12 || !is_readable($imagePath)) {
+ if (is_bool($imagePath) || !@is_file($imagePath) || !file_exists($imagePath) || filesize($imagePath) < 12 || !is_readable($imagePath)) {
return false;
}
$iType = exif_imagetype($imagePath);
@@ -608,6 +608,13 @@ class OC_Image implements \OCP\IImage {
case IMAGETYPE_BMP:
$this->resource = $this->imagecreatefrombmp($imagePath);
break;
+ case IMAGETYPE_WEBP:
+ if (imagetypes() & IMG_WEBP) {
+ $this->resource = @imagecreatefromwebp($imagePath);
+ } else {
+ $this->logger->debug('OC_Image->loadFromFile, webp images not supported: ' . $imagePath, ['app' => 'core']);
+ }
+ break;
/*
case IMAGETYPE_TIFF_II: // (intel byte order)
break;