vanilophp / framework

The truly Laravel E-commerce Framework
https://vanilo.io
MIT License
816 stars 103 forks source link

Question : new behavior in Media? #179

Closed csavelief closed 5 months ago

csavelief commented 5 months ago

Hi!

I upgraded to Vanilo 4 and its seems that the way media are handled has changed : now all my png files are automatically converted to jpg. Unfortunately, the transparent background is now lost due to this conversion.

This is the snippet of code I use to attach a Media to a Product :

$media = $product
  ->copyMedia(public_path('/images/' . $app['logo']))
  ->toMediaCollection();

Is-it expected? Is-there a workaround?

Best,

Cyrille

fulopattila122 commented 5 months ago

The media-related work is being done by the Spatie Media Library package: https://spatie.be/docs/laravel-medialibrary/v11/introduction

With Vanilo 4, it has been upgraded from v10 to v11 since that version is compatible with Laravel 11.

I think this issue might be the same as yours: https://github.com/spatie/laravel-medialibrary/issues/3502

As far as I read, running composer update -W spatie/image spatie/laravel-medialibrary should solve the issue.

csavelief commented 5 months ago

It does not. I will try to understand why. Thanks.

fulopattila122 commented 5 months ago

Can you share more details here once you know more about this issue?

csavelief commented 5 months ago

Solved! I did the following things :

First, I installed php-imagick.

apt-get install php-imagick

Then, I added the imagick extension to my composer.json file.

"require": {
   "ext-imagick": "*",
   ...
}

Next, I updated my .env file to use this driver instead of the default gd driver.

IMAGE_DRIVER=imagick

And the problem was solved as explained here.