Closed JelmerIJff closed 5 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.
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?
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
Pushed a new release of spatie/image that adds FillMax as a fit operation: https://github.com/spatie/image/pull/258
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