-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.sh
executable file
·66 lines (52 loc) · 1.09 KB
/
create.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# @author Fanny Hasbi
# @website https://fannyhasbi.id
# Declare variables
PRIMITIVE="/usr/local/bin/primitive"
help="Usage : ./create.sh path/to/picture.jpg 5 100"
inputfile=$1
outputfolder="./output/"
ext="jpg"
prefix="haz"
imagecount=$2
shapecount=$3
# Check if argument exists
if [ -z "$1" ]; then
echo "Please specify the image path"
echo "$help"
exit 1
fi
if [ -z "$2" ]; then
echo "Please specify the image count"
echo "$help"
exit 1
fi
if [ -z "$3" ]; then
echo "Please specify the shape count"
echo "$help"
exit
fi
# Check if output file and folder exists
if [ ! -f $inputfile ]; then
echo "Image doesn't exist"
exit 1
fi
if [ ! -d $outputfolder ]; then
echo "Output folder doesn't exist"
exit 1
fi
# main generator
i=1
while [[ $i -le $imagecount ]];
do
printf "Generating image #$i... "
index=$i
name="$prefix-$index.$ext"
output="$outputfolder$name"
comm="$PRIMITIVE -i $inputfile -o $output -n $shapecount -m 1"
eval $comm
printf "DONE : $output\n"
(( i = i + 1))
done
echo "==== DONE ===="
echo "Generated images are under $outputfolder"