.JPG JPEG Image
.jpg

JPEG Image

JPEG’s “quality 85” does not mean 85% of the original — it scales a quantization table that divides DCT frequency coefficients, and every encoder uses a different scale. Convert JPG to PNG, WebP, or BMP in your browser with FileDex — no upload, no server, full privacy.

Learn more ↓
Image structure
SOI FF D8 marker
APP1 EXIF · GPS
SOS DCT coefficients
LossyMetadataISO 109181992
By FileDex

Your files never leave your device

Common questions

Why does my JPEG quality degrade every time I save it?

Each save re-applies DCT quantization to the current pixel data, discarding more information with every round. Even at quality 95, re-saving a JPEG 5-10 times produces visible banding and 8x8 blocking artifacts. Work in a lossless format (PNG, TIFF, PSD) and export to JPEG only as the final step.

What JPEG quality setting should I use for web images?

Quality 80-85 is the standard recommendation for web photography. At this range, files are 40-60% smaller than quality 100 with differences imperceptible to most viewers. Quality 90-95 suits print masters. Below 60, DCT blocking artifacts become clearly visible.

How do I strip GPS location data from a JPEG before sharing?

Run exiftool -gps:all= -overwrite_original photo.jpg to remove only GPS fields, or exiftool -all= to strip all metadata. FileDex also strips EXIF automatically during conversion. iOS 13+ has a built-in option to remove location data when sharing from Photos.

Is there any difference between .jpg and .jpeg file extensions?

No technical difference exists. The .jpg extension originated from the MS-DOS 8.3 filename limit that could not accommodate the four-character .jpeg extension. Both map to the same image/jpeg MIME type. Modern systems accept either.

Can I convert JPEG to PNG without losing quality?

Yes. JPEG-to-PNG conversion decodes the JPEG pixel data and stores it losslessly via DEFLATE. No additional quality loss occurs during the conversion itself. The PNG output preserves exactly what the JPEG decoder produced, but cannot recover detail already discarded during JPEG encoding.

Why do my JPEG photos look different on iPhone vs. PC?

iPhones encode photos with a wide color gamut (Display P3) color profile. Windows applications that do not support color profiles interpret the raw RGB values assuming sRGB, causing photos to look oversaturated. The solution is to change the color profile to sRGB before sharing: in Photoshop, go to Edit, then choose the profile-conversion option, and select sRGB IEC61966-2.1. Image editing tools with color management support can also perform this profile change.

What is progressive JPEG and when should I use it?

A progressive JPEG stores the image in multiple scans — the first scan contains a low-quality version of the entire image, and subsequent scans add refinement. This means the browser can display a blurry-but-complete image immediately, then sharpen progressively as more data arrives. Use progressive JPEG for images above 10 KB on the web. Most image editors and export tools offer a progressive or interlace option when saving JPEG files.

What makes .JPG special

Since 1992
2 trillion new files per year
Standardized in 1992 as ISO 10918-1, JPEG accounts for an estimated 2 trillion new files annually. Every camera and phone outputs JPG.
Privacy risk
EXIF stores your GPS coordinates
Smartphones embed precise GPS location, device model, and timestamps in every photo. Sharing unstripped JPGs can expose your exact location.
8x8 blocks
DCT divides images into 64-pixel tiles
Each 8x8 block is transformed independently via Discrete Cosine Transform. This is why low-quality JPGs show visible square artifacts.
Quality sweet spot
Quality 85 looks like quality 100
JPEG quality 85 and 100 are visually identical on small screens, but quality 85 produces files 40-60% smaller. The perceptual return above 85 is negligible.

JPEG stores photographic images through lossy compression built on the Discrete Cosine Transform, achieving 10:1 to 20:1 size reduction with minimal visible degradation. The .jpg and .jpeg extensions are identical — the shorter form exists because MS-DOS and Windows 3.1 enforced three-character extensions. Published in 1992 as ISO/IEC 10918-1 by the Joint Photographic Experts Group, the format accounts for an estimated 2 trillion new files per year.

Continue reading — full technical deep dive

The Compression Pipeline

JPEG compression runs through five sequential stages. Each stage targets a different perceptual redundancy in human vision.

Color space conversion transforms RGB triplets into YCbCr: one luminance channel (Y) carrying brightness, and two chrominance channels (Cb, Cr) carrying color difference signals. Human eyes resolve spatial detail in brightness roughly four times better than in color, so separating these channels creates an immediate optimization target.

Chroma subsampling exploits that gap. In 4:2:0 mode — the default for most cameras and encoders — each chrominance channel is downsampled by 2x in both dimensions. Four luminance samples share a single Cb and a single Cr value. This alone cuts raw data by 50% with almost no perceptible change in photographs. 4:2:2 subsamples horizontally only, preserving vertical color edges — useful for text overlaid on photos. 4:4:4 keeps full chrominance resolution, used in medical imaging and professional color grading where any chroma loss is unacceptable.

8x8 block splitting divides each channel into non-overlapping blocks of 64 pixels. Every block is processed independently. This is fast but creates the characteristic "blockiness" visible at low quality settings — adjacent blocks have no shared context.

Discrete Cosine Transform converts each 8x8 block from spatial pixel values into 64 frequency coefficients. The DC coefficient (position 0,0) stores average block brightness. The remaining 63 AC coefficients represent increasing spatial frequencies — low frequencies capture gradual tonal shifts, high frequencies capture sharp edges and fine texture. Most photographic content concentrates energy in the low-frequency coefficients.

Quantization is where data is permanently discarded. Each DCT coefficient is divided by a value from a quantization table and rounded to the nearest integer. High-frequency coefficients get divided by larger numbers, often rounding to zero entirely. The encoder then zigzag-scans the 64 values (low frequency to high), run-length encodes the resulting zero runs, and applies Huffman coding to the output. Arithmetic coding is an alternative entropy coder that produces files 5-10% smaller, but it saw limited adoption for decades due to Unisys and IBM patent claims. Modern encoders like MozJPEG support it freely.

Quality Factor and Quantization Tables

The "quality" slider in image editors scales the quantization table. At quality 100, divisors are small and almost no data is lost — but files are 5-8x larger than quality 85. At quality 50, divisors are aggressive and high-frequency detail vanishes. The relationship is nonlinear.

A 12-megapixel photo (4000x3000) at quality 95 produces roughly 8-12 MB. The same image at quality 85 drops to 2-4 MB. At quality 50, it falls to 500 KB-1 MB. JPEG quality 85 and quality 95 look identical on screens below 6 inches but the file size doubles. This makes quality 80-85 the standard choice for web delivery — the perceptual return above that threshold doesn't justify the bandwidth cost.

Progressive vs Baseline Scan Modes

Baseline JPEG encodes blocks top-to-bottom, left-to-right in a single pass. The image renders line by line as bytes arrive. Progressive JPEG encodes multiple scans: the first pass contains only the DC coefficients (a blurry thumbnail of the full image), and subsequent passes add AC coefficients in bands, sharpening the image incrementally. On slow connections, progressive files appear to "fade in" from blurry to sharp rather than painting downward.

Progressive files are typically 2-6% smaller than baseline at the same quality because Huffman tables span the entire image rather than a single scan. MozJPEG defaults to progressive encoding for this reason.

File Structure and Markers

Every JPEG begins with FF D8 (Start of Image) and ends with FF D9 (End of Image). Between those markers sit segments identified by two-byte codes:

  • APP0 (FF E0) — JFIF header with version, resolution, and optional thumbnail
  • APP1 (FF E1) — EXIF metadata block (camera settings, GPS, timestamps) and XMP data
  • DQT (FF DB) — Quantization tables
  • SOF0 (FF C0) — Start of Frame (baseline) with image dimensions, component count, subsampling factors
  • DHT (FF C4) — Huffman tables
  • SOS (FF DA) — Start of Scan, followed by entropy-coded image data

EXIF Metadata and Privacy

Digital cameras and smartphones embed EXIF data in the APP1 segment: camera model, lens, ISO, aperture, shutter speed, focal length, timestamp, orientation flag, and — critically — GPS coordinates accurate to a few meters. Sharing an unstripped JPEG from a phone can expose your exact location.

Strip all metadata before publishing: exiftool -all= -overwrite_original photo.jpg. Social media platforms strip EXIF on upload, but email attachments, direct file shares, and many CMS platforms preserve it.

Artifacts and Degradation

Three artifact types are characteristic of JPEG:

Blocking artifacts appear as visible 8x8 grid patterns in smooth gradients, most obvious at quality settings below 60. Mosquito noise creates shimmering halos around high-contrast edges — dark text on white backgrounds shows this clearly. Color bleeding occurs at sharp chrominance boundaries when chroma subsampling smears color across the edge.

Re-encoding a JPEG applies quantization again. Each save cycle degrades quality further, even at quality 100, because rounding errors accumulate. Edit in a lossless format (TIFF, PNG) and export to JPEG only as the final step. For lossless operations on existing JPEGs — rotation, cropping on 8x8 boundaries, metadata editing — use jpegtran or MozJPEG's jpegtran fork, which manipulate DCT coefficients directly without re-quantization.

When to Use JPEG vs Alternatives

Scenario Best Format Reason
Photographs for web JPEG or WebP Lossy compression excels on continuous tone
Photographs with transparency WebP or AVIF JPEG has no alpha channel
Screenshots, text, diagrams PNG Sharp edges cause JPEG artifacts
Vector graphics SVG Resolution-independent, tiny files
Next-gen photo delivery AVIF 30-50% smaller than JPEG at equivalent quality
Maximum compatibility JPEG Every browser, device, and OS since the 1990s

AVIF outperforms JPEG on compression efficiency, but browser support reached full coverage only in 2024. WebP is a strong middle ground — lossy and lossless modes, transparency, animation — with universal browser support since 2023. JPEG remains the safe default when compatibility with legacy systems, email clients, or print workflows matters.

Optimization Tools

MozJPEG re-encodes JPEGs with optimized Huffman tables, trellis quantization, and progressive scanning. Typical savings: 5-15% file size reduction at the same visual quality. jpegtran performs lossless transformations — rotation, crop, progressive conversion — without touching pixel data. Guetzli (Google) produces files 20-30% smaller than libjpeg but encoding is extremely slow (minutes per image). For batch web optimization, MozJPEG with quality 80-85 and progressive mode hits the best balance of speed, size, and quality.

.JPG compared to alternatives

.JPG compared to alternative formats
Formats Criteria Winner
.JPG vs .PNG
Compression efficiency for photographs
JPEG achieves 10-20x compression ratios for photographic content via DCT. PNG DEFLATE produces 2-5x larger files for photos because lossless compression cannot discard perceptual redundancy.
JPG wins
.JPG vs .WEBP
File size at equivalent visual quality
WebP produces 25-34% smaller files than JPEG at matched SSIM scores. VP8 block prediction is more efficient than JPEG DCT for natural images.
WEBP wins
.JPG vs .HEIC
Compression ratio and feature set
HEIC delivers 40-50% size reduction over JPEG and supports 10-bit HDR, wide gamut, and multi-image sequences. JPEG wins on universal device compatibility.
HEIC wins
.JPG vs .AVIF
Modern web delivery efficiency
AVIF AV1 achieves ~50% smaller files than JPEG with 10/12-bit depth and HDR support. AVIF is royalty-free, unlike HEIC. Browser support covers Chrome, Firefox, and Safari 16+.
AVIF wins

Technical reference

MIME Type
image/jpeg
Magic Bytes
FF D8 FF JPEG SOI marker. Identical format to .jpeg.
Developer
Joint Photographic Experts Group
Year Introduced
1992
Open Standard
Yes — View specification
00000000FFD8FF ...

JPEG SOI marker. Identical format to .jpeg.

Binary Structure

JPEG uses a marker-based sequential structure. Every segment begins with a two-byte marker (FF xx). The file opens with SOI (FF D8), followed by application segments (APP0/APP1 for JFIF/EXIF metadata), quantization tables (DQT, FF DB), frame header (SOF0/SOF2 for baseline/progressive), Huffman tables (DHT, FF C4), and scan data (SOS, FF DA). Compressed DCT coefficient data follows SOS with byte-stuffing (FF 00 escapes literal 0xFF). The file terminates with EOI (FF D9). JPEG has no index or table of contents — parsers must walk markers sequentially.

OffsetLengthFieldExampleDescription
0x00 2 bytes SOI FF D8 Start of Image marker. Universal JPEG signature.
0x02 2 bytes APP0/APP1 marker FF E0 or FF E1 JFIF (APP0) or EXIF (APP1) application segment identifier.
0x04 2 bytes Segment length 00 10 Big-endian uint16 — byte count of segment data including this field.
0x06 5 bytes JFIF identifier 4A 46 49 46 00 ASCII 'JFIF' + null terminator. Present only in JFIF-wrapped JPEGs.
variable 2 bytes DQT marker FF DB Quantization table segment. Contains 64 values controlling compression quality.
variable 2 bytes SOF0/SOF2 marker FF C0 or FF C2 Start of Frame — baseline (C0) or progressive (C2). Contains image dimensions.
variable 2 bytes SOS marker FF DA Start of Scan. Compressed image data follows immediately after scan header.
EOF-2 2 bytes EOI FF D9 End of Image marker. Signals end of JPEG data stream.
1986Joint Photographic Experts Group (JPEG) committee formed under ISO/IEC JTC 11992JPEG standard released as ITU-T T.81; JFIF container published by C-Cube Microsystems1994ISO/IEC 10918-1 ratified; JPEG becomes the dominant photo format on the early web1996EXIF standard published by JEIDA/CIPA, enabling camera metadata in JPEG files2000JPEG 2000 (ISO 15444) published as wavelet-based successor; never displaced baseline JPEG2010Google releases WebP targeting JPEG replacement in web delivery2017Apple adopts HEIC as default iPhone camera format, the first mainstream JPEG challenger2019AVIF ratified by Alliance for Open Media as royalty-free JPEG successor2022JPEG XL (ISO 18181) published with lossless recompression of existing JPEG files
Convert JPEG to PNG (lossless) ffmpeg
ffmpeg -i input.jpg -vf format=rgba output.png

Decodes JPEG and encodes to lossless PNG with RGBA pixel format. The alpha channel is set to fully opaque. Use format=rgb24 to omit the alpha channel.

Convert JPEG to WebP at quality 82 ffmpeg
ffmpeg -i input.jpg -c:v libwebp -quality 82 -compression_level 6 output.webp

Encodes to lossy WebP using libwebp. Quality 82 on WebP is perceptually equivalent to JPEG quality ~88 with 25-35% smaller output. Compression level 6 is maximum effort for smallest file size.

Strip all EXIF metadata from JPEG exiftool
exiftool -all= -overwrite_original photo.jpg

Removes all EXIF, XMP, IPTC, and GPS metadata without re-encoding image data. Pixel data stays unchanged; file size decreases by the metadata block size.

Optimize JPEG for web with ImageMagick imagemagick
magick input.jpg -quality 82 -sampling-factor 4:2:0 -strip -interlace JPEG output.jpg

Re-encodes JPEG at quality 82 with 4:2:0 chroma subsampling, stripped metadata, and progressive scan ordering. This is the standard web optimization pipeline producing ~40% smaller files.

Inspect JPEG markers and EXIF data (Python) other
import sys, struct

MARKERS = {
    0xD8: 'SOI (Start of Image)',
    0xD9: 'EOI (End of Image)',
    0xE0: 'APP0 (JFIF)',
    0xE1: 'APP1 (EXIF / XMP)',
    0xE2: 'APP2 (ICC Profile)',
    0xEE: 'APP14 (Adobe CMYK flag)',
    0xDB: 'DQT (Quantization Table)',
    0xC0: 'SOF0 (Baseline DCT)',
    0xC2: 'SOF2 (Progressive DCT)',
    0xC4: 'DHT (Huffman Table)',
    0xDA: 'SOS (Start of Scan)',
}

with open(sys.argv[1], 'rb') as f:
    soi = f.read(2)
    if soi != b'\xFF\xD8':
        print('Not a JPEG file')
        sys.exit(1)
    print(f'SOI marker: {soi.hex().upper()}')
    while True:
        byte = f.read(1)
        if not byte:
            break
        if byte == b'\xFF':
            marker_byte = f.read(1)
            if not marker_byte:
                break
            marker = marker_byte[0]
            if marker in (0xD8, 0xD9):
                print(f'  FF {marker:02X} — {MARKERS.get(marker, "Unknown")}')
                if marker == 0xD9:
                    break
            elif marker != 0x00:
                length_bytes = f.read(2)
                if len(length_bytes) < 2:
                    break
                length = struct.unpack('>H', length_bytes)[0]
                name = MARKERS.get(marker, f'Unknown ({marker:02X})')
                print(f'  FF {marker:02X} — {name} ({length} bytes)')
                f.seek(length - 2, 1)

Walk all JPEG segment markers in sequence, printing their type and byte length. Identifies JFIF/EXIF/ICC/Adobe markers, quantization tables, and scan data.

JPG PNG transcode lossless PNG preserves decoded pixel values with lossless DEFLATE compression and adds alpha channel support. Ideal for images entering further editing pipelines where repeated lossy saves would degrade quality.
JPG WEBP transcode lossy WebP VP8 achieves 25-34% smaller files than JPEG at equivalent SSIM due to more efficient block prediction and adaptive quantization. Reduces bandwidth costs for web image delivery.
JPG BMP transcode lossless BMP stores raw uncompressed pixel data for legacy Windows applications, embedded systems, and CNC hardware that cannot decode compressed formats.
JPG AVIF transcode lossy AVIF AV1 intra-frame encoding delivers 50%+ file size reduction over JPEG with support for 10/12-bit HDR and wide gamut. Best option for next-generation web image delivery.
MEDIUM

Attack Vectors

  • EXIF GPS metadata privacy leak
  • ImageMagick Shell Injection (ImageTragick)
  • Android Stagefright JPEG heap overflow
  • libjpeg-turbo SOF marker out-of-bounds write
  • JPEG/ZIP polyglot file upload bypass

Mitigation: FileDex processes JPEG files entirely in the browser using Canvas API. No server upload occurs. EXIF metadata is stripped during conversion. The browser sandbox isolates all decoding from system resources, preventing exploitation of codec vulnerabilities.

Industry-standard raster image editor with full JPEG support
GIMP tool
Free open-source image editor with JPEG import/export
libjpeg-turbo library
SIMD-accelerated JPEG codec used by Chrome, Firefox, and most Linux distros
CLI image processor supporting 200+ formats including JPEG
ExifTool tool
Read/write EXIF, XMP, IPTC metadata in JPEG and other formats
MozJPEG library
Mozilla's optimized JPEG encoder producing 5-10% smaller files than libjpeg