IE9 and JPEG-XR: first impressions

April 5th, 2010. Tagged: IE, images, PEAR, performance, PHP certification

One of the new features in IE9 is the support for the JPEG-XR format, which reportedly has a better compression. Is it something we should dive into ASAP?

JPEG-XR

The wikipedia article is here. This format is developed and patented (red flag!) by Microsoft (yellow flag! :) ), it replaces the suggested JPEG-2000 format and is an official standard as of mid '09. It's formerly known as "HD photo" and "Microsoft something something" and is heavily used in Vista and Windows 7 - two OSes I'm yet to experience. Anyway.

The wikipedia article says that the format has a better compression, so I had to take a look at it!

Software support

That's where the problems start. The list of software that supports the format is not too long and most of the software just reads it, like IE9. IE9 doesn't run on XP, so I couldn't actually test it.

What I managed to try was:

  • a plugin for Paint.NET that read/writes JPEG-XR
  • a 60-day trial version of MS' Expression Design 3 that reads/writes - this required an upgrade of my .Net platform, so the whole process took forever on the poor XP VMWare (but hey, I have a book to finish, so no distraction is too long!)
  • a plugin for IrfanView that reads the format

Nothing for Mac though.

There's rumors all over the place that MS have a beta version of a Photoshop plugin that works on the Mac, but even the MS' press release linked to a 404. (which redirected to a bing search - here's the secret to gaining search market share!)

Actually before I digged into these programs, my first instinct was to check if ImageMagick supports this format. Turns out no. IMagick used libjpeg like pretty much all image programs out there and curiously enough here's what libjpeg's README has to say:

FILE FORMAT WARS
================

The ISO JPEG standards committee actually promotes different formats like
JPEG-2000 or JPEG-XR which are incompatible with original DCT-based JPEG
and which are based on faulty technologies.  IJG therefore does not and
will not support such momentary mistakes (see REFERENCES).
We have little or no sympathy for the promotion of these formats.  Indeed,
one of the original reasons for developing this free software was to help
force convergence on common, interoperable format standards for JPEG files.
Don't use an incompatible file format!
(In any case, our decoder will remain capable of reading existing JPEG
image files indefinitely.)

Sounds like another red flag to me. IDG (Independent JPEG Group) are the creators of libjpeg. If libjpeg doesn't sounds like it will support it JPEG-XR, that means adoption can be really slow if not feasible at all. But even if IE is the only browser under the sun that supports the format and the format is so much better, then there might be cases where it could be beneficial to browser-sniff and send different image versions, as far-fetched as that may sound.

Test in Paint.NET

I started with Paint.NET because it was the easiest. I took a photo I've taken with the iPhone, keeping the use case real, and resized to a 600x450px which sounds like a normal thing to do in a blog post for example. I used IrfanView and PNG, so that the original is lossless (click the thumb for the actual source image).

I converted the photo with Paint.NET to JPEG and to JPEG-XR (also called WDP/HD Photo). In both cases I used quality of 80%. There was also an option for WDP which was 32bit image by default, which I changed to 24 bits because the image was smaller filesize.

WDP export in Paint.NET

The results were - 45K for XR/WDP and 24K for JPEG. So the good old JPEG was smaller - the exact opposite of what should've happened. Additionally JPEGTran shaved off another 1.3K from the file. Seemed like JPEG-XR is not that good after all. But as I said I had a book to write so I kept going with the distractions, determined to avoid writing for as long as I can.

Test with Expression Design

Expression Design produced the exact same WDP/HD Photo/JPEG-XR file - 45K. And this is not surprising actually, since there is an image framework from MS, called WIC, part of .Net, which is probably what Paint.NET and Expression Design both use. But surprisingly enough the JPEG outcome from Expression Design was significantly bigger - 57K. What?!

Then I looked at the visual quality and the number of colors and it turned out the JPEGs were pretty different, although they were converted from the same PNG and using 80% in both programs.

Software/Format JPEG JPEG-XR aka WDP aka HD Photo
Paint.NET 24K (50 000+ colors) 45K (104 000+ colors)
Expression Design 57K (54 000+ colors)

Visually the JPEG from Paint.NET is clearly lower quality than the one from Expression Design and from the WDP format. Interestingly, IrfanView produced an pretty much identical file when converting the PNG to JPEG with quality 80. So Expression Design seems to be doing something differently.

Using IrfanView I increased the quality of the JPEG until the file size reaches the file size of the WDP. (After all, all I want to know is which format has the smaller filesize). The quality of 93 resulted in a JPEG that was about the same file size as quality 80 JPEG-XR. Then I tried so look at the visual quality and although I'm not a designer, it seemed to me that the two images are pretty identical and XR is maybe just a little better. But that's a little subjective.

Here's the two files for comparison. Let me know which one you think is better. In this case they are both losslessly converted to PNG, so all browsers can see the WDP.

Here's also an image diff (from ImageMagick's compare) - it shows that technically the two images are very different (the white dots are pixels with the exact same color values)

One other thing about Expression Design - when exporting WDR, it has a "transparency" checkbox ON. This results is bigger images, so make sure you turn it off when using, it makes no sense for photos.
Expression Design options

Batch conversion?

My motivation in this experiment was to see if there's a way (and a reason) to do a batch conversion of all JPEG imagery to JPEG-XR. This would be my favorite performance optimization - you run one script and wake up to a 5-10% less image bandwidth.

Looks like JPEG-XR could probably look better for the same filesize, meaning maybe a smaller filesize for the same quality. But it's not easy to decide when it comes to quality and certainly even harder for a machine (a simple batch conversion script) to tell. I was hoping that there's a way to losslessly convert to JPEG-XR. From what I can see, there isn't. JPEG-XR does have a lossless option but it creates huge files (like 250K instead of 45), so the lossless versions are not meant to be on the web. BTW, the lossless option is the same as 100 quality (which is not the same in normal JPEG, where even 100% is lossy).

So, in conclusion - JPEG-XR may look promising but is currently unusable for practical purposes, because of

  • the extremely limited support in browsers (browser, actually),
  • very limited choices of creation software
  • the benefits are hard to distinguish
  • not possible to batch-and-forget process all old JPEGs

And there's the other turn off - patents. Although Microsoft has promised to promise not to sue people around for implementing JPEG-XR, a patent is a patent and all software patents must die on general principle :)

Tell your friends about this post: Facebook, Twitter, Google+

14 Responses

  1. This is very interesting, but you did the test in the wrong direction, I think.

    Instead of starting from the image size, you shod start to the “visual quality” :
    1- Save a jpeg at an acceptable quality, enough for not revealing the typical compression artefacts. You have to do this visually.
    2- Save the same image as jpeg-xr, again with a similar acceptable quality for your eyes.
    3- compare the two file sizes. Based on the xr promises, you should see a difference in the file size.

    The idea is that xr can do a better job with lower quality settings.

    Anyway, due to the patents, I would never endorse such file format.
    (damn, it’s ten years I’m waiting for jpeg2000 to get used!)

  2. MS had a bunch of in depth posts up on one of their graphics developer blogs. I don’t have the link….but they laid out the reasoning and benefits of the format. I wonder if you actually disagree with their test cases or not.

  3. Comparing the two files:
    - The “standard” JPEG has some noticeable artifacts in some specific parts (series of dots that are lighter than they should be).
    - The JPEG-XR doesn’t have such noticeable artifacts, but the camera noise seems “bigger” (unless this is not original camera noise, but a different type of artifact in both images). It could be the result of some smoothing algorithm.

    This was a very limited test, but it seems that the focus of JPEG-XR is on digital cameras: taking big pictures, with millions of pixels, that look good (on screen and print) and don’t weight 10 MB each so that you can send them to friends by email or something. Might not be of much use for the Web.

  4. Looks like the advantages of -XR over -2000 are mostly in the algorithm’s efficiency and low memory use. Microsoft’s developer claimed, “The JPEG-2000 algorithm is considerably more complex and is not appropriate for consumer device implementation.” This was four years ago.

  5. Hmm, the article:

    Takes seriously the claims of a group that uses the expressions “based on faulty technologies”, “will not support such momentary mistakes” in official documentation.

    Believes that “quality” is an objective measure between 0 and 1 that has the same meaning across different encoders and different formats.

  6. •Better compression – JPEG XR offers improved efficiency compared to JPEG, and the type of compression artifacts are often less objectionable than the typical JPEG compression artifacts. JPEG XR offers a very wide range of compression levels, including perceptively lossless or mathematically lossless compression. Regardless of your requirements, JPEG XR probably offers a compression option that’s ideal for that scenario.

    •More image formats – JPEG XR supports 8bpc (bits per channel), 16bpc and 32bpc, as well as several special bit depth formats. Pixel values can be stored as either integers, scaled fixed point numbers or full floating point values; this provides full support for numerous high dynamic range (HDR) imaging scenarios, as well as support for wide gamut color spaces. In addition to 3-channel RGB, JPEG XR supports monochrome, CMYK and n-channel formats up to 16 independent channels. many of these formats also support an alpha channel. This wide range of image formats allows for dramatically better image quality and allows this single new file format to effectively replace many previous formats that were required for specific scenarios.

    •Advanced decoding features – JPEG XR provides progressive decoding, allowing lower resolution previews or specific cropped areas to be displayed without the need to decode the entire image. Additionally, JPEG XR images can be cropped, rotated, flipped and resized (within certain constraints) without ever needing to decode and then re-encode the image. That means these operations are much, much faster and no additional image quality is lost due to the additional encoding steps.

  7. Regarding batch conversions and something that would work on Mac/Linux, there’s the reference implementation that came along with the standard at:
    http://www.itscj.ipsj.or.jp/sc29/open/29view/29n10430att.zip
    Surprisingly enough it compiles and runs on Linux, so OSX should work too. Just run “make” and you’re good to go.
    However, it only accepts TIFF/PNM/RAW as input :(

  8. Appreciation. Sunny post! Note down further. It seems like I happen to regular visitor

  9. Top-notch story it is definitely. My teacher has been searching for this content. 1,498 Shanghai Expo Violations Nailed

  10. iphone repair portsmouth…

    [...]IE9 and JPEG-XR: first impressions / Stoyan’s phpied.com[...]…

  11. Your Q: “Let me know which one you think is better”
    Answer: plain old JPEG is better at the same filesize.
    I compared the low light portion of the two images and many more details are kept in the simple JPEG. A sort of flagstaff on the roof, at the bottom right corner, completely disappears in JPEG-XR. The rounded dots at the top of pillars on the building behind “Barnes & Noble” are still better in simple JPEG. And so on.
    Sorry MS, the XR format seems really unefficient.

  12. For me, the advantage of JPEG XR would be for archiving: it seems as taggable as TIFF, improves upon TIFF by supporting Deep Colour, and in lossless mode has a significantly smaller file size than a lossless TIFF. Plus it displays well in Internet Explorer with support for ICC colour management profiles.

    Disadvantages: lack of common support. Even Microsoft has dropped their Photoshop plugin from their website and no official news has been published about the format in over 3 years. Yet Adobe has recently adopted it in Flash, so things may be looking up.

    Windows Vista/7 can display the .wdp files natively in Windows Explorer, Windows Media Center, and Windows Live Photo Gallery, but colour management is broken for thumbnail previews at this time. Full size viewing works fine, though, and for sRGB images the problem is effectively hidden.

    I can also confirm that the old Photoshop plugin is still working beyond its official supported life with CS3, but I do not have a higher version of Photoshop to test.

  13. bardzo dobry blog, bede czytal czesciej twoje artykul, ciekawy punkt widzenia

  14. JPG image converter you can easily convert almost any image file format to JPEG/JPG. Convert image formats like: JPG, PDF, TIF, GIF, PNG, BMP, EPS, TGA, PSD, and more!

Leave a Reply