filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 76 forks source link

Requiring specific image dimensions to be met (picker validation for image dimensions) #426

Open ease opened 3 years ago

ease commented 3 years ago

Is there any chance to set the options within PickerOptions to require files that meet specific criteria, such as i.e. 300x200px PNG? Or if it's not met then it opens crop UI with fixed selection that's 300x200px so that user can crop the image based on that. image

I'm aware of imageDim, imageMin and imageMax options, but it always respect the original aspect ratio, while I need to allow a user to choose the area within the image they've uploaded, and still fixing the rectangle selection to i.e. 300x200px rectangle? Such as avatars, etc...

javiergbas commented 3 years ago

I think you can achieve what you want with the following options:

{
  transformations: {
    crop: { aspectRatio: 1 / 1, force: true },
  },
  imageMin: [200, 200],
  imageMax: [200, 200],
}
ease commented 3 years ago

Thanks, that could solve some issues, but what if I have the area that requires 300px width and 200px height image and I want users to crop their image within those dimensions? I know it's aspectRatio: 1.5 / 1 but it doesn't work the way I want it, because crop rectangle:

To be more precise, I think Filestack needs an option to: