+ (article-narrow-to-head)
+ (gnus-article-goto-header "from")
+ (when (bobp)
+ (insert "From: [no `from' set]\n")
+ (forward-char -17))
+ (gnus-add-image
+ 'xface
+ (gnus-put-image
+ (if (gnus-image-type-available-p 'xface)
+ (apply 'gnus-create-image (concat "X-Face: " data) 'xface t
+ (cdr (assq 'xface gnus-face-properties-alist)))
+ (apply 'gnus-create-image pbm 'pbm t
+ (cdr (assq 'pbm gnus-face-properties-alist))))
+ nil 'xface))
+ (gnus-add-wash-type 'xface))))))
+
+(defun gnus-grab-cam-x-face ()
+ "Grab a picture off the camera and make it into an X-Face."
+ (interactive)
+ (shell-command "xawtv-remote snap ppm")
+ (let ((file nil))
+ (while (null (setq file (directory-files "/tftpboot/sparky/tmp"
+ t "snap.*ppm")))
+ (sleep-for 1))
+ (setq file (car file))
+ (with-temp-buffer
+ (shell-command
+ (format "pnmcut -left 110 -top 30 -width 144 -height 144 '%s' | ppmnorm 2>/dev/null | pnmscale -width 48 | ppmtopgm | pgmtopbm -threshold -value 0.92 | pbmtoxbm | compface"
+ file)
+ (current-buffer))
+ ;;(sleep-for 3)
+ (delete-file file)
+ (buffer-string))))
+
+(defun gnus-grab-cam-face ()
+ "Grab a picture off the camera and make it into an X-Face."
+ (interactive)
+ (shell-command "xawtv-remote snap ppm")
+ (let ((file nil)
+ result)
+ (while (null (setq file (directory-files "/tftpboot/sparky/tmp"
+ t "snap.*ppm")))
+ (sleep-for 1))
+ (setq file (car file))
+ (shell-command
+ (format "pnmcut -left 110 -top 30 -width 144 -height 144 '%s' | pnmscale -width 48 -height 48 | ppmtopgm > /tmp/gnus.face.ppm"
+ file))
+ (let ((gnus-convert-image-to-face-command
+ (format "cat '%%s' | ppmquant %%d | ppmchange %s | pnmtopng"
+ (gnus-fun-ppm-change-string))))
+ (setq result (gnus-face-from-file "/tmp/gnus.face.ppm")))
+ (delete-file file)
+ ;;(delete-file "/tmp/gnus.face.ppm")
+ result))
+
+(defun gnus-fun-ppm-change-string ()
+ (let* ((possibilites '("%02x0000" "00%02x00" "0000%02x"
+ "%02x%02x00" "00%02x%02x" "%02x00%02x"))
+ (format (concat "'#%02x%02x%02x' '#"
+ (nth (random 6) possibilites)
+ "'"))
+ (values nil))
+ (dotimes (i 255)
+ (push (format format i i i i i i)
+ values))
+ (mapconcat 'identity values " ")))