Understanding JPG: The Universal Photo Format
JPG is the most widely used image format in the world. Every digital camera, every smartphone, every web browser, and every image editor supports it. When you take a photo on your phone, share an image on social media, or download a picture from the web, there is a very high chance it is a JPG file.
The format has been around since 1992 and despite being over 30 years old, it remains the default choice for photographic images. Understanding how JPG works helps you make better decisions about quality settings, file sizes, and when to use alternatives like WebP or AVIF.
What Is JPG (and JPEG)?
JPG and JPEG are the same format. JPEG stands for Joint Photographic Experts Group, the committee that created the standard. The .jpg file extension became common because early versions of Windows limited file extensions to three characters. Modern systems accept both .jpg and .jpeg interchangeably.
JPEG is a lossy compression standard designed specifically for continuous-tone photographic images. Unlike PNG, which preserves every pixel, JPEG achieves dramatically smaller files by discarding visual information that the human eye is less likely to notice. The result is a photograph that looks nearly identical to the original at a fraction of the file size.
How DCT Compression Works
JPEG compression is built on the Discrete Cosine Transform (DCT), a mathematical technique that converts spatial pixel data into frequency components. The process works in several stages.
First, the image is divided into 8x8 pixel blocks. Each block is transformed from pixel values into 64 frequency coefficients using DCT. Low-frequency coefficients represent gradual color changes (the overall tone of the block), while high-frequency coefficients represent sharp edges and fine detail.
The key insight is that human vision is much more sensitive to low-frequency information than high-frequency detail. JPEG's quantization step divides each frequency coefficient by a quantization factor (controlled by the quality setting), rounding the result. High-frequency coefficients get divided by larger numbers, often rounding to zero. This is where data is permanently discarded, and it is why JPEG compression is lossy.
Finally, the quantized coefficients are compressed using Huffman coding (or arithmetic coding in some implementations), producing the final compressed data stream.
Quality vs File Size: Finding the Sweet Spot
Most image editors let you choose a quality level from 0 to 100 when saving a JPG. This quality number controls the quantization tables, which determine how aggressively high-frequency data is discarded.
Quality 100 is not lossless. Even at the maximum setting, JPEG still applies some lossy compression. The difference between quality 95 and 100 is often imperceptible to the eye but can double the file size. For web use, quality 80-85 is widely considered the sweet spot: files are 60-70% smaller than quality 100 with minimal visible degradation.
Below quality 50, compression artifacts become increasingly visible. Smooth gradients develop banding, sharp edges show ringing artifacts, and fine text becomes blurry. For most photographic content, there is no reason to go below quality 60.
EXIF Metadata: The Hidden Data in Your Photos
JPG files can carry extensive EXIF (Exchangeable Image File Format) metadata embedded by the camera. This includes the camera model, lens focal length, aperture, shutter speed, ISO, GPS coordinates, date and time, and even the orientation of the camera when the photo was taken.
EXIF data is useful for photographers organizing their collections, but it raises privacy concerns. A casual photo shared online can reveal the exact GPS coordinates where it was taken. Many social media platforms strip EXIF data on upload, but not all do. If privacy matters, consider stripping EXIF data before sharing photos publicly.
EXIF metadata typically adds 10-100KB to a JPG file. For web optimization, stripping EXIF data can provide meaningful savings, especially for thumbnails and small images where 50KB of metadata might exceed the size of the actual image data.
Progressive vs Baseline JPEG
JPEG files come in two flavors: baseline and progressive. A baseline JPEG loads from top to bottom, one line at a time. A progressive JPEG loads in multiple passes, starting with a low-quality full-image preview that sharpens with each subsequent pass.
Progressive JPEGs have several practical advantages for the web. They give users a meaningful preview before the full image loads (similar to PNG interlacing). They are typically 2-10% smaller than baseline JPEGs for images over 10KB. And they provide a better perceived loading experience on slower connections.
Most modern web optimization tools output progressive JPEGs by default. There is rarely a reason to use baseline encoding for web delivery.
Chroma Subsampling: The Invisible Trick
Before DCT compression even starts, most JPEG encoders apply chroma subsampling. The image is converted from RGB to YCbCr color space (luminance + two chrominance channels). Because human vision is far more sensitive to brightness than to color, the chrominance channels are stored at half resolution.
The most common scheme is 4:2:0, which stores color at one quarter the resolution of brightness. This alone cuts file size by about 50% with virtually no perceptible impact on photographs. The effect is only visible in images with sharp color edges (like red text on a white background), which is one reason PNG is preferred for graphics with text.
If you need to preserve sharp color transitions, look for a 4:4:4 chroma subsampling option in your image editor. This retains full color resolution at the cost of larger files.
Common JPG Artifacts
Knowing what compression artifacts look like helps you choose the right quality setting for your images.
- Blocking artifacts. The 8x8 pixel blocks that JPEG processes become visible at low quality settings, giving the image a "tiled" appearance. Most noticeable in smooth gradients and solid color areas.
- Mosquito noise. Bright sparkling patterns that appear near sharp edges, especially where a dark object meets a light background. Named because the artifacts seem to "buzz" around edges.
- Color bleeding. At very low quality, chroma subsampling combined with aggressive quantization causes colors to bleed across sharp boundaries. Red text on a white background is a classic example.
- Banding. Smooth gradients (like a sunset sky) develop visible steps or bands instead of continuous tonal transitions. This happens when the quantization step is too coarse to represent subtle differences.
When to Use JPG vs Alternatives
JPG remains the right choice for photographs when universal compatibility is important. Every device, every browser, every email client, and every social media platform supports JPG without exception.
Consider WebP when you need smaller files and are targeting modern web browsers. WebP produces files 25-35% smaller than JPG at equivalent quality. AVIF goes further with roughly 50% size savings over JPG. Both formats have reached near-universal browser support in 2026.
Use PNG instead of JPG when you need transparency, pixel-perfect text rendering, or lossless quality for screenshots and graphics. JPG should never be used for images with sharp text, logos with flat colors, or any image that will be edited and re-saved multiple times.
Frequently Asked Questions
Is there a difference between JPG and JPEG?
No. JPG and JPEG refer to the same format. The .jpg extension exists because early Windows versions limited file extensions to three characters. Modern systems treat .jpg and .jpeg identically. The official format name is JPEG (Joint Photographic Experts Group).
What quality setting should I use for web images?
Quality 80-85 is the widely accepted sweet spot for web photographs. It produces files 60-70% smaller than quality 100 with minimal visible degradation. For thumbnails and less critical images, quality 70 works well. Below 60, artifacts become increasingly noticeable.
Does re-saving a JPG reduce quality?
Yes. Each time you open a JPG, edit it, and save it again, another round of lossy compression is applied. Quality degrades with each save cycle, a process sometimes called generation loss. If you need to edit an image multiple times, keep a lossless source (PNG or TIFF) and export to JPG only as the final step.
Can JPG metadata reveal my location?
Yes. If your camera or phone has GPS enabled, JPG files can contain exact latitude and longitude coordinates in their EXIF metadata. This data persists unless explicitly stripped. Many social media platforms remove EXIF on upload, but sharing JPG files directly (via email, messaging apps, or file sharing) preserves the original metadata.