<<< Date Index >>>     <<< Thread Index >>>

Re: Default image size option



* On 2006.03.12, in <20060312093812.GA4773@Machine2>,
*       "Daryl" <drfenn@xxxxxxxxxxxx> wrote:
> Greetings all,
>               Just curious to see if mutt has or can be configured to
> have a default image attachment size.
> For example suppose I want to send a photo and it's 1600x1200. Instead
> of me using gimp to resize-save-attach etc, can I just parse the photo
> to mutt and its configuration will take care of the size at say 800x640.

You'd have to do this through your mailcap, probably with a small shell
script.  Something like the following might work, but is untested.

.mailcap:
image/jpeg; scaleview.sh %s
image/pjpeg; scaleview.sh %s
image/gif; scaleview.sh %s
image/tiff; scaleview.sh %s

scaleview.sh:
#!/bin/sh

Xmax=800
Ymax=600
tmpdir=${TMPDIR-/tmp}
viewer=xv

original="$1"

umask 077
: > ${tmpdir}/image.$$
: > ${tmpdir}/image.$$.jpg
anytopnm "$original" >${tmpdir}/image.$$
set -- `pnmfile ${tmpdir}/image.$$`
if [ $4 -gt $Xmax -o $6 -gt $Ymax ]; then
        pnmscale -xysize $Xmax $Ymax <${tmpdir}/image.$$ \
        | cjpeg >${tmpdir}/image.$$.jpg
else
        ## It's not necessarily a jpeg, but smart viewers won't care.
        cat "$original" >${tmpdir}/image.$$.jpg
fi
${viewer} ${tmpdir}/image.$$.jpg

rm -f ${tmpdir}/image.$$ ${tmpdir}/image.$$.jpg

-- 
 -D.    dgc@xxxxxxxxxxxx        NSIT    University of Chicago