* Image formats for gnus-(x-)face-from-file
@ 2005-10-13 20:12 Reiner Steib
2005-10-14 7:21 ` James Cloos
0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2005-10-13 20:12 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 645 bytes --]
Hi,
the following patch allows for use different input image formats by
using convert(1) to generate Face and X-Face headers.
Currently `gnus-x-face-from-file' requires GIF and
`gnus-face-from-file' requires JPEG.
For me, the current `gnus-x-face-from-file' command doesn't even work
(and I saw similar reports on Google):
$ giftopnm face.gif | ppmnorm | pnmscale -width 48 -height 48 | ppmtopgm |\
pgmtopbm | pbmtoxbm | compface
giftopnm: Reading Image Sequence 0
ppmnorm: remapping 65..233 to 0..255
compface: (warning) <stdin>: excess data ignored
compface: (warning) <stdin>: excess data ignored
$
Is it okay to change the defaults?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rs-gnus-fun-face-w-convert.patch --]
[-- Type: text/x-patch, Size: 2861 bytes --]
--- gnus-fun.el 29 Aug 2005 16:37:45 +0200 7.9
+++ gnus-fun.el 13 Oct 2005 21:56:20 +0200
@@ -45,21 +45,37 @@
:group 'gnus-fun
:type 'string)
-(defcustom gnus-convert-image-to-x-face-command "giftopnm %s | ppmnorm | pnmscale -width 48 -height 48 | ppmtopgm | pgmtopbm | pbmtoxbm | compface"
+(defcustom gnus-convert-image-to-x-face-command
+ "convert -resize 48x48 %s xbm:- | xbm2xface.pl"
"Command for converting an image to an X-Face.
+The command must take a image filename (use \"%s\") as input.
+The output must be the Face header data on stdout in PNG format.
+
By default it takes a GIF filename and output the X-Face header data
on stdout."
:version "22.1"
:group 'gnus-fun
- :type 'string)
+ :type '(choice (const :tag "giftopnm, netpbm (GIF input only)"
+ "giftopnm %s | ppmnorm | pnmscale -width 48 -height 48 | ppmtopgm | pgmtopbm | pbmtoxbm | compface")
+ (const :tag "convert"
+ "convert -resize 48x48 %s xbm:- | xbm2xface.pl")
+ (string)))
-(defcustom gnus-convert-image-to-face-command "djpeg %s | ppmnorm | pnmscale -width 48 -height 48 | ppmquant %d | pnmtopng"
+(defcustom gnus-convert-image-to-face-command
+ "convert -resize 48x48 %s -colors %d png:-"
"Command for converting an image to a Face.
-By default it takes a JPEG filename and output the Face header data
-on stdout."
+
+The command must take an image filename (first format
+argument\"%s\") and the number of colors (second format argument:
+\"%d\") as input. The output must be the Face header data on
+stdout in PNG format."
:version "22.1"
:group 'gnus-fun
- :type 'string)
+ :type '(choice (const :tag "djpeg, netpbm (JPG input only)"
+ "djpeg %s | ppmnorm | pnmscale -width 48 -height 48 | ppmquant %d | pnmtopng")
+ (const :tag "convert"
+ "convert -resize 48x48 %s -colors %d png:-")
+ (string)))
(defcustom gnus-face-properties-alist (if (featurep 'xemacs)
'((xface . (:face gnus-x-face)))
@@ -125,8 +141,11 @@
;;;###autoload
(defun gnus-x-face-from-file (file)
- "Insert an X-Face header based on an image file."
- (interactive "fImage file name (by default GIF): ")
+ "Insert an X-Face header based on an image file.
+
+Depending on `gnus-convert-image-to-x-face-command' it may accept
+different input formats."
+ (interactive "fImage file name: ")
(when (file-exists-p file)
(gnus-shell-command-to-string
(format gnus-convert-image-to-x-face-command
@@ -134,8 +153,11 @@
;;;###autoload
(defun gnus-face-from-file (file)
- "Return a Face header based on an image file."
- (interactive "fImage file name (by default JPEG): ")
+ "Return a Face header based on an image file.
+
+Depending on `gnus-convert-image-to-face-command' it may accept
+different input formats."
+ (interactive "fImage file name: ")
(when (file-exists-p file)
(let ((done nil)
(attempt "")
[-- Attachment #3: Type: text/plain, Size: 114 bytes --]
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Image formats for gnus-(x-)face-from-file
2005-10-13 20:12 Image formats for gnus-(x-)face-from-file Reiner Steib
@ 2005-10-14 7:21 ` James Cloos
2005-10-14 16:51 ` Reiner Steib
0 siblings, 1 reply; 9+ messages in thread
From: James Cloos @ 2005-10-14 7:21 UTC (permalink / raw)
I don't know how relevant it is for face headers, but I just noticed
that convert -resize 48x48 does not guarantee a 48x48 bit image, but
instead maintains the original's aspect ratio and sets the resulting
image's largest dimension to 48 pixels. My test image came out as a
36x48 pixel xbm or png.
-JimC
--
James H. Cloos, Jr. <cloos@jhcloos.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Image formats for gnus-(x-)face-from-file
2005-10-14 7:21 ` James Cloos
@ 2005-10-14 16:51 ` Reiner Steib
2005-10-27 14:21 ` face quantization (was: Image formats for gnus-(x-)face-from-file) Didier Verna
0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2005-10-14 16:51 UTC (permalink / raw)
On Fri, Oct 14 2005, James Cloos wrote:
> I don't know how relevant it is for face headers, but I just noticed
> that convert -resize 48x48 does not guarantee a 48x48 bit image, but
> instead maintains the original's aspect ratio and sets the resulting
> image's largest dimension to 48 pixels. My test image came out as a
> 36x48 pixel xbm or png.
So we should use "convert -scale 48x48!" instead of "convert -resize
48x48"? Thanks for the hint.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 9+ messages in thread
* face quantization (was: Image formats for gnus-(x-)face-from-file)
2005-10-14 16:51 ` Reiner Steib
@ 2005-10-27 14:21 ` Didier Verna
2005-10-27 15:11 ` face quantization Reiner Steib
0 siblings, 1 reply; 9+ messages in thread
From: Didier Verna @ 2005-10-27 14:21 UTC (permalink / raw)
Reiner Steib <reinersteib+gmane@imap.cc> wrote:
> On Fri, Oct 14 2005, James Cloos wrote:
>
>> I don't know how relevant it is for face headers, but I just noticed
>> that convert -resize 48x48 does not guarantee a 48x48 bit image, but
>> instead maintains the original's aspect ratio and sets the resulting
>> image's largest dimension to 48 pixels. My test image came out as a
>> 36x48 pixel xbm or png.
>
> So we should use "convert -scale 48x48!" instead of "convert -resize
> 48x48"? Thanks for the hint.
I don't know why, but recent modifications on the face code broke my
faces. They seem to have much less colors than before, while being of the same
size (in the header I mean). Has the quantization algorithm been modified
recently ?
--
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier
EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bicêtre, France Fax.+33 (1) 53 14 59 22 didier@xemacs.org
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: face quantization
2005-10-27 14:21 ` face quantization (was: Image formats for gnus-(x-)face-from-file) Didier Verna
@ 2005-10-27 15:11 ` Reiner Steib
2005-10-28 8:32 ` Didier Verna
0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2005-10-27 15:11 UTC (permalink / raw)
On Thu, Oct 27 2005, Didier Verna wrote:
> I don't know why, but recent modifications on the face code
> broke my faces. They seem to have much less colors than before,
> while being of the same size (in the header I mean). Has the
> quantization algorithm been modified recently ?
The algorithm in `gnus-face-from-file' itself hasn't changed.
But the default of `gnus-convert-image-to-face-command' is
"convert -scale 48x48! %s -colors %d png:-"
instead of
"djpeg %s | ppmnorm | pnmscale -width 48 -height 48 | ppmquant %d | pnmtopng".
It's quite possible that the convert differs from the later. Could
you investigate?
My intention was to allow more input formats (for both, X-Face and
Face [1]). But if convert is not doing a good job, we could change
the default back to use djpeg and the netpbm tools.
Bye, Reiner.
[1] Cf. your comment in `gnus.texi':
| 6.528 (didier 18-Jun-03):
| @c #### FIXME: faces and x-faces'implementations should really be harmonized.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: face quantization
2005-10-27 15:11 ` face quantization Reiner Steib
@ 2005-10-28 8:32 ` Didier Verna
2005-10-28 10:52 ` Reiner Steib
0 siblings, 1 reply; 9+ messages in thread
From: Didier Verna @ 2005-10-28 8:32 UTC (permalink / raw)
Reiner Steib <reinersteib+gmane@imap.cc> wrote:
> The algorithm in `gnus-face-from-file' itself hasn't changed.
> But the default of `gnus-convert-image-to-face-command' is
> "convert -scale 48x48! %s -colors %d png:-"
> instead of
> "djpeg %s | ppmnorm | pnmscale -width 48 -height 48 | ppmquant %d | pnmtopng".
>
> It's quite possible that the convert differs from the later. Could
> you investigate?
After some testing, it appears that convert does a better job (in the
sense that the result is closer to the original image), although I tend to
prefer the former solution because the results are brighter and a bit
"artificial", kinda special-effect :-)
I also noticed that given my original jpg faces that are already at a
size of 48x48, the average quantization I get is 4 to 6 which is quite poor.
Maybe the size limit of 726 has something to do with it. As it changed in the
last few months (I cound't find a trace of this in the ChangeLog) ?
Finally, it might be worth considering that after quantization to 4 or
6 colors, the resulting PNG images are *bigger* than my original JPEG ones.
So why not using JPG in the headers instead ?
--
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier
EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bicêtre, France Fax.+33 (1) 53 14 59 22 didier@xemacs.org
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: face quantization
2005-10-28 8:32 ` Didier Verna
@ 2005-10-28 10:52 ` Reiner Steib
2005-10-28 12:43 ` Didier Verna
0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2005-10-28 10:52 UTC (permalink / raw)
On Fri, Oct 28 2005, Didier Verna wrote:
> I also noticed that given my original jpg faces that are already at a
> size of 48x48, the average quantization I get is 4 to 6 which is quite poor.
> Maybe the size limit of 726 has something to do with it. As it changed in the
> last few months (I cound't find a trace of this in the ChangeLog) ?
It hasn't changed since...
,----[ C-x v g / vc-annotate ]
| revision 6.45
| date: 2003/04/21 11:42:07; author: kaig; state: Exp; lines: +3 -3
| (gnus-face-from-file, gnus-convert-png-to-face):
| Max length of header is 726, not 740. From Gaute B Strokkenes
| <gs234@cam.ac.uk>.
`----
> Finally, it might be worth considering that after
> quantization to 4 or 6 colors,
BTW, would it make sense to decrease by one instead of two at least if
quant becomes small?
--8<---------------cut here---------------start------------->8---
--- gnus-fun.el 14 Oct 2005 18:51:50 +0200 7.10
+++ gnus-fun.el 28 Oct 2005 12:50:42 +0200
@@ -172,7 +172,7 @@
quant))))
(if (> (length attempt) 726)
(progn
- (setq quant (- quant 2))
+ (setq quant (- quant (if (< quant 10) 1 2)))
(gnus-message 9 "Length %d; trying quant %d"
(length attempt) quant))
(setq done t)))
--8<---------------cut here---------------end--------------->8---
> the resulting PNG images are *bigger* than my original JPEG ones.
> So why not using JPG in the headers instead ?
Ask Lars; his specification says PNG. :-)
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: face quantization
2005-10-28 10:52 ` Reiner Steib
@ 2005-10-28 12:43 ` Didier Verna
2006-04-13 8:25 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Didier Verna @ 2005-10-28 12:43 UTC (permalink / raw)
Cc: Lars Magne Ingebrigtsen
Reiner Steib <reinersteib+gmane@imap.cc> wrote:
>> Finally, it might be worth considering that after quantization to 4
>> or 6 colors, the resulting PNG images are *bigger* than my original JPEG
>> ones. So why not using JPG in the headers instead ?
>
> Ask Lars; his specification says PNG. :-)
OK. Lars ? :-)
--
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier
EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bicêtre, France Fax.+33 (1) 53 14 59 22 didier@xemacs.org
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: face quantization
2005-10-28 12:43 ` Didier Verna
@ 2006-04-13 8:25 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-04-13 8:25 UTC (permalink / raw)
Didier Verna <didier@lrde.epita.fr> writes:
>>> Finally, it might be worth considering that after quantization to 4
>>> or 6 colors, the resulting PNG images are *bigger* than my original JPEG
>>> ones. So why not using JPG in the headers instead ?
>>
>> Ask Lars; his specification says PNG. :-)
>
> OK. Lars ? :-)
When "designing" this, I did quite a few tests with jpeg/png 48x48
images constrained to 778 bytes, and the jpeg ones always looked much,
much worse than the PNG ones.
You might find examples of the opposite, of course.
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-04-13 8:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-13 20:12 Image formats for gnus-(x-)face-from-file Reiner Steib
2005-10-14 7:21 ` James Cloos
2005-10-14 16:51 ` Reiner Steib
2005-10-27 14:21 ` face quantization (was: Image formats for gnus-(x-)face-from-file) Didier Verna
2005-10-27 15:11 ` face quantization Reiner Steib
2005-10-28 8:32 ` Didier Verna
2005-10-28 10:52 ` Reiner Steib
2005-10-28 12:43 ` Didier Verna
2006-04-13 8:25 ` Lars Magne Ingebrigtsen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).