-
Notifications
You must be signed in to change notification settings - Fork 7
/
scale-and-crop-export
executable file
·53 lines (42 loc) · 1.28 KB
/
scale-and-crop-export
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
45
46
47
48
49
50
51
52
53
#!/bin/bash
pwd="`pwd`"
export="$pwd/export"
cropdir="$export/crop"
scaledir="$export/scale"
jobs="$pwd/jobs"
logs="$jobs/log"
nJobs=50
mkdir -p "$scaledir"
mkdir -p "$cropdir"
mkdir -p "$jobs"
mkdir -p "$logs"
n=`find export/ -maxdepth 1 -not -type d -name '*tif' | wc -l`
tasksPerJob=$[$n/$nJobs]
j=1
k=0
script="$jobs/export-scale-crop-$k.job"
echo "#!/bin/bash" > "$script"
for file in `cd $export; ls | grep -P "\.tif$"`
do
if [ $j -ge $tasksPerJob ]; then
chmod a+x "$script"
cd "$logs"
qsub -cwd -pe batch 4 $script # run previous job
cd "$pwd"
j=0
((k++))
# get started on the next job
script="$jobs/export-scale-crop-$k.job"
echo "#!/bin/bash" > "$script"
fi
echo "convert $export/$file -resize 10% $scaledir/$file" >> "$script"
# echo "convert $export/$file -crop 768x768+2900+2400 $export/crop1/$file" >> "$script"
# echo "convert $export/$file -crop 768x768+1550+4500 $export/crop2/$file" >> "$script"
# echo "convert $export/$file -crop 768x768+3970+5440 $export/crop/$file" >> "$script"
# echo "convert $export/$file -crop 768x768+1400+4700 $export/crop/$file" >> "$script"
echo "convert $export/$file -crop 2060x5120+3620+2220 $cropdir/$file" >> "$script"
((j++))
done
cd "$pwd"
chmod a+x "$script"
qsub -cwd -pe batch 4 $script # run previous job