Next: , Up: Image Enhancements

9.14.1 X-Face

X-Face headers describe a 48x48 pixel black-and-white (1 bit depth) image that's supposed to represent the author of the message. It seems to be supported by an ever-growing number of mail and news readers.

Viewing an X-Face header either requires an Emacs that has ‘compface’ support (which most XEmacs versions have), or that you have suitable conversion or display programs installed. If your Emacs has image support the default action is to display the face before the From header. If there's no native X-Face support, Gnus will try to convert the X-Face header using external programs from the pbmplus package and friends, see below. For XEmacs it's faster if XEmacs has been compiled with X-Face support. The default action under Emacs without image support is to fork off the display program.

On a GNU/Linux system, the display program is included in the ImageMagick package. For external conversion programs look for packages with names like netpbm, libgr-progs and compface. On Windows, you may use the packages netpbm and compface from http://gnuwin32.sourceforge.net. You need to add the bin directory to your PATH environment variable.

The variable gnus-article-x-face-command controls which programs are used to display the X-Face header. If this variable is a string, this string will be executed in a sub-shell. If it is a function, this function will be called with the face as the argument. If gnus-article-x-face-too-ugly (which is a regexp) matches the From header, the face will not be shown.

(Note: x-face is used in the variable/function names, not xface).

Face and variable:

gnus-x-face
Face to show X-Face. The colors from this face are used as the foreground and background colors of the displayed X-Faces. The default colors are black and white.
gnus-face-properties-alist
Alist of image types and properties applied to Face (see Face) and X-Face images. The default value is ((pbm . (:face gnus-x-face)) (png . nil)) for Emacs or ((xface . (:face gnus-x-face))) for XEmacs. Here are examples:
          ;; Specify the altitude of Face and X-Face images in the From header.
          (setq gnus-face-properties-alist
                '((pbm . (:face gnus-x-face :ascent 80))
                  (png . (:ascent 80))))
          
          ;; Show Face and X-Face images as pressed buttons.
          (setq gnus-face-properties-alist
                '((pbm . (:face gnus-x-face :relief -2))
                  (png . (:relief -2))))

see Image Descriptors for the valid properties for various image types. Currently, pbm is used for X-Face images and png is used for Face images in Emacs. Only the :face property is effective on the xface image type in XEmacs if it is built with the ‘libcompface’ library.

If you use posting styles, you can use an x-face-file entry in gnus-posting-styles, See Posting Styles. If you don't, Gnus provides a few convenience functions and variables to allow easier insertion of X-Face headers in outgoing messages. You also need the above mentioned ImageMagick, netpbm or other image conversion packages (depending the values of the variables below) for these functions.

gnus-random-x-face goes through all the ‘pbm’ files in gnus-x-face-directory and picks one at random, and then converts it to the X-Face format by using the gnus-convert-pbm-to-x-face-command shell command. The ‘pbm’ files should be 48x48 pixels big. It returns the X-Face header data as a string.

gnus-insert-random-x-face-header calls gnus-random-x-face and inserts a ‘X-Face’ header with the randomly generated data.

gnus-x-face-from-file takes a GIF file as the parameter, and then converts the file to X-Face format by using the gnus-convert-image-to-x-face-command shell command.

Here's how you would typically use the first function. Put something like the following in your ~/.gnus.el file:

     (setq message-required-news-headers
           (nconc message-required-news-headers
                  (list '(X-Face . gnus-random-x-face))))

Using the last function would be something like this:

     (setq message-required-news-headers
           (nconc message-required-news-headers
                  (list '(X-Face . (lambda ()
                                     (gnus-x-face-from-file
                                      "~/My-face.gif"))))))