Skip to content

CLI

One-shot commands over the same pipeline, no server:

Terminal window
oximg resize photo.jpg 1600 1600 out.webp # fit within 1600x1600; format from the extension
oximg resize photo.jpg 800 800 out.jpg -q 70 # JPEG quality 70 (--preset fast|small for mozjpeg)
oximg resize photo.jpg 750 0 out.jpg # width-only: height follows the aspect ratio
oximg resize photo.jpg 0 0 out.webp # 0 0 = re-encode at the source's own size
oximg probe photo.webp # format + stored dimensions, header-only
oximg probe loop.gif # animated sources also print frames, duration and loop count
oximg probe loop.gif --json # one JSON object, with the decode work OXIMG_MAX_ANIM_DECODE_WORK is spent against
oximg probe portrait.jpg # a rotated source also prints its orientation and displayed size
oximg strip upload.jpg clean.jpg # drop EXIF/GPS, XMP, IPTC, comments; no re-encode
oximg strip upload.png clean.png --icc strip # ...and the colour profile too
oximg strip portrait.jpg clean.jpg --auto-rotate # ...and turn a rotated JPEG upright, losslessly
oximg strip portrait.jpg clean.jpg --auto-rotate --json # ...and print the outcome as JSON on stdout

oximg strip removes metadata from a JPEG, PNG or WebP without decoding a pixel: the compressed image data is copied byte for byte, so it costs O(file size) in memory and nothing in quality, where a 0 0 re-encode costs a generation and the pipeline’s largest buffers (a 21 MB 8000x8000 JPEG: 45 MB peak RSS and 0.02 s, against 602 MiB and 0.96 s for resize 0 0 on a similar file, M2 Max). It keeps what rendering needs and drops everything else, unknown blocks included: JPEG keeps JFIF (minus any thumbnail), the ICC profile and Adobe APP14 (CMYK decoding needs its transform flag) and drops bytes after EOI, such as MPF secondary images; PNG keeps critical and colour/transparency/animation chunks; WebP keeps the image and animation chunks and fixes the VP8X flags. A rotated photo keeps an EXIF block holding only its orientation, so it still displays upright. --icc keep|strip defaults to OXIMG_ICC (keep); dropping a CMYK JPEG’s profile is refused, since browsers would show wrong colours (resize converts it to sRGB instead). GIF and AVIF are not supported.

--auto-rotate turns a rotated JPEG upright instead of keeping its orientation tag, still without re-encoding: the compressed 8x8 blocks are moved and transposed, as jpegtran -perfect does, so stored and displayed dimensions agree for every reader. It re-codes the entropy data (optimized Huffman, the source’s baseline or progressive), so it costs what jpegtran does: 168 ms and 88 MiB for a 12 MP phone photo, against 12 ms for a plain strip (M2 Max). It is only exact when the edges the rotation moves are whole 8 or 16 px blocks; otherwise, for a truncated or corrupt JPEG, and for PNG and WebP, the file is stripped as without the flag, orientation kept, and the summary says why. --json prints the outcome on stdout for scripts: orientation, rotated, and not_rotated: {code, message}, where code is one of unaligned_edges, corrupt, over_limit or not_jpeg (docs/features/paths.md) and stays stable while the message may change.

The output format is -f/--format, else the <out> extension, else the source’s own format — the same precedence idea as the server’s @fmt grammar. The OXIMG_* encode knobs below apply to CLI encodes the same way. Usage errors exit 2; processing failures exit 1.

Two of those knobs also have per-call flags on resize, which win over the environment: --icc keep|strip (OXIMG_ICC) and --no-auto-rotate (OXIMG_AUTO_ROTATE=0; --auto-rotate forces it back on). A caller that treats one image differently passes a flag rather than changing the process environment.