yiisoft / yii2-imagine

Yii 2 imagine extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
288 stars 94 forks source link

Change color depth in png images after saving #65

Open degorych opened 4 years ago

degorych commented 4 years ago

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]);
  3. 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
samdark commented 4 years ago

Any idea on how to fix it?

degorych commented 4 years ago

Solution for Imagick may be here here