mirror of
https://github.com/processwire/processwire.git
synced 2025-08-21 05:51:41 +02:00
refactored webp creation and compression
This commit is contained in:
@@ -360,6 +360,10 @@ class ImageSizerEngineIMagick extends ImageSizerEngine {
|
||||
$this->im->setImageDepth(($this->imageDepth > 8 ? 8 : $this->imageDepth));
|
||||
|
||||
// prepare to save file(s)
|
||||
if($this->webpAdd) {
|
||||
$this->imWebp = clone $this->im; // make a copy before compressions take effect
|
||||
}
|
||||
|
||||
$this->im->setImageFormat($this->imageFormat);
|
||||
$this->im->setImageType($this->imageType);
|
||||
if(in_array(strtoupper($this->imageFormat), array('JPG', 'JPEG'))) {
|
||||
@@ -394,8 +398,6 @@ class ImageSizerEngineIMagick extends ImageSizerEngine {
|
||||
|
||||
// optionally create a WebP dependency file
|
||||
if($this->webpAdd) {
|
||||
$this->imWebp = new \IMagick();
|
||||
if($this->imWebp->readImage($dstFilename)) {
|
||||
// prepare for webp output
|
||||
$this->imWebp->setImageFormat('webp');
|
||||
$this->imWebp->setImageCompressionQuality($this->webpQuality);
|
||||
@@ -404,7 +406,6 @@ class ImageSizerEngineIMagick extends ImageSizerEngine {
|
||||
// save to file
|
||||
$return = $this->imWebp->writeImage($webpFilename);
|
||||
}
|
||||
}
|
||||
|
||||
// release and return to event-object
|
||||
$this->release();
|
||||
|
Reference in New Issue
Block a user