An X-Face:
header allows you to include a 48x48 bitmap
(one bit per pixel) icon in the headers of your e-mails or
Usenet news posts.
Some (of "your better") e-mail and news clients can
display these icons along with your message.
Traditionally, an X-Face:
header is created with a program called
(part of the
faces
package)
which produces a highly compressed representation of a 48x48 bitmap
consisting solely of printable
ASCII characters.
The compface
program requires its input to be in the archaic and
obscure ikon format. Because of this, converting images to
X-Face:
headers
is typically a time-consuming trial-and-error process.
This page fixes all that.
Using this page you can convert nearly any image into an X-Face:
header.
(Under construction.)
I believe the following image types to be supported:
GIF, TIFF, PNG, JPEG, PPM, PGM, PBM, BMP (PC bitmap), XBM, XPM, XWD (X Windows dump), Sun rasterfile, MACP (MacPaint format), BRUSH (Xerox Doodlebrush), YBM (Bennet Yee's face format), FS (UseNix Facesaver), LISPM (Lisp machine bitmap), TGA (TrueVision Targa file), PI1 (Atari Degas .pi1), PI3 (Atari Degas .pi3), SPU (Atari uncompressed Spectrum file), SPC (Atari compressed Spectrum file), MDA (Microdesign .mda file), PCX, PICT, HIPS, FITS, ILBM, MTV, QRT, XIM, G3 (group 3 fax)
(I have not tested support for all the above types. Let me know if you discover bugs.)
The image type is deduced by inspecting the files
magic number,
when possible.
If the magic number is not recognized, then the file name extension
(e.g. .xbm
) is used to identify the image type.
(Currently the MIME type is ignored when determining
image format.)
Most of the image manipulations are performed using various utilities from the netpbm package. The steps in the conversion process are:
The image is converted to PNM (i.e. either PPM, PGM, or PBM) (if necessary).
If the image is larger than 48 pixels in height or width, it is scaled so that it's largest dimension is exactly 48 pixels.
The image is then padded so that it is exactly 48 pixels square. The pad color option controls the padding fill color.
If the image is in color (i.e. a PPM) it is converted to a grayscale image using .
If contrast enhancement is enabled, the image contrast is adjusted using (for Auto-stretch mode) or (for Equalize mode).
If edge-enhancement is enabled, the image is passed through . The amount parameter (you guessed it!) controls the amount of enhancement.
If you're converting a continuous tone image, like a photograph, some edge enhancement often seems to make the final dithered picture a bit clearer.If edge-detection is enabled, the image is passed through . (Edge detection is probably only useful for special effects.)
If the image is not already a bitmap (1-bit color depth), it is converted to a PBM using the program. The dithering options control the behavior of this step.
Atkinson, Floyd-Steinberg and Threshold dithering are the most useful for creating small bitmaps. (The Atkinson algorithm seems usually to produce the best results.) The other dithering types are useful (if at all) only for special effects. The threshold parameter may be specified in the range (0.0,1.0) --- it affects the Atkinson, Floyd-Steinberg and threshold dithering. (It may help to think of the threshold as a brightness or gamma control.)
See the
pgmtopbm
man page for
more information on the dithering options.
If bitmap cleaning is enabled, the bitmap is run through . This inverts any pixel which has less than connect identical neighbors.
If the invert option is selected the image is inverted (white <-> black).
Finally, the image is piped through
to produce the
X-Face
header.
This page by Jeff Dairiki. Comments are welcome.