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.
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
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
| 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 |
Convert .JPG to...
Technical reference
- MIME Type
image/jpeg- Magic Bytes
FF D8 FFJPEG SOI marker. Identical format to .jpeg.- Developer
- Joint Photographic Experts Group
- Year Introduced
- 1992
- Open Standard
- Yes — View specification
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.
| Offset | Length | Field | Example | Description |
|---|---|---|---|---|
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. |
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.
- Specification ISO 10918-1:1994 / ITU-T T.81 — JPEG Compression Standard
- Specification JFIF 1.02 — JPEG File Interchange Format
- Specification Exif 2.32 — Exchangeable Image File Format (CIPA DC-008)
- Registry JFIF — JPEG File Interchange Format (fdd000018) — Library of Congress
- Registry image/jpeg — IANA Media Types
- Registry JPEG/JFIF 1.02 (fmt/44) — The National Archives PRONOM Registry
- History JPEG — Wikipedia