* Coloured faces: 740 bytes is too much.
@ 2003-04-13 13:48 Gaute B Strokkenes
2003-04-15 21:48 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Gaute B Strokkenes @ 2003-04-13 13:48 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 652 bytes --]
I recently received some advice on gnu.emacs.gnus on how to get this
working. However, I believe that the specification of the Face:
header is wrong in one respect. It states that, because of
limitations on how large a news/mail header can be and the base64
encoding that is used, the png image can be at most 740 bytes long.
As luck would have it, the 10-colour version of the 9-colour image
that I have in this image is precisely 739 bytes. When I base64
encode it I get a header that is too long. A suitably modified
version of the make-face shell script seems to agree with me as well.
It seems that the calculations here need to be redone.
[-- Attachment #2: My pretty face --]
[-- Type: image/png, Size: 739 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Not just a pretty face --]
[-- Type: text/x-sh, Size: 826 bytes --]
#!/bin/bash
png1=$1
png2=$2
if [ "$png1" = "" -o "$png2" = "" ]; then
echo "Usage: make-face <PNG-FILE> <BASE64-FILE>"
exit
fi
quant=16
found=false
tmp=/tmp/make-face.$$.tmp
tmp2=/tmp/mak-face2.$$.tmp
while [ "$found" = "false" ]; do
echo -n "Trying quantization $quant ($jpg)..."
pngtopnm "$png1"\
| ppmnorm\
| pnmscale -width 48 -height 48\
| ppmquant $quant\
| pnmtopng > $tmp2
size=`ls -l $tmp2 | awk '{ print $5; }'`
echo "Size of png is $size"
cat "$tmp2" \
| mimencode > $tmp
size=`ls -l $tmp | awk '{ print $5; }'`
if [ $size -lt 999 ]; then
echo -n "Face:" > "$png2"
for i in `cat $tmp`; do
echo -n " " >> "$png2"
echo "$i" >> "$png2"
done
rm $tmp
rm $tmp2
found=true
echo "done"
else
quant=`expr $quant - 2`
echo "too big ($size)"
fi
done
[-- Attachment #4: Type: text/plain, Size: 101 bytes --]
--
Big Gaute http://www.srcf.ucam.org/~gs234/
Are we on STRIKE yet?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Coloured faces: 740 bytes is too much.
2003-04-13 13:48 Coloured faces: 740 bytes is too much Gaute B Strokkenes
@ 2003-04-15 21:48 ` Lars Magne Ingebrigtsen
2003-04-17 23:05 ` Gaute B Strokkenes
0 siblings, 1 reply; 3+ messages in thread
From: Lars Magne Ingebrigtsen @ 2003-04-15 21:48 UTC (permalink / raw)
Gaute B Strokkenes <gs234@cam.ac.uk> writes:
> As luck would have it, the 10-colour version of the 9-colour image
> that I have in this image is precisely 739 bytes. When I base64
> encode it I get a header that is too long.
Oops. A miscalculation on my part. I calculated 33% + newlines, but
there needs to be a space on the beginning of each line as well. The
real limit is 726 bytes, and I've now updated the web page.
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Coloured faces: 740 bytes is too much.
2003-04-15 21:48 ` Lars Magne Ingebrigtsen
@ 2003-04-17 23:05 ` Gaute B Strokkenes
0 siblings, 0 replies; 3+ messages in thread
From: Gaute B Strokkenes @ 2003-04-17 23:05 UTC (permalink / raw)
On 15 apr 2003, larsi@gnus.org wrote:
>Gaute B Strokkenes <gs234@cam.ac.uk> writes:
>
>>As luck would have it, the 10-colour version of the 9-colour image
>>that I have in this image is precisely 739 bytes. When I base64
>>encode it I get a header that is too long.
>
>Oops. A miscalculation on my part. I calculated 33% + newlines, but
>there needs to be a space on the beginning of each line as well. The
>real limit is 726 bytes, and I've now updated the web page.
That's execellent--but let's not forget the obvious patch to
gnus-fun.el:
Index: gnus-fun.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-fun.el,v
retrieving revision 6.44
diff -u -r6.44 gnus-fun.el
--- gnus-fun.el 16 Apr 2003 13:20:01 -0000 6.44
+++ gnus-fun.el 16 Apr 2003 17:10:36 -0000
@@ -115,7 +115,7 @@
(format gnus-convert-image-to-face-command
(shell-quote-argument (expand-file-name file))
quant)))
- (if (> (length attempt) 740)
+ (if (> (length attempt) 726)
(progn
(setq quant (- quant 2))
(message "Length %d; trying quant %d"
@@ -155,10 +155,10 @@
(defun gnus-convert-png-to-face (file)
"Convert FILE to a Face.
FILE should be a PNG file that's 48x48 and smaller than or equal to
-740 bytes."
+726 bytes."
(mm-with-unibyte-buffer
(insert-file-contents file)
- (when (> (buffer-size) 740)
+ (when (> (buffer-size) 726)
(error "The file is %d bytes long, which is too long"
(buffer-size)))
(gnus-face-encode)))
--
Big Gaute http://www.srcf.ucam.org/~gs234/
I decided to be JOHN TRAVOLTA instead!!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-04-17 23:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-13 13:48 Coloured faces: 740 bytes is too much Gaute B Strokkenes
2003-04-15 21:48 ` Lars Magne Ingebrigtsen
2003-04-17 23:05 ` Gaute B Strokkenes
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).