guile-elisp bootstrap (lisp)
[bpt/emacs.git] / lisp / gnus / compface.el
CommitLineData
23f87bed 1;;; compface.el --- functions for converting X-Face headers
e84b4b86 2
ba318903 3;; Copyright (C) 2002-2014 Free Software Foundation, Inc.
23f87bed
MB
4
5;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6;; Keywords: news
7
8;; This file is part of GNU Emacs.
9
5e809f55 10;; GNU Emacs is free software: you can redistribute it and/or modify
23f87bed 11;; it under the terms of the GNU General Public License as published by
5e809f55
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
23f87bed
MB
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
5e809f55 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23f87bed
MB
22
23;;; Commentary:
24
25;;; Code:
26
27;;;###
28(defun uncompface (face)
29 "Convert FACE to pbm.
30Requires the external programs `uncompface', and `icontopbm'. On a
31GNU/Linux system these might be in packages with names like `compface'
32or `faces-xface' and `netpbm' or `libgr-progs', for instance."
33 (with-temp-buffer
73f2395e 34 (unless (featurep 'xemacs) (set-buffer-multibyte nil))
23f87bed 35 (insert face)
5ebdc299
MB
36 (let ((coding-system-for-read 'raw-text)
37 ;; At least "icontopbm" doesn't work with Windows because
38 ;; the line-break code is converted into CRLF by default.
39 (coding-system-for-write 'binary))
40 (and (eq 0 (apply 'call-process-region (point-min) (point-max)
41 "uncompface"
42 'delete '(t nil) nil))
43 (progn
44 (goto-char (point-min))
71c90957
KY
45 (insert "/* Format_version=1, Width=48, Height=48, Depth=1,\
46 Valid_bits_per_item=16 */\n")
5ebdc299
MB
47 ;; I just can't get "icontopbm" to work correctly on its
48 ;; own in XEmacs. And Emacs doesn't understand un-raw pbm
49 ;; files.
50 (if (not (featurep 'xemacs))
51 (eq 0 (call-process-region (point-min) (point-max)
52 "icontopbm"
53 'delete '(t nil)))
54 (shell-command-on-region (point-min) (point-max)
55 "icontopbm | pnmnoraw"
56 (current-buffer) t)
57 t))
58 (buffer-string)))))
23f87bed
MB
59
60(provide 'compface)
61
23f87bed 62;;; compface.el ends here