yii2-imagine icon indicating copy to clipboard operation
yii2-imagine copied to clipboard

Change color depth in png images after saving

Open degorych opened this issue 4 years ago • 2 comments

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?

  1. Create upload image form
  2. 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]);
  1. 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

degorych avatar May 05 '20 08:05 degorych

Any idea on how to fix it?

samdark avatar May 07 '20 09:05 samdark

Solution for Imagick may be here here

degorych avatar May 07 '20 14:05 degorych