SeNioR- Posted January 26, 2023 Posted January 26, 2023 (edited) Hey, devs. I have a question about converting image attachments. So, if we use Imagick, PNG images are not compressed at all. 8 out of 10 images that I uploaded to the post have a larger file size than before uploading (lol). I wrote some code to compress PNG images (by changing the format to webp) and the size dropped by about 80% (sic!), however I need code to save the output file in .webp format. Can anyone direct me how to change the output format after uploading? /* Get Format */ $format = $this->imagick->getImageFormat(); /* Set PNG */ if( mb_strtolower( $format ) == 'png' ) { $this->imagick->setImageFormat('webp'); $this->imagick->setOption('webp:filter-strength', '20'); $this->imagick->setOption('webp:filter-type', '0'); $this->imagick->setOption('webp:method', '3'); $this->imagick->setImageCompressionQuality( 85 ); } Edited January 26, 2023 by SeNioR- PayMap 1
Joey_M Posted November 1, 2023 Posted November 1, 2023 @SeNioR-: Did you ever get anywhere with this?
Recommended Posts