Share via

Windows Confidential: The Mystery of the Recalcitrant JPG

The wrong file extension can cause a lot of problems—especially when you make the assumption that the problem lies elsewhere.

Raymond Chen

A customer reported that their attempt to deploy company-standard wallpaper to all their employees via Group Policy was not working. The wallpaper in question was named corp.jpg, indicating that it was in the format developed by the Joint Photographic Experts Group, commonly known as JPEG.

The customer liaison did some experimenting. They found that when they replaced the company-standard wallpaper image with a different JPEG image, the new image deployed successfully. This troubleshooting step narrowed the problem significantly. The problem clearly wasn’t with deploying the Group Policy Object or with JPEG wallpapers in general. The customer had not accidentally set an “Allow only bitmapped wallpaper” policy. There was something strange about that particular JPEG image. Perhaps it was haunted?

“I compared the properties on the two JPEG images and noticed the Bit depth property was different,” reported the customer liaison. “The customer’s wallpaper image—the one we can’t get to work—has a bit depth of eight. The JPEG that I used has a bit depth of 24. Is this a bug or by design? If Windows doesn’t support 8-bit JPEGs, is this documented anywhere?”

Actually, Windows 7 is perfectly happy with wallpapers in JPEG format. There is a file size limit that is currently set at 20MB. Files greater than that size are simply rejected outright. This limit is a sanity check, so you don’t accidentally (or perhaps maliciously) set a gigabyte-sized file as your wallpaper. That would cause Windows to slow to a crawl as it decodes the file. Perhaps the customer’s image was too big? Maybe there was some problem with the file itself that caused the Windows JPEG decoder to decide that the image wasn’t valid?

CSI: Windows

The customer agreed to provide the suspect image to the product team for closer investigation. The file size was only 48KB, so the 20MB limit was not the issue. The next step in the investigation was to ask the JPEG decoder team to study the image file and determine why it was being rejected by Windows.

Perhaps the image was subtly corrupted or slightly out of specification? Perhaps it used a JPEG feature the Windows JPEG decoder doesn’t support? Perhaps there was simply a bug in the Windows JPEG decoder itself that this particular image was tripping over.

As it happens, the shell team didn’t need to call in the JPEG decoder team after all. The answer was plain to see once you had the image file. It was something the attentive reader may have noticed when the customer said they had an 8-bit JPEG. There’s no such thing as an 8-bit JPEG image. JPEG images are always 24-bit images.

What the customer had was not actually a JPEG image at all. It was a GIF file that had been renamed with the JPEG extension (GIF, short for Graphics Interchange Format, is another type of bitmap image format). That’s why the Windows JPEG decoder rejected it. It wasn’t a JPEG at all.

At this point, the guidance for the customer was simple. They needed to take the GIF file and convert it to either BMP or the real JPEG format. Those are the two image formats that Windows 7 supports for wallpapers. When they converted the file, they had to remember to give it the correct file extension.

So, when you’re having trouble with a JPEG image, it helps to verify that what you have really is a JPEG image in the first place.

Don Jones

Raymond Chen's* Web site, The Old New Thing, and identically-titled book (Addison-Wesley, 2007) deals with Windows history, Win32 programming, and 9,925-BTU portable stoves.*