File format

JPG - JPEG Image

JPG is the compressed image format that almost every camera, phone and website uses for photographs. You meet it whenever you take, download or attach a picture.

A JPG file is a photograph stored using JPEG compression. JPEG is a standard published by the Joint Photographic Experts Group, a committee set up by the international standards bodies ISO and ITU, and it became the default way to keep photographs almost everywhere: cameras, phones, websites and email attachments. The extension is written both .jpg and .jpeg, and they are the same thing. The three-letter version only exists because older versions of Windows allowed no more than three characters.

Strictly speaking, JPEG is the compression method and the file wrapped around it is a container, either JFIF or, when a camera wrote it, an Exif file. In practice every viewer treats them all as a JPG, and so does a metadata report.

How a JPG stores its picture

JPEG is lossy, which means it throws information away in order to make the file smaller. It splits the image into small blocks, describes each block as a set of frequency values, then rounds those values off: coarsely for the fine detail your eye barely registers, gently for the broad shapes it does. The quality slider in your editor controls how coarse that rounding is. Most JPGs also store colour at half the resolution of brightness, because human vision notices changes in brightness far more than changes in colour.

Two consequences matter in daily use. Detail that has been discarded cannot come back, so every re-save loses a little more, and editing the same JPG over and over leaves blocky smudges around edges and text. And JPEG has no transparency: there is no way to mark a pixel as see-through, so a logo saved as a JPG arrives with a solid background.

What metadata a JPG carries

Metadata is the information about the picture that travels inside the file alongside the pixels. JPEG keeps it in labelled segments near the start of the file, and one photo often carries several different metadata standards at once.

  • EXIF, the Exchangeable Image File Format, is what a camera or phone writes. Expect Make and Model, DateTimeOriginal, ExposureTime, FNumber, ISOSpeedRatings, FocalLength, Flash, LensModel, Software and Orientation, the flag that tells a viewer to rotate the picture.
  • GPS tags are part of EXIF but sit in a group of their own: GPSLatitude, GPSLongitude, GPSAltitude and a timestamp in UTC. Together they say where the photo was taken, often to within a few metres.
  • IPTC is the older publishing standard used in news and stock photography, with fields such as By-line, Caption, Keywords, City, Country and Credit.
  • XMP is Adobe's newer scheme, stored as a block of XML text. It holds creator, title, description, keywords, star ratings and colour labels, and frequently an edit history naming the programs that touched the file.
  • An ICC colour profile may be embedded to describe how the stored numbers map to real colours.
  • A thumbnail is usually included as well, as a tiny separate JPEG.

Several of those fields are personal. GPS coordinates can point straight at your home. Make, Model and, on some cameras, a body or lens serial number identify your equipment, while Artist, Copyright, an owner name and the XMP creator field can carry your own name. The embedded thumbnail deserves a special mention: some editors update the main image and leave the old thumbnail untouched, so a cropped photo can still contain a small copy of what was cropped out.

When to use JPG

JPG is the right choice for photographs that people need to view, send or publish. Continuous-tone images with soft gradients are exactly what the compression was designed for, so a little discarded detail stays invisible while the size saving is enormous. It is the wrong choice for screenshots, line art, diagrams and anything containing text, because hard edges are what JPEG handles worst, and for anything that needs a transparent background.

The obvious alternative is PNG, which keeps every pixel and supports transparency, but which produces much larger files for photographs. If you are editing, keep a lossless master such as a PNG, a TIFF or the raw file from the camera, and export a JPG only at the end.