diff --git a/wire/core/ImageSizerEngineGD.php b/wire/core/ImageSizerEngineGD.php index f58bb97c..97bad910 100755 --- a/wire/core/ImageSizerEngineGD.php +++ b/wire/core/ImageSizerEngineGD.php @@ -57,6 +57,7 @@ class ImageSizerEngineGD extends ImageSizerEngine { // and if it passes the mandatory requirements, we check particularly aspects here switch($action) { + case 'imageformat': // compare current imagefile infos fetched from ImageInspector $requested = $this->getImageInfo(false); @@ -69,7 +70,16 @@ class ImageSizerEngineGD extends ImageSizerEngine { return true; } break; - + + case 'webp': + if(!isset($this->wire('config')->webpSupportGD)) { + // only call it once + $gd = gd_info(); + $this->wire('config')->webpSupportGD = isset($gd['WebP Support']) ? $gd['WebP Support'] : false; + } + return $this->wire('config')->webpSupportGD; + break; + case 'install': /* $gd = gd_info(); @@ -77,6 +87,7 @@ class ImageSizerEngineGD extends ImageSizerEngine { $png = isset($gd['PNG Support']) ? $gd['PNG Support'] : false; $gif = isset($gd['GIF Read Support']) && isset($gd['GIF Create Support']) ? $gd['GIF Create Support'] : false; $freetype = isset($gd['FreeType Support']) ? $gd['FreeType Support'] : false; + $webp = isset($gd['WebP Support']) ? $gd['WebP Support'] : false; $this->config->gdReady = true; */ return true; diff --git a/wire/core/Pageimage.php b/wire/core/Pageimage.php index 3338dace..81a954e6 100644 --- a/wire/core/Pageimage.php +++ b/wire/core/Pageimage.php @@ -833,7 +833,13 @@ class Pageimage extends Pagefile { /** @var ImageSizerEngine $engine */ $engine = $sizer->getEngine(); - + + /* if the current engine installation does not support webp, modify the options param */ + if(isset($options['webpAdd']) && $options['webpAdd'] && !$engine->supported('webp')) { + $options['webpAdd'] = false; + $engine->setOptions($options); + } + // allow for ImageSizerEngine module settings for quality and sharpening to override system defaults // when they are not specified as an option to this resize() method $engineConfigData = $engine->getConfigData(); @@ -1929,7 +1935,7 @@ class Pageimage extends Pagefile { $original, parent::__debugInfo(), array( - 'suffix' => $finalOptions['suffix'], + 'suffix' => isset($finalOptions['suffix']) ? $finalOptions['suffix'] : '', 'extension' => $osInfo['extension'] ) )); @@ -1993,7 +1999,8 @@ class Pageimage extends Pagefile { $enginesArray = array( 'neededEngineSupport' => strtoupper($oSizer->getImageInfo()), 'installedEngines' => $a, - 'selectedEngine' => $oSizer->getEngine()->className + 'selectedEngine' => $oSizer->getEngine()->className, + 'engineWebpSupport' => $oSizer->getEngine()->supported('webp') ); unset($a, $moduleName, $configData, $engines, $priority, $modules, $oSizer); diff --git a/wire/modules/Image/ImageSizerEngineIMagick/ImageSizerEngineIMagick.module b/wire/modules/Image/ImageSizerEngineIMagick/ImageSizerEngineIMagick.module index dcc4a5b5..9cecb6a0 100755 --- a/wire/modules/Image/ImageSizerEngineIMagick/ImageSizerEngineIMagick.module +++ b/wire/modules/Image/ImageSizerEngineIMagick/ImageSizerEngineIMagick.module @@ -161,7 +161,22 @@ class ImageSizerEngineIMagick extends ImageSizerEngine { return false; } break; - + + case 'webp': + if(!isset($this->wire('config')->webpSupportIM)) { + // only call it once + ob_start(); + phpinfo(INFO_MODULES); + $dump = ob_get_clean(); + $list = array(); + if(preg_match('#ImageMagick supported formats