VideoEditor SDK supports several configuration options for the
TransformToolController allowing flexible adaptation to different needs and use cases.
For a detailed explanation of how to configure different editor views, refer to this guide.
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
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.
While it is possible to configure the available preset aspect ratios for cropping, we can also disable free cropping to ensure that video will always choose one of the available aspect ratios by setting
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
Sometimes video 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.
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
VideoEditViewController by setting
This ensures that the transform tool is presented first if the selected video does not fit one of the allowed aspect ratios.