msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

25 Nov 2007 Adjust images to a digital frame (480×234 pixels)

Posted by

This bash script adjusts images to fit in a digital frame with a resolution of 480×234 pixels however by using the size 832×468 pictures are displayed sharper on some frames. Normally, narrower pictures will have black borders at both sides when displayed. but this script makes the border color the average of the picture.

The following linux tools are used in the script: convert and montage, bash, od and awk. od is part of the textutils package in Debian.

#!/bin/bash
# current directory contains source JPG files
# $DESTINATION is where the prepared JPG files are stored
# $TEMP is a temporary directory
TEMP=TEMP
DESTINATION=DESTINATION
GEO=832x468 # geometry of target JPG files and resize value

for FILE in *.JPG
do
convert -resize 1x1 "$FILE" "$TEMP/1x1.bmp"
od -A n -j 54 -t u1 "$TEMP/1x1.bmp" | awk -v f="$FILE" -v des="$DESTINATION/" -v geo="$GEO" '
{
print "montage -geometry", geo, "-resize", geo, "-background rgb\\(" $3 \
"," $2 "," $1 "\\) \"" f "\" \"" des f "\"";
exit;
}'

done | sh -x

Source: comp.graphics.misc

Tags: , , , , ,

Comments are closed.