libvips/tools/batch_image_convert.in

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