Configure Transforms
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 CropAspectAsset
s and give it the desired width
and height
.
For the UI, we add CropAspectItem
s with ids matching CropAspectAsset
s. The 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.
Force crop#
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 TransformTool
.
We also set the forceCropMode
to SHOW_TOOL_ALWAYS
. This ensures that the transform tool is always presented first before being able to use other features of the editor.