Decode JPEG XR Images to BMP, PNM or TIFF with JxrDecApp

JxrDecApp turns a JPEG XR or HD Photo file into a BMP, PNM or TIFF you can actually open. This guide also covers previews, cropped regions, pixel-format quirks, and replacing an existing result only after a successful decode.

Allow about fifteen minutes. You need a readable .jxr or .wdp file and the libjxr-tools package. The examples use JxrDecApp 1.2~git20170615.f752187, installed here as package version 1.2~git20170615.f752187-5.1ubuntu2. Decoding an image normally needs no elevated privileges. Use sudo only if your input or destination directory genuinely requires it.

1. Check the installed command

Start by confirming which executable will run. This is a read-only check:

$ command -v JxrDecApp
/usr/bin/JxrDecApp
$ dpkg-query -W -f='${Package} ${Version}\n' libjxr-tools
libjxr-tools 1.2~git20170615.f752187-5.1ubuntu2

Ask the program for its built-in help as well. The installed utility documents the input with -i and the output with -o:

$ JxrDecApp -h
JPEG XR Decoder Utility
...
  -i input.jxr/wdp             Input JPEG XR/HD Photo file name
  -o output.bmp/pnm/tif/jxr    Output image file name

The help text is longer than the excerpt above. The option spelling and supported output suffixes are the details worth checking if you are working on a different distribution or a later package.

Checkpoint: If command -v prints nothing, stop and install the package through your normal package-management process. Do not substitute a similarly named decoder without checking its own manual page.

2. Decode a complete image

Use -i for the source and -o for a new destination. This example writes an eight-bits-per-channel-compatible BMP:

$ JxrDecApp -i /path/to/input.jxr -o /path/to/output.bmp

The output suffix selects the container. JxrDecApp documents BMP for images at 8 bits per channel or less, PNM for at least 8 bits per channel, and TIFF for at least 8 bits per channel. A destination ending in .jxr is for compressed-domain transcoding rather than an ordinary uncompressed image export.

Check the exit status immediately, then inspect the file:

$ printf 'decoder status: %s\n' "$?"
$ file /path/to/output.bmp
$ ls -lh /path/to/output.bmp

A zero status means the command completed successfully. The exact file description depends on the output format and image properties, so check that it identifies the expected image type and dimensions. A file merely existing is not enough: a failed shell workflow can leave a partial destination behind.

Do not use sudo for a normal decode in a directory you own. Running an image decoder as root increases the consequences of a malformed or hostile input without helping the conversion.

3. Choose the uncompressed pixel format

The optional -c value controls the uncompressed output format. If you omit it, the program's behaviour may depend on the input and output path, so set it explicitly when a consumer needs a particular channel layout. The common choices:

For example, request 24-bit RGB and write a PNM file:

$ JxrDecApp -i /path/to/input.jxr -o /path/to/output.pnm -c 9
$ file /path/to/output.pnm

The manual lists additional fixed-point, floating-point, CMYK and packed BGR formats. Do not pick a numeric format just because its bit count sounds close to the source. Match the output format to what the next program actually accepts, then verify the resulting file with that program or with file.

Checkpoint: Record the chosen -c value beside any script or batch job. Numeric format codes are easy to confuse, and a successful decode does not prove that a later image tool will interpret the channels as intended.

4. Decode a smaller image or a region

Use -T when a full-size image is unnecessary. The default -T 0 is full resolution. The documented levels are half size at 1, quarter size at 2, one eighth at 3, and one sixteenth at 4. Values greater than 4 continue reducing from the one-sixteenth level:

$ JxrDecApp -i /path/to/input.jxr -o /path/to/preview.bmp -T 3 -c 0
$ file /path/to/preview.bmp

Reduced decoding is useful for a preview or a quick inspection, but it is not a replacement for the full image. Keep the output name explicit so a preview cannot be mistaken for the source-quality export.

For a rectangular area, pass -r followed by four values: top, left, height and width. For example:

$ JxrDecApp -i /path/to/input.jxr -o /path/to/crop.pnm -r 100 200 600 800 -c 9

Check the coordinate order carefully. The command does not use the more familiar left, top, width, height order. If the crop is empty, shifted or rejected, confirm the image dimensions and rerun with the documented top-left-height-width order. Region decoding changes what is exported, but it does not modify the original JPEG XR file.

5. Keep the original while replacing an output

Warning: Writing directly to an existing output can destroy the previous result before you have a replacement. Decode to a temporary name in the same directory, verify it, then rename it:

$ JxrDecApp -i /path/to/input.jxr -o /path/to/output.bmp.new -c 0
$ status=$?
$ if [ "$status" -eq 0 ] && [ -s /path/to/output.bmp.new ]; then
>     file /path/to/output.bmp.new
>     mv -- /path/to/output.bmp.new /path/to/output.bmp
> else
>     printf 'decode failed; original output was left alone\n' >&2
>     rm -f -- /path/to/output.bmp.new
>     exit "$status"
> fi

The temporary file must be on the same filesystem for the final mv to be a simple rename. If you need to preserve the old output independently, copy it to a clearly named backup before replacing it. Remove that backup only after checking the new image; deletion is irreversible.

6. Diagnose failures without guessing

A missing input is a straightforward path or permission problem. Test it without changing anything:

$ ls -l /path/to/input.jxr
$ test -r /path/to/input.jxr && printf '%s\n' 'input is readable'

If the decoder reports that it cannot open the source, check the exact spelling, case and permissions. If it rejects the image, keep the original and try a known-good JPEG XR file before changing pixel-format or region options. That separates an invalid source from an invalid option combination.

For a diagnostic run, add -v for verbose decoder information or -t for timing information:

$ JxrDecApp -v -t -i /path/to/input.jxr -o /path/to/check.pnm -c 9

These options report information; they do not repair a damaged file. The -p option selects post-processing strength from 0, none, through 4, very strong. Apply it only when you have a visual reason, because it changes the decoded result. The default is 0.

Options such as -s and -C are aimed at compressed-domain transcoding and tile extraction, not routine image export. Leave them out unless you have a specific compressed-domain workflow and have checked the output. Similarly, -a controls alpha handling: 0 omits alpha, 1 decodes only alpha, and 2 decodes image and alpha, the default. An alpha-only result is not a normal colour image.

Done means