How this works
Rotating by exactly 90, 180 or 270 degrees is pixel-perfect — no quality loss, no extra padding. Any other angle (like 15° to straighten a tilted photo) adds a small margin around the edges, since a rotated rectangle no longer fits its original bounding box exactly.