2009-08-16 17:00:08 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Convert a set of image files to new file format
|
|
|
|
#
|
|
|
|
# usage:
|
|
|
|
#
|
|
|
|
# example% batch_image_convert <new image type> image1 image2 etc
|
|
|
|
#
|
|
|
|
# writes output images image1.* and image2.* where * is the new file type.
|
|
|
|
|
|
|
|
# default prefix
|
|
|
|
VIPSHOME=${VIPSHOME-@prefix@}
|
|
|
|
|
|
|
|
name=`basename $0`
|
|
|
|
|
|
|
|
# check args
|
2012-11-13 15:11:34 +01:00
|
|
|
if [ $# -lt 2 ]; then
|
2009-08-16 17:00:08 +02:00
|
|
|
echo "usage: $name <new image type> image1 image2 ..."
|
|
|
|
echo
|
|
|
|
echo "$name uses VIPS to convert a group of image files of"
|
|
|
|
echo "any image format into a new group of images all of the same"
|
|
|
|
echo "image format. VIPS can read almost any standard image format"
|
|
|
|
echo "but it can only write VIPS, JPEG, TIFF, PPM/PBM/PGM or PNG."
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-11-13 15:11:34 +01:00
|
|
|
type=$1
|
|
|
|
shift
|
|
|
|
|
2009-08-16 17:00:08 +02:00
|
|
|
# convert each argument
|
|
|
|
for i in $*; do
|
|
|
|
# drop the suffix on the filename
|
|
|
|
base=${i%*.*}
|
|
|
|
echo "Converting $i to $base.$type ..."
|
|
|
|
|
|
|
|
if [ -f $base.$type ]; then
|
|
|
|
echo "$base.$type already exists skiping $i"
|
|
|
|
else
|
|
|
|
$VIPSHOME/bin/vips im_copy $i $base.$type
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|