Bug with lossless JPG-Rotating - Rotating changes the image-size. |
Bug with lossless JPG-Rotating - Rotating changes the image-size. |
May 17 2004, 04:22 AM
Post
#1
|
|
Forum Member Group: Members Posts: 9 Joined: 4-March 03 From: Vienna Member No.: 134 |
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. |
|
|
May 18 2004, 07:25 PM
Post
#2
|
|
Forum Member Group: Admin Posts: 672 Joined: 14-March 00 From: Wilmington, North Carolina Member No.: 3 |
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, -------------------- Peter Nielsen (peter@pmview.com) "If you can dream it, you can do it" JFK.
|
|
|
May 19 2004, 01:38 AM
Post
#3
|
|
Forum Member Group: Members Posts: 9 Joined: 4-March 03 From: Vienna Member No.: 134 |
Thanks!
So there is no possibility to rotate a JPG-image really lossless? |
|
|
May 20 2004, 06:19 PM
Post
#4
|
|
Forum Member Group: Admin Posts: 672 Joined: 14-March 00 From: Wilmington, North Carolina Member No.: 3 |
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, -------------------- Peter Nielsen (peter@pmview.com) "If you can dream it, you can do it" JFK.
|
|
|
May 21 2004, 03:16 PM
Post
#5
|
|
Forum Member Group: Members Posts: 9 Joined: 4-March 03 From: Vienna Member No.: 134 |
Yes you are right. My camera makes 2048x1536 px pictures.
So its no problem. Thank you a lot for the detailed explanations! |
|
|
Lo-Fi Version | Time is now: 10th November 2024 - 02:41 PM |