yii2-imagine
yii2-imagine copied to clipboard
Change color depth in png images after saving
When I upload a png picture, it has a color depth of 8 bits and a size of 0.3 mb. After saving, the color depth becomes 32 bits, and the size with a maximum compression of 0.7 mb.
What steps will reproduce the problem?
- Create upload image form
- Add image saving code in the controller action
$file = UploadedFile::getInstanceByName('file');
Image::getImagine()->open($file->tempName)
->save('path/to/destination/image.png', ['png_compression_level' => 9]);
- Upload any phg image with 8 bit color depth and save it.
What's expected?
Expected png image with 8 bit color depth and it will be compressing
What do you get instead?
Get png image with 32 bit color depth and it has more size then first image.
Additional info
Q | A |
---|---|
Yii version | 2.0.15.1 |
Imagine version | 2.2.0 |
PHP version | 7.2 |
Operating system | ubuntu 18.04 |
Any idea on how to fix it?
Solution for Imagick may be here here