ctessier / nova-advanced-image-field

🌄 📐 A Laravel Nova advanced image field with cropping and resizing using Vue Advanced Cropper and Intervention Image
https://novapackages.com/packages/ctessier/nova-advanced-image-field
MIT License
100 stars 26 forks source link

Image Resize Not Working #73

Closed erayusta closed 2 years ago

erayusta commented 3 years ago

I want to resize and crop image from admin panel. But i think it's not working.

AdvancedImage::make('Image','image')->croppable()->resize(624, 168),

Then i selected 700x700 px image

image

Is it croppable/resize area size 624x168?

ctessier commented 3 years ago

Hi @erayusta

I am not sure I understand your issue. Just note that the resize method doesn't define the size of the crop box, but the size to which the image will be resized during upload (keeping the ratio).

If you want to specify a ratio for the crop box, you can give the croppable method a first parameter.

Hope this helps.

erayusta commented 3 years ago

Thank you for response. I understood you correctly.

Actually, I want to custom size for the crop box.

ctessier commented 3 years ago

Actually, I want to custom size for the crop box.

You can give it a ratio. The package uses https://github.com/fengyuanchen/cropperjs and cropperjs doesn't allow to pass an arbitrary width and height for the crop box.

I suggest you pass a ratio and define your ideal width or height in the resize method. Like this, your final image will have the right size, and your user will still be able to decide which part of the image to crop in case she wants to shrink the selection for instance.

As an example, ->croppable(16/9)->resize(400) will result in an image of 400px by 225px.