Skip to content

add support for specifying a min and max aspect ratio#63

Open
takdw wants to merge 1 commit into
ctessier:1.xfrom
takdw:min-max-aspect-ratio
Open

add support for specifying a min and max aspect ratio#63
takdw wants to merge 1 commit into
ctessier:1.xfrom
takdw:min-max-aspect-ratio

Conversation

@takdw

@takdw takdw commented Feb 11, 2021

Copy link
Copy Markdown

Add support for specifying min and max aspect ratio values for cropping

This PR tries to add a functionality that allows users to specify a minimum and maximum range for aspect ratio. This can be useful when you want to allow a varying number of crop aspect ratios. It uses a listener on a CropperJs instance to determine the crop box. I have still kept the existing vue-cropperjs implementation and that is preferred when the user wants a crop of a fixed aspect ratio. It also allows for cropping outside the bounds of the image. The empty space is filled a white (#ffffff) color.

Usage

AdvancedImage::make('Logo', 'logo')->croppable(1); // square crop 1:1
AdvancedImage::make('Logo', 'logo')->croppable(16 / 9); // 16:9 crop ratio
AdvancedImage::make('Logo', 'logo')->croppable(1, 2); // allowed crop ratios are from 1 (1:1) to 2 (2:1)

@ctessier ctessier force-pushed the 1.x branch 2 times, most recently from e24cad5 to 5587ccb Compare April 24, 2021 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant