LinuxCommandLibrary

jp2a

Convert JPEG 2000 images to other formats

TLDR

Read JPEG image from a file and print in ASCII

$ jp2a [path/to/image.jpeg]
copy

Read JPEG image from a URL and print in ASCII
$ jp2a [www.example.com/image.jpeg]
copy

Colorize the ASCII output
$ jp2a --colors [path/to/image.jpeg]
copy

Specify characters to be used for the ASCII output
$ jp2a --chars='[..-ooxx@@]' [path/to/image.jpeg]
copy

Write the ASCII output into a file
$ jp2a --output=[path/to/output_file.txt] [path/to/image.jpeg]
copy

Write the ASCII output in HTML file format, suitable for viewing in web browsers
$ jp2a --html --output=[path/to/output_file.html] [path/to/image.jpeg]
copy

SYNOPSIS

jp2a [options] <jpeg-files>...

PARAMETERS

-b, --background=color
    Set background color (e.g., black, rgb:ff/00/00)

-c, --colors[=when]
    Enable color output (always, auto, never)

-f, --foreground=color
    Set foreground color

-g, --gamma=num
    Gamma correction value (default 2.2, range 0.1-4.0)

--html
    Output HTML with ANSI colors

-i, --invert
    Invert light/dark areas

-l, --limit=num
    Max lines per image (default 0=unlimited)

-m, --margin=mode
    Margin mode (none, fixed, auto)

-o, --output=file
    Write output to file

-s, --size=widthxheight
    Set output dimensions (e.g., 80x40)

-t, --threshold=num
    Dithering threshold (0.0-1.0)

-u, --unlimited
    Ignore line limits

-v, --version
    Print version info

-h, --help
    Show usage help

DESCRIPTION

jp2a is a lightweight Linux command-line tool that converts JPEG images into ASCII art using the AA-lib library. It maps pixel intensities to ASCII characters, creating text-based representations suitable for terminals, emails, or text files.

Key features include adjustable output dimensions, color support (for terminals with 256/16M colors), gamma and threshold tuning for contrast, background/foreground customization, and inversion for negative effects. It processes single or multiple files, outputting to stdout or files, with an HTML mode for web-safe art.

Common uses: embedding images in shell scripts, generating ASCII previews, forum posts without attachments, or artistic terminal displays. Run jp2a photo.jpg for instant results; pipe to less -R for scrolling color art. Limitations include JPEG-only input and potential quality loss on complex images.

CAVEATS

Supports only JPEG/PJPG formats; complex or high-res images may lose detail. Color output requires terminal support (e.g., xterm-256color). No stdin input.

EXAMPLE USAGE

jp2a --colors --size=80x40 image.jpg
jp2a --html image.jpg > art.html
for f in *.jpg; do jp2a -o "$f.txt" "$f"; done

DEPENDENCIES

Requires libjpeg-dev and libaa1-dev for compilation; runtime links libjpeg and libaa.

HISTORY

Developed by Jan 'Hector' Krikhaar around 2001 as a frontend to AA-lib for JPEG-to-ASCII conversion. Maintained sporadically; latest stable in 2014. Widely packaged in distros like Debian/Ubuntu.

SEE ALSO

aaview(1), aaflip(1), convert(1)

Copied to clipboard