Printable Version of Topic

Click here to view this topic in its original format

PMView Pro Forums _ PMView - Windows Technical Support _ Bug with lossless JPG-Rotating - Rotating changes the image-size.

Posted by: Hermann May 17 2004, 04:22 AM

When I rotate a JPG image with the lossless JPG-Rotating, the image size changes.

For example: When I use my lossless 90° Clockwise Rotating to rotate a 800x600 JPG image , I get a 592x800 JPG image.

Is this behavior expected? I don't think so, because it simply cuts one side of my image off.

I'm using WindowsXP Professionel (SP1).
Tested it on WindowsXP Home and it results in the same bug.

Posted by: Peter May 18 2004, 07:25 PM

Yes, this image size chage is expected. It has to do with the "block size" of the JPEG encoding. This will occur if the image size is not evenly divisible by 16 (or sometimes 8). Quoting www.faqs.org/faqs/jpeg-faq/ :

"There are a few specialized operations that can be done on a JPEG file
without decompressing it, and thus without incurring the generational loss
that you'd normally get from loading and re-saving the image in a regular
image editor. In particular it is possible to do 90-degree rotations and
flips losslessly, if the image dimensions are a multiple of the file's
block size (typically 16x16, 16x8, or 8x8 pixels for color JPEGs). "

There are two ways to deal with it. #1 is to not change the size (garbage will appear) #2 is to change the size.
Almost all programs choose #2, because it is never nice to present the user with garbage data...

Thanks,

Posted by: Hermann May 19 2004, 01:38 AM

Thanks!

So there is no possibility to rotate a JPG-image really lossless?

Posted by: Peter May 20 2004, 06:19 PM

In order to do a lossless rotation of JPEG files, the internal blocks must be rotated losslessly. If the image size is a multiple of the block size, all blocks can be losslessly rotated. If not, the outer edge blocks cannot be losslessly rotated. (PMView chooses to throw them away instead of showing garbage or doing any other dirty tricks).

For instance your 600 pixel side is not divisible by the block size 16. It has 37.5 blocks in the 600 pixel direction. The half block cannot be rotated, and will be garbled. PMView will drop this block and make this side 592 pixels (=37 blocks).

Usually this is not an issue when working with image originals. Most, if not all, cameras will output images with an even number of blocks in both the x and y axis. This leads me to believe that your 800x600 images are already processed by another application and may already have suffered loss by being resaved to a different non-block aligned size...

Thanks,

Posted by: Hermann May 21 2004, 03:16 PM

Yes you are right. My camera makes 2048x1536 px pictures.
So its no problem.

Thank you a lot for the detailed explanations!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)