Rotation Transformation

This options specifies the degrees by which the output image has to be rotated. Or it can be used to automatically correct the orientation of the image using the image metadata.


Currently, for specifying the degrees of rotation, only 4 values are supported - 90, 180, 270 and 360. Auto-orientation has been discussed later in this article.


Syntax

rt-<angle>
'angle' can be 90, 180, 270 or 360


Example

1. Image resized to 200x200 and rotated by 90 degrees

https://ik.imagekit.io/demo/tr:h-200,w-200,rt-90/medium_cafe_B1iTdD0C.jpg



Auto-orientation

The rotation transformation supports a special value "auto", that automatically corrects the image orientation using the EXIF orientation tag in the image metadata. This option is also available as a dashboard setting, under "Image Settings" > "Advanced".


Syntax

rt-auto

If the auto orientation setting in the dashboard is not enabled and rt-auto is not used in the image URL, the default behavior in ImageKit is that all the image metadata, which also includes the EXIF orientation tag, is removed to make the image smaller for delivery. This means that the image would be displayed in an incorrect orientation to your users. 


This is where auto-orientation is really handy. It corrects the orientation of the image, then removes the image metadata, thereby achieving a small size while maintaining the correct orientation. Note, that you can also achieve correct orientation by preserving all metadata in the image, but it would result in a larger image size.


Let's take a look at an example


This is the original image (taken from Exif orientation examples on Github)

As can be seen from the image above, the orientation is incorrect. With auto-orientation, this is how the image URL looks like

https://ik.imagekit.io/demo/img/tr:w-300,rt-auto/Landscape_3_r1jEp5Vo7.jpg


Note that, we are using the demo account here for the example. The demo account also has auto-orientation enabled from the default image settings. Thus, even if you remove rt-auto from the URL, it would still orient correctly.


If you have any questions about the above transformations, please reach out to us by creating a support ticket from your ImageKit dashboard.