1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 03:05:26 +02:00

A couple other ImageSizerEngine adjustments for webp

This commit is contained in:
Ryan Cramer
2019-05-24 14:22:07 -04:00
parent 50f8024ba3
commit d8bbde74d7
2 changed files with 12 additions and 8 deletions

View File

@@ -1657,13 +1657,17 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
return false; // fallback or failed
}
// all went well, copy back the temp file, remove the temp file
if(!@copy($this->tmpFile, $this->filename)) return false; // fallback or failed
$this->wire('files')->chmod($this->filename);
$this->wire('files')->unlink($this->tmpFile);
// post processing: IPTC, setModified and reload ImageInfo
$this->writeBackIPTC($this->filename, false);
if($this->webpOnly) {
$this->wire('files')->unlink($this->tmpFile);
} else {
// all went well, copy back the temp file,
if(!@copy($this->tmpFile, $this->filename)) return false; // fallback or failed
$this->wire('files')->chmod($this->filename);
// remove the temp file
$this->wire('files')->unlink($this->tmpFile);
// post processing: IPTC, setModified and reload ImageInfo
$this->writeBackIPTC($this->filename, false);
}
$this->setModified($this->modified);
$this->loadImageInfo($this->filename, true);

View File

@@ -239,7 +239,7 @@ class ImageSizerEngineGD extends ImageSizerEngine {
// current version is already the desired result, we only may have to compress JPEGs but leave GIF and PNG as is:
if(!$isModified && ($this->imageType == \IMAGETYPE_PNG || $this->imageType == \IMAGETYPE_GIF)) {
if(!$isModified && !$this->webpOnly && ($this->imageType == \IMAGETYPE_PNG || $this->imageType == \IMAGETYPE_GIF)) {
$result = @copy($srcFilename, $dstFilename);
if(isset($image) && is_resource($image)) @imagedestroy($image); // clean up
if(isset($image)) $image = null;