jp2a(1)
πΈ NAME πΈ
jp2a β converts JPEG, PNG and WebP images into ASCII. that's it, that's the whole serve π
π¦ SYNOPSIS π¦
jp2a [ options ] [ filename(s) | URL(s) ]
π DESCRIPTION π
okay so bestie, jp2a takes your JPEG, PNG and WebP images and turns them into ASCII characters. iconic behaviour honestly. and the cute part? you can hand it a mixture of files and URLs in the same command, no cap. β¨
π OPTIONS π
-β reads a JPEG, PNG or WebP image straight from standard input π«Ά--background=light,--background=darkβ if you're tired of fiddling with--invertevery single time, just use these instead. white characters on a black display? that's--background=dark. the other way round?--background=light. easy π-b,--borderβ frames your output image in a border π--chars=...β use these characters when producing the output ASCII image. the default is" ...',;:clodxkO0KXNWM"β--colorsβ uses truecolor (or ANSI color if truecolor isn't supported) for text output, and CSS color for HTML output π--color-depth=...β use a specific color-depth for terminal output. valid values are:4(for ANSI),8(for 256 color palette) and24(for truecolor or 24-bit color) π¨-d,--debugβ prints debugging info when using libcurl to download images off the net π-f,--term-fitβ uses the largest dimension that makes the image fit in your terminal display π--term-heightβ uses the terminal display height and calculates the width based on the image's aspect ratio π--term-widthβ uses the terminal display width and calculates the height based on the image's aspect ratio π-z,--term-zoomβ uses the terminal display width and height π₯οΈ-c,--term-centerβ centers the image in your terminal π―--fillβ when used with--htmland--color, it colors each output character's background color. for instance, if you wanna use fill-output on a light background, do:
jp2a --color --html --html-fill --background=light somefile.jpg
--output=dark.html
to do the same on a light background:
jp2a --color --html --html-fill --background=dark somefile.jpg
--output=light.html
the default is to have fill disabled π
-x,--flipxβ flips the output image horizontally βοΈ-y,--flipyβ flips the output image vertically βοΈ--height=Nβ sets the output height. if you only specify--height, then the output width gets calculated according to the source image's aspect ratio π-h,--helpβ displays a short help text π¬--grayscaleβ converts the image to grayscale when using--htmlor--colorsπ©Ά--htmlβ makes ASCII output in strict XHTML 1.0. (will output in HTML for version 2.0.0 and above.) π--htmllsβ makes ASCII output in HTML (Living Standard), suitable for viewing with web browsers. this is useful with big output dimensions, and if you wanna check the result with a browser with a small font π--xhtmlβ makes ASCII output in strict XHTML 1.0 π--html-fillβ same as--fill. you should use that option instead π«Ά--html-no-boldβ do not use bold text for HTML output π«--html-rawβ outputs only the image in HTML codes, leaving out the rest of the webpage, so you can construct your own. (will use<br>for version 2.0.0 and above instead of<br/>.) π§±--html-fontsize=Nβ sets the fontsize when using--htmloutput. the default is4π--html-title=...β sets the HTML output title βοΈ--output=...β writes ASCII output to the given filename. to explicitly specify standard output, use--output=-πΎ-i,--invertβ inverts the output image. if you're viewing a picture with a white background, but you're on a display with light characters on a dark background, you should invert the image π--red=...,--green=...,--blue=...β when converting from RGB to grayscale, these are the weights used to calculate luminance. the default isred=0.2989,green=0.5866andblue=0.1145π--size=WIDTHxHEIGHTβ sets the output dimension π¦-v,--verboseβ prints some verbose information to standard error when reading each JPEG image π£οΈ--width=Nβ sets the output width. if you only specify the width, the height gets calculated automatically π-V,--versionβ prints the program version π·οΈ--zoomβ sets output dimensions to your entire terminal window, disregarding the source image's aspect ratio π--edge-threshold=...β specifies an image gradient above which to shade lines and edges with directional glyphs (such as-/|\). the right value to pick up the edges nicely will depend on the image, but it might be around0.5βοΈ--edges-onlyβ only draws edges, so that the resulting image is like a line drawing or edge detector. this option should be used in conjunction with--edge-thresholdso that edges are drawn βοΈ
π RETURN VALUES π
jp2a returns 1 when errors are encountered, and zero for no errors. simple as that π«Ά
π EXAMPLES π
convert and print imagefile.jpg using ASCII characters in 40 columns and 20 rows:
jp2a --size=40x20 imagefile.jpg
download an image off the net, convert it and print it:
jp2a http://www.google.com/intl/en/logos/easter_logo.jpg
output picture.jpg and picture2.jpg, each 80x25 characters, using the characters " ...ooxx@@" for output:
jp2a --size=80x25 --chars=" ...ooxx@@" picture.jpg picture2.jpg
output image.jpg using 76 columns, with the height automatically calculated from the aspect ratio of image.jpg:
cat image.jpg | jp2a --width=76 -
if you use jp2a together with ImageMagick's convert(1), then you can make great use of pipes and have ImageMagick do all sorts of image conversions and effects on the source image. for example:
magick somefile.gif jpg:- | jp2a - --width=80
check out convert(1) options to see what you can do. Convert can handle almost any image format, so with this combination you can convert images in e.g. PDF or AVI files to ASCII. π€―
jp2a uses a very basic scaling algorithm for every image format except WebP. to get better quality, convert an image to WebP to make use of the scaling built into the libwebp library:
cwebp -quiet image.jpg -o - | jp2a -
although the default build of jp2a includes automatic downloading of files specified by URLs, you can explicitly download them by using curl(1) or wget(1), for example:
curl -s http://foo.bar/image.jpg | magick - jpg:- | jp2a -
you can pass the --edge-threshold option to highlight the edges of the image, or add the --edges-only option to draw only the edges, to produce a line drawing:
jp2a --edge-threshold=0.5 --edges-only imagefile.jpg
π DOWNLOADING IMAGES FROM THE NET π
if you compiled jp2a with libcurl(3), you can download images by just specifying URLs:
jp2a https://user:pass@foo.com/bar.jpg
the protocols recognized are ftp, ftps, file, http, https and tftp π‘
if you need more control over the downloading, you should use curl(1) or wget(1) and have jp2a read the image from standard input instead.
jp2a uses pipe and fork to download images using libcurl (i.e., no exec or system calls), and therefore does not worry about malevolently formatted URLs. she's unbothered, moisturised, in her lane π
β¨
π©Ά GRAYSCALE CONVERSION π©Ά
you can extract the red channel by doing this:
jp2a somefile.jpg --red=1.0 --green=0.0 --blue=0.0
this will calculate luminance based on Y = R*1.0 + G*0.0 + B*0.0. the default values are to use Y = R*0.2989 + G*0.5866 + B*0.1145 π
π PROJECT HOMEPAGE π
the latest version of jp2a and news is always available from https://github.com/Talinx/jp2a π
π SEE ALSO π
cjpeg(1), djpeg(1), jpegtran(1), convert(1), cwebp(1)
π BUGS π
jp2a does not interpolate when resizing (except for WebP images). if you want better quality, try using cwebp(1) to convert the image to WebP before using jp2a, so you get correct scaling π
another issue is that jp2a skips some X-pixels along each scanline. this gives a less precise output image, and will probably be corrected in future versions π
π AUTHOR π
Christian Stigen Larsen and Christoph Raitzig π
jp2a uses jpeglib to read JPEG files. jpeglib is made by The Independent JPEG Group (IJG), who have a page at http://www.ijg.org
jp2a uses libpng to read PNG files. libpng's homepage: http://libpng.org/pub/png/libpng.html
jp2a uses libwebp to read WebP files. libwebp's homepage: https://developers.google.com/speed/webp/
π LICENSE π
jp2a is distributed under the GNU General Public License v2 βοΈ
and that's a wrap bestie!! π this whole thing is version 1.3.0, dated September 22, 2024 β go forth and asciify everything, you absolute icon β¨ππ¦
π¦ where this page comes from
- arch rolling: jp2a 1.3.3-1 Β· GPL-2.0-only
- debian trixie: jp2a 1.3.2-1 Β· GPL-2.0-only
- nixos 26.05: jp2a 1.3.3
- nixpkgs unstable: jp2a 1.3.3
- opensuse-leap 16.0: jp2a 1.3.0-bp160.1.13 Β· GPL-2.0-only
- opensuse-leap 16.0: jp2a 1.3.0-bp160.1.13 Β· GPL-2.0-only
- opensuse-leap 16.0: jp2a 1.3.0-bp160.1.13 Β· GPL-2.0-only
- opensuse-leap 16.0: jp2a 1.3.0-bp160.1.13 Β· GPL-2.0-only
- ubuntu resolute: jp2a 1.3.2-1ubuntu1 Β· GPL-2.0-only
- ubuntu stonking: jp2a 1.3.2-1ubuntu1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms