# Force lossless rotation of JPEGs

**URL:** <https://resource.dopus.com/t/force-lossless-rotation-of-jpegs/54572>\
**Category:** Help & Support\
**Created:** [February 17, 2025, 11:21am UTC](https://resource.dopus.com/t/force-lossless-rotation-of-jpegs/54572 "2025-02-17T11:21:25Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Guido](https://resource.dopus.com/user_avatar/resource.dopus.com/guido/32/56013_2.png) [@Guido](https://resource.dopus.com/u/Guido)\
**Post date:** [March 4, 2025, 8:24pm UTC](https://resource.dopus.com/t/force-lossless-rotation-of-jpegs/54572/11 "2025-03-04T20:24:04Z")

</div>

Metadata change way as mentioned by mojo-chan is not reliable, because JPEG decoder is not obligated to respect metadata.

Lossless rotation of the JPEG data is always reliable, provided the image dimensions meet certain criteria (divisible by 16 should always work, divisible by 8 in some cases as well).

Moderate file size change after lossless rotation (depending on _entropy coding_ method) is normal!  
This is because the final lossless _entropy coding_ stage sees different data order after rearrangement of data for rotation.  
This is similar to text compression with zip: Rearrange words or letters in a text and you get different compressed file size, because compression depends on data order.

More puzzling:  
Even the decoded pixels of a losslessly rotated JPEG image may not match with rearrangement, because also the lossy parts of the decoding process depend on data order.  
All what the JPEG lossless rotation feature promises is data match after applying the _reverse operation on the JPEG data_, internally represented as DCT (Discrete Cosine Transform) coefficients.  
This is important to know if you want to verify lossless rotation by decoded pixel comparison: _First_ reverse the operation on the JPEG file, _then_ compare the decoded pixels (with the same decoder!). Do _not_ decode the original and rotated files and then rotate the pixel image. Need not match.

Regards  
Guido  
JPEG developer

---

_[View the full topic](https://resource.dopus.com/t/force-lossless-rotation-of-jpegs/54572)._
