PhotoEditor SDK supports several configuration options for the
TransformToolPanel allowing flexible adaptation to different needs and use cases.
Forcing specific ratios#
The default configuration includes several different crop aspect ratios users can choose from. To restrict those to specific aspect ratios only, for instance, those used by social networks (e.g. Facebook, Twitter, Instagram, Flickr), we can specify aspect ratios as
CropAspectAssets and give it the desired
For the UI, we add
CropAspectItems with ids matching
CropAspectItem constructor allows using a custom name and
ImageSource for further customization.
For the sake of this example, we don't add the Reset button and Free Crop since we are enforcing certain ratios.
PhotoEditor SDK chooses the best matching aspect amongst the specified ratios for the input photo. However, you can also force a specific ratio.
Here, we force the 16:9 ratio for landscape photos and the 9:16 ratio for portrait photos. However, the user can still choose from one of the specified ratios above using the
We also set the
SHOW_TOOL_ALWAYS. This ensures that the transform tool is always presented first before being able to use other features of the editor.