I am using spatie/media-library
with my Laravel 8
project. In the model, I am writing a method to register a mediaCollection
for a model. The issue I am facing is that during the conversion, the transparency is lost in the converted image.
How can I resize the image without losing transparency in result image?
Here is the code that I am using
public function registerMediaCollections(): void
{
$this->addMediaCollection('crops')
->singleFile()
->useDisk('public')
->acceptsMimeTypes([
'image/jpeg', 'image/png', 'image/jpg',
])
->onlyKeepLatest(1)
->registerMediaConversions(function (Media $media) {
$this
->addMediaConversion('thumb')
->fit(Manipulations::FIT_CROP, 150, 150)
->keepOriginalImageFormat();
});
}