spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.78k stars 1.08k forks source link

Conversion Quality NOT Applied with Source PNG when setting Background #3667

Open jmorfis opened 4 months ago

jmorfis commented 4 months ago

Conversions not working as expected with source type image/png.

On my model:

Below completes but the resulting jpg is not compressed...it is not honoring the quality(10) setting

            $this->addMediaConversion('remote')
                ->fit(Fit::Contain, 800, 600)
                ->quality(10) 
                ->background('#ffffff')
                ->nonQueued();

If I remove the background method the quality(10) is correctly applied. I can verify that the converted jpg is much smaller if filesize. The problem is, if you have a transparent background in the original PNG, it now shows up black in the converted jpegs.

            $this->addMediaConversion('remote')
                ->fit(Fit::Contain, 800, 600)
                ->quality(10) 
                ->nonQueued();

Using: package v. 11.7.5 imagemagick: 7.1.1-34 macos