sherwinmdev's avatar

can i force images to be square?

is there something i can use to make images that are uploaded to be square. for instance, i want all images to be 800x800. i'd like the user to be able to select a section of the image and have it cropped or resize to fit the square. kind of like how instagram does it.

i am using image intervention to do the resizing and orientation fix already. but those who upload a photo that is landscape or portrait and not square, it resizes the images and crops them to make it square. hope i'm explaining this right.

0 likes
3 replies
Cronix's avatar

You could use something like this plugin: https://fengyuanchen.github.io/cropperjs/

There are options that will allow you to set a fixed ratio square for the cropping and force it to stay in the actual image area (so you can't select outside of the image boundary) and the user can move it around to crop what they'd like. There are many js tools that will do this type of thing.

1 like
Chris1904's avatar

You could also simply use CSS and object-fit and then just recommend what the recommended image dimensions should be upon upload.

1 like

Please or to participate in this conversation.