Move the version of ELisp-based uncompface program to the contrib directory
[gnus] / lisp / compface.el
1 ;;; compface.el --- functions for converting X-Face headers
2 ;; Copyright (C) 2002 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: news
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 ;;;###
29 (defun uncompface (face)
30   "Convert FACE to pbm.
31 Requires the external programs `uncompface', and `icontopbm'.  On a
32 GNU/Linux system these might be in packages with names like `compface'
33 or `faces-xface' and `netpbm' or `libgr-progs', for instance."
34   (with-temp-buffer
35     (insert face)
36     (and (eq 0 (apply 'call-process-region (point-min) (point-max)
37                       "uncompface"
38                       'delete '(t nil) nil))
39          (progn
40            (goto-char (point-min))
41            (insert "/* Width=48, Height=48 */\n")
42            ;; I just can't get "icontopbm" to work correctly on its
43            ;; own in XEmacs.  And Emacs doesn't understand un-raw pbm
44            ;; files.
45            (if (not (featurep 'xemacs))
46                (eq 0 (call-process-region (point-min) (point-max)
47                                           "icontopbm"
48                                           'delete '(t nil)))
49              (shell-command-on-region (point-min) (point-max)
50                                       "icontopbm | pnmnoraw"
51                                       (current-buffer) t)
52              t))
53          (buffer-string))))
54
55 (provide 'compface)
56
57 ;;; arch-tag: f9c78e84-98c0-4142-9682-8ba4cf4c3441
58 ;;; compface.el ends here