Yummypets / YPImagePicker

📸 Instagram-like image picker & filters for iOS
MIT License
4.31k stars 976 forks source link

Is there a way to specify an aspect ratio inside the library VC? #670

Open rudsberg opened 3 years ago

rudsberg commented 3 years ago

The application I am building is intended not to allow any arbitrary crop to be applied to an image, instead a specific aspect ratio is only allowed. So, is it possible to use the same behaviour as "showsCrop" has, but have it being applied in the library VC? That is, I would like to restrict to only change to crop to a given aspect ratio inside the library VC. I am aware of the "showsCrop" attribute which adds another step to the picker after selection. However, I want to only include the library view to select images/videos with my specified crop ratio and then not have any extra step. Is this possible?

If this is not possible, would it be possible to entirely disable the cropping in the library VC?

Thank you for your guidance. I am loving the library. Cheers.

s4cha commented 3 years ago

Hi @rudsberg, the crop feature is only available as an extra step at the moment, the library preview only handling square crops. To disable the crop feature altogether you can use config.showsCrop = .none, which is the default value. To force a custom image ratio, you can use config.showsCrop = .rectangle(ratio: (16/9)) for example.

AlexisLampouridis commented 3 years ago

Hello @s4cha I want to add something to this.

After taking a picture and the next step is filters , the filter preview is always 4:3 and we cannot change it. And in my use-case which needs the output to be 16:9 creates a problem , because I need to convert the image to 16:9 bypassing the .crop stage of the library and the user cannot select what he wants to be shown to the final image.

So it would be great to config the library to a certain aspect ratio and apply it to all steps.

I tried this config.targetImageSize = .cappedTo(size: CGFloat(9/16)) but it doesn't change the image ratio at the filter step.