Using native PHP webp for image output
This commit is contained in:
parent
fb71414dc3
commit
26e3b22f76
1 changed files with 21 additions and 21 deletions
|
@ -131,35 +131,35 @@ class Resize
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'webp':
|
case 'webp':
|
||||||
//$this->image->setImageFormat('webp');
|
$this->image->setImageFormat('webp');
|
||||||
|
|
||||||
$signature = $this->image->getImageSignature();
|
// $signature = $this->image->getImageSignature();
|
||||||
$temp = '/tmp/temp-'.$signature.'.'.\strtolower($this->image->getImageFormat());
|
// $temp = '/tmp/temp-'.$signature.'.'.\strtolower($this->image->getImageFormat());
|
||||||
$output = '/tmp/output-'.$signature.'.webp';
|
// $output = '/tmp/output-'.$signature.'.webp';
|
||||||
|
|
||||||
// save temp
|
// // save temp
|
||||||
$this->image->writeImages($temp, true);
|
// $this->image->writeImages($temp, true);
|
||||||
|
|
||||||
// convert temp
|
// // convert temp
|
||||||
\exec("cwebp -quiet -metadata none -q $quality $temp -o $output");
|
// \exec("cwebp -quiet -metadata none -q $quality $temp -o $output");
|
||||||
|
|
||||||
$data = \file_get_contents($output);
|
// $data = \file_get_contents($output);
|
||||||
|
|
||||||
//load webp
|
// //load webp
|
||||||
if (empty($path)) {
|
// if (empty($path)) {
|
||||||
return $data;
|
// return $data;
|
||||||
} else {
|
// } else {
|
||||||
\file_put_contents($path, $data, LOCK_EX);
|
// \file_put_contents($path, $data, LOCK_EX);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->image->clear();
|
// $this->image->clear();
|
||||||
$this->image->destroy();
|
// $this->image->destroy();
|
||||||
|
|
||||||
//delete webp
|
// //delete webp
|
||||||
\unlink($output);
|
// \unlink($output);
|
||||||
\unlink($temp);
|
// \unlink($temp);
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue