Lossless JPEG Saving

Log-in or register.

Lossless JPEG Saving

The JPEG codec used in RealWorld Photos applications since version 2008.1 supports lossless and partially lossless operations with a JPEG image.

JPEG compression

JPEG compression was designed to be lossy, which means the encoded image is not saved exactly, but at a relatively very high compression ratio. The small loss of quality outweighs the high compression ratio if the image in question is a photograph. Unfortunately, when a JPEG image is repeatedly modified and saved, the loss caused by the compression accumulates.

Lossless processing

A JPEG image is divided into tiles (called MCUs - minimum compression units) and each tile is processed separately. The size of the tiles is 8x8 pixels, but JPEG can save chrominance (hue) information at smaller resolution and therefore a 8x8 pixels of chrominance information can effectively affect for example 16x16 pixels.

The JPEG codec in RW apps detects which tiles were not changed since the original JPEG image was opened and if such tiles are found, they are copied from the original image without any loss.

Practical usage

To modify your JPEG images losslessly, no special care needs to be taken. If you for example watermark an image and save it, only the portion affected with the watermark will be re-encoded. When cropping or extending the canvas, make sure to make the cuts on tile (MCU) boundaries if you want to have the image saved losslessly. To simplify this task, the crop tool supports tiled mode that only allows you to crop at 16 pixel boundaries.

Limitations

  • If you convert a PNG to JPEG, the JPEG will NOT be the same as the PNG, the lossless saving only works from JPEG to JPEG.
  • The lossless operations are only supported for standard YCbCr JPEGs (these are the most common JPEGs - every digial camera produces these JPEGs), it is NOT supported for Adobe RGB, grayscale, or CMYK JPEGs.

Recent comments

user icon pollaris registered user on September 17th 2014

Can I get my Windows application icons any smaller?

In the icon group I include:
1.) a 256x256 png image for extra large icons, (about 12k compressed) and let Windows re-size to 96x96 for large icons.
2.) a 48x48 32 bit image (about 12k), and let Windows re-size to 32,24, and 16x16.

The icon is about 24k. If I replace the 32 bit image with a 48x48 png, the size
is reduced to about 15k and Windows accepts that. However some programs report that
"the icon is corrupted...".

Is 24k about a lower limit to the size of application icons (that will render in
most applications?)

user icon Vlasta site administrator on September 17th 2014

PNG-compressed icon images are supported in Vista and newer, so it won't be displayed in XP and older. If that is not what your users will have, you can use the smaller icon. Theoretically, you can have just the 256x256 format. Though Microsoft recommends 16, 24, 32, 48 and 256 for best user experience. The smaller images should be optimized and eventually use a different glyph.

user icon pollaris registered user on September 17th 2014

Yep, Windows accepts only a 256x256 compressed png! Total size only about 13k.
The 16x16 and 32x32 icons suffer minor edge distortion from re-sizing, but
all the others fair very well. It's good to know that I don't need all the formats
while I am experimenting; I can add 16, 24, 32, and 48 later when I have completed
an application. I noticed there is no distortion at all when Windows uses the actual image for an icon. A full blown icon package is never much more than 30k, and
I can live with that.

I will post any future comments in the forum as you suggested... thanks...

user icon Anonymous
Vista & Win 7 icons
What about ICL files?