Skip to main content
Language

Configure Transforms

PhotoEditor SDK supports several configuration options for the TransformToolController allowing flexible adaptation to different needs and use cases. For a detailed explanation on how to configure different editor views, refer to this guide.

allowedCropRatios#

The default configuration includes a number of different crop aspect ratios users can choose from. In order 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 CropAspect object and give it the desired width and height. The localizedName argument to the CropAspect construtor allows using a custom name for the crop ratio. Note that setting the aspect ratio will not affect the resolution of the image.

allowFreeCrop#

While it is possible to configure the available preset aspect ratios for cropping, we can also disable free cropping to ensure that photo will always choose one of the available aspect ratios by setting allowFreeCrop to false.

showResetButton#

When free crop is enabled, users need a way to reset the applied transform operations. In our example, since we are enforcing a certain set of aspect ratios, we can disable the reset button by setting showResetButton to false.

outputScaling#

Sometimes image resolution can't be represented in aspect ratio that is desired. That happen in cases where width and height aren't dividable by the selected aspect ratio widths and heights. For this purpose we have an option to scale the output resolution to match the selected ratio exactly. Default is set to .none which means that no output scaling will be performed. In our example we set it to .scaleUp, which means that the output resolution will be scaled up to the closest resolution that is dividable by the selected ratio.

Introduced in PhotoEditor SDK v11.6.0

forceCropMode#

Since in this example we enforce a certain set of aspect ratios, we need to ensure that one of the crop options is selected before any other editing operations are applied. To this end we configure the PhotoEditViewController by setting forceCropMode to true. This ensures that the transform tool is presented first if the selected photo does not fit one of the allowed aspect ratios.