spatie / laravel-medialibrary

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

Missing the Fit::FillMax #3612

Closed JelmerIJff closed 5 months ago

JelmerIJff commented 6 months ago

I'm missing the FillMax manipulation from the previous version.

I've tried Fit::Contain but then the image doesn't get my desired width and height. And with Fit::Fill the image stays really small with a lot of padding around it. FillMax is the perfect solution because that should respect the aspect ratio within the given desired width and height, and at the same time should upscale to fit the given width and height.

According to the docs it should work but there is no class present in the directory: https://spatie.be/docs/image/v3/image-manipulations/resizing-images#content-manipulationsfillmax

timvandijck commented 6 months ago

There should be a way of doing this, but it's indeed not working the way it's documented.

You should try this: ->fit(fit: Fit::Fill, desiredWidth: 800, desiredHeight: 200, backgroundColor: '#0073ff')

I will update the documentation accordingly.

JelmerIJff commented 6 months ago

No, i've already tried that but then you get a small image with a lot of padding around it. FillMax is supposed to fill it right to the edges right while maintaining the aspect ratio? Team Visma Shirt

timvandijck commented 6 months ago

Ok, tested it with some different images and sizes, and I think I see what you mean now.

I implemented a quick implementation in Imagick, but I'll only get around GD next week I'm afraid: https://github.com/spatie/image/pull/258

timvandijck commented 5 months ago

Pushed a new release of spatie/image that adds FillMax as a fit operation: https://github.com/spatie/image/pull/258