awcodes / filament-curator

A media picker plugin for Filament Panels.
MIT License
339 stars 86 forks source link

Image Crop Aspect Ratio #542

Closed kinkaz closed 3 weeks ago

kinkaz commented 1 month ago

Filament Version

v3.2.117

Plugin Version

v3.6.9

PHP Version

PHP 8.2.20

Problem description

I tried to use imageCropAspectRatio when a user load an image :

CuratorPicker::make('image')
                            ->acceptedFileTypes(['image/webp'])
                            ->imageCropAspectRatio('13:16')
                            ->required()

The acceptedFileTypes does work but the imageCropAspectRatio does nothing

Expected behavior

I expected the user to either be forbidden to upload or to be forced to crop the picture that are not in the correct aspect ratio

Steps to reproduce

Add a CuratorPicker as I did.

Reproduction repository

No response

Relevant log output

No response

awcodes commented 1 month ago

imageCropAspectRatio() is not a validation, it will crop the image to that ratio, but it requires a few other methods to work correctly.

https://filamentphp.com/docs/3.x/forms/fields/file-upload#cropping-and-resizing-images-without-the-editor

kinkaz commented 3 weeks ago

Hi, Thanks, it seems to work adding the additional methods.

However, with FileUpload, you can directly call the imageEditor method and allow the user to choose what the picture should focus on in cover mode.

Is it possible with your plugin ?

awcodes commented 3 weeks ago

There's currently no integration in Curator for the ->imageEditor() functionality. It is in the works. It's just not a simple integration and is a destructive action against the image that's stored on disk.

Curations are meant for focal point picking though. Maybe those can serve your needs until I can get it integrated.