Flip/Mirror operation doesn't flip/mirror the entirety of the picture (there...
SIMD-accelerated libjpeg-compatible JPEG codec library
Brought to you by:
dcommander
When using the flip or mirror operation in program using libjpeg (digikam, gwenview, jpegtran, eye of gnome) => the entirety of the picture is not mirrored of flipped: there is a little strip left unchanged.
This happens when the size of the picture is a multiple of 8: so then the flip/mirror operation is NOT loss-less !
Originally reported on digikam bugzilla: see discussion https://bugs.kde.org/show_bug.cgi?id=320107
See picture examples:
Please read the jpegtran man page, as well as usage.txt in the libjpeg-turbo source. This is probably the third bug report I've received this month regarding something which isn't a bug. Our lossless transformation code is inherited from libjpeg and behaves identically to its parent. Because lossless transformation works in frequency space, not image space, it manipulates raw DCT coefficients, not image pixels. Therefore, certain operations can only work on full MCU blocks. A full MCU block is 8x8 if the image isn't chroma-subsampled, but if it is chroma-subsampled, then the MCU block could be 16x16 (4:2:0) or 16x8 (4:2:2). When flipping the image, if the vertical image dimension isn't evenly divisible by 8 * the vertical chroma sampling factor, then the bottom-most MCU row is incomplete. An incomplete MCU row can't be moved to the top or left of the image, so if the transform would do so, then the transform is considered "imperfect." There are limited options in this case-- libjpeg-turbo can either trim that MCU row, thus making the transformed image smaller, or it can leave it in place and transform the MCUs that it is able to transform.
It is incumbent upon user-level software to handle this case. For instance, whenever I try to transform an image using GraphicConverter on my Mac, it will pop up a dialog if the image dimensions don't fall on MCU boundaries, and I can choose from that dialog whether I want to trim the image or transform it using a lossy method (decompress/recompress.)