forked from libvips/libvips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
batch_crop.in
46 lines (36 loc) · 848 Bytes
/
batch_crop.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
# Crop a set of image files
#
# usage:
#
# example% batch_crop left top width height image1 image2 etc
#
# writes output images crop_image1, crop_image2
# default prefix
VIPSHOME=${VIPSHOME-@prefix@}
name=`basename $0`
# check args
if [ $# -lt 5 ]; then
echo "usage: $name left top width height image1 image2 ..."
echo
echo "$name writes a new set of images called crop_image1, "
echo "crop_image2, etc., each cropped to the specified size"
exit 1
fi
left=$1
top=$2
width=$3
height=$4
shift 4
# convert each argument
for i in $*; do
dir=`dirname $i`
file=`basename $i`
new=$dir/crop_$file
echo "Cropping $file as $new ..."
if [ -f $new ]; then
echo "$new exists, skipping"
else
$VIPSHOME/bin/vips im_extract_area $i $new $left $top $width $height
fi
done