Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Imagemagick for digital foto frame 480x234

14 views
Skip to first unread message

OpaPiloot

unread,
Nov 12, 2007, 10:37:41 AM11/12/07
to
The popular 480x234 digital foto frame has an odd aspect ratio.
Its resolution is not as specified 480/234, but after trying to count
the pixels
I think it's 416x234, which corresponds to an aspect ratio of 16:9 i.e.
1.7778
However, I noticed that 832x468 pictures are displayed notably sharper
than 416x234.
When preparing pictures with my favorite photo editor, I crop all foto's
in landscape format,
not wider than 16:9.
Normally, narrower pictures will have black borders at both sides when
displayed.
I wanted these borders in a color that is the average of the picture.
I use Imagemagick convert to shrink the picture to 1x1 and then use the
color of this pixel.
This appears to work wonderfully.
Then I use Imagemagick montage to make 832x468 pictures with optional
side borders.

The following script runs on my windows XP system, with the MKS (Unix
lookalike) toolset and Imagemagick installed.
It should also run with Cygwin and under Linux or other Unix lookalikes.
Besides convert and montage, sh, od and awk are used.
Maybe there is a more elegant way to obtain the average color, but I
don't know it.

####################################################################
#!sh
# current directory contains source JPG files
# $DES is where the prepared JPG files are stored
# $TMP is a temporary directory
GEO=832x468 # geometry of target JPG files and resize value
#
for F in *.jpg
do
convert -resize 1x1 "$F" "$TMP/1x1.bmp"
od -A n -j 54 -t u1 "$TMP/1x1.bmp" | awk -v f="$F" -v des="$DES/" -v
geo="$GEO" '
{
print "montage -geometry", geo, "-resize", geo, "-background rgb\\(" $3
"," $2 "," $1 "\\) \"" f "\" \"" des f "\"";
exit;
}'
done | sh -x
####################################################################

--
Have fun, Bert

0 new messages