ScreenshotNeo

BlogEngineering

JPEG XL Modular Mode Explained

Learn how JPEG XL Modular predicts and codes image data, when it can be lossless or lossy, and how it differs from VarDCT.

By the ScreenshotNeo team4 October 20266 min read

JPEG XL Modular is an image-coding mode that predicts integer sample values, codes the differences from those predictions, and can apply reversible transforms to make the data easier to compress. It supports both lossless and lossy coding. It is not simply “the lossless mode”: JPEG XL also uses Modular sub-bitstreams for some auxiliary data within VarDCT-coded images.

Use Modular when its coding tools and encoder settings suit the image and fidelity target. The mode alone does not guarantee a smaller file than VarDCT or another format. Compare representative images at the required quality, with the encoder version and settings recorded.

1. What Modular Mode does

At a high level, Modular treats image samples as integer data. It predicts values from nearby or related data, then encodes residuals: the differences between predictions and actual values. Context-dependent models and entropy coding represent those residuals compactly. This is a useful mental model, not a complete normative description of the bitstream.

Before coding, Modular can apply reversible transforms that reshape the data while preserving the decoded samples. The libjxl format overview describes reversible color transforms, palette transforms, and Squeeze, a modified nonlinear Haar-like transform that supports progressive decoding. Whether a transform helps depends on the image and encoder choices.

2. Lossless and lossy are both possible

In lossless use, decoding can recover the original sample values exactly under the chosen encoding conditions. The libjxl format overview explains that Modular uses integer arithmetic, which enables lossless compression. Modular can also be used in lossy coding; selecting Modular does not by itself promise exact recovery.

Lossless means fidelity, not a guaranteed size reduction. A lossless Modular file may be larger than a lossy encode, or larger than another lossless representation. If the goal is exact sample recovery, verify the encoder’s lossless settings and validate decoded output with a pixel or hash comparison appropriate to the image representation.

3. Modular compared with VarDCT

Property Modular VarDCT
Core approach Integer-domain prediction, residual coding, and transforms Variable-sized DCT transforms for image data
Lossless capability Supports mathematically lossless coding, as well as lossy use Generally lossy as an image mode; has a restricted case for losslessly representing an existing JPEG
Relationship in a codestream Can code the primary image data or auxiliary data Can use Modular sub-bitstreams for data such as low-frequency image information, extra channels such as alpha, and adaptive-quantization weights
Which is smaller or faster? There is no universal winner established by the sources reviewed. Results depend on image, target fidelity, encoder version, settings, and implementation.

These are distinct coding approaches, but not mutually exclusive pieces of the overall format. In particular, the presence of Modular data in a VarDCT stream does not mean the primary image data was encoded in Modular mode.

4. How to compare encodes fairly

  1. Choose representative source images and record their dimensions, color mode, bit depth, and alpha-channel needs.
  2. Set the same required outcome for each candidate: exact sample recovery for a lossless task, or a defined visual-fidelity target for a lossy task.
  3. Record the encoder implementation, version, and all relevant options. Avoid comparing defaults from different versions as if they were equivalent settings.
  4. Encode each image in the modes you want to evaluate. Keep the input, color handling, metadata policy, and target fidelity consistent.
  5. Decode the files and check correctness. For lossless results, compare decoded samples to the source; for lossy results, use a consistent visual review or metric suitable for your use case.
  6. Measure output size and encode/decode time on the same hardware and software setup. Report the image set and settings alongside results.

The reviewed sources do not provide a universal Modular-versus-VarDCT benchmark table or a Modular-specific compression statistic suitable for generalizing across images. Avoid presenting a result from one image as a mode-wide rule.

5. Practical questions and edge cases

Does Modular always preserve the original?

No. Modular supports lossless coding, but it can also be used lossily. Confirm the actual encoder configuration and test the decoded output when exactness matters.

Does lossless mean smaller?

No. It means exact recovery, not a size guarantee. Image content and coding settings determine the result.

Does a JPEG XL file using Modular mean it was encoded wholly in Modular?

Not necessarily. VarDCT can contain Modular sub-bitstreams for auxiliary image-like data, including extra channels and other information.

Should I pick Modular for screenshots, illustrations, paintings, or photographs?

Do not decide from the content label alone. Test the images you actually need to store or serve, at the required fidelity, with the encoder and version you will deploy. The available sources establish the tools and mode capabilities, not a universal content-type winner.

What should I preserve for reproducibility?

Keep the original input, encoder name and version, mode and quality or lossless settings, color and metadata handling, and the command or configuration used. This makes later size or fidelity comparisons interpretable.

6. Troubleshooting encoding evaluations

Symptom Likely cause What to check
Decoded pixels differ from the source The encode was lossy, or the comparison included a color, metadata, or sample-representation conversion Check lossless settings and compare decoded samples in the same color and channel representation.
The Modular file is larger Lossless coding preserves detail, and compression effectiveness depends on the data and settings Confirm both files target equivalent fidelity and compare a representative image set.
Two runs produce different sizes Encoder version, options, input preprocessing, or metadata handling changed Record and pin these inputs before drawing conclusions.
A file contains Modular data, but mode inspection suggests VarDCT Modular may be present in auxiliary sub-bitstreams of a VarDCT codestream Distinguish the primary image coding mode from auxiliary data coding.
A transform does not improve size Transforms are tools whose effectiveness depends on the image and encoder choices Compare controlled outputs; do not assume every reversible transform helps every source.

7. Capturing images for codec evaluation

If the images being evaluated are web pages, capture the same page state and viewport each time before comparing image encodes. A changing banner, animation, lazy-loaded image, or responsive layout can invalidate a comparison. ScreenshotNeo is a website screenshot API and MCP server by Yorker Media. Its options include viewport and device presets, full-page capture with lazy images loaded, element capture, waiting for a selector or network idle, custom CSS and JavaScript, and PNG, JPEG, WebP, or PDF output. See ScreenshotNeo and its API documentation.

Or skip the browser setup

One GET request captures a page; this example saves the response body as a WebP file. See the ScreenshotNeo docs for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
const bytes = new Uint8Array(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', bytes));

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits cost nothing, and response headers say the page verdict and whether it was billed. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.

8. FAQ

Is Modular the same as a palette codec?

No. Palette coding is one reversible transform available within Modular; it is not the whole mode.

Does Squeeze make every Modular image progressive?

Squeeze supports progressive decoding, but its presence does not mean every image or encode uses that behavior.

Can I infer the encoder settings from the word “Modular” alone?

No. The mode name does not specify whether the encode was lossless, which transforms were used, or the encoder’s quality and other settings.

Sources