libvips/tools/batch_image_convert.in
John Cupitt e0d4ed89ff reorganise tools/ dir
The subdir in tools are no lonmger necessary. Also, remove ther old bin
links feature, not very useful anymore.
2011-04-06 12:06:32 +01:00

44 lines
1002 B
Bash

#!/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`
type=$1
shift
# check args
if [ $# -lt 1 ]; then
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
# 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