-
Notifications
You must be signed in to change notification settings - Fork 0
/
neural-display-h.sh
69 lines (53 loc) · 2.08 KB
/
neural-display-h.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
67
68
69
#! /bin/bash
size_factor=2
# 1. Defines the content image as a variable
input=$1
input_file=`basename $input`
clean_name="${input_file%.*}"
#Defines the style image as a variable
style=$2
style_dir=`dirname $style`
style_file=`basename $style`
style_name="${style_file%.*}"
#Defines the styled image as a variable
content=$3
content_dir=`dirname $content`
content_file=`basename $content`
content_name="${content_file%.*}"
#Defines the temp directory
temp_dir="./"$clean_name"_temp"""
mkdir $temp_dir
styled_image_w=`convert $clean_name'.png' -format "%w" info:`
styled_image_h=`convert $clean_name'.png' -format "%h" info:`
if [ `echo ${style} | grep -c ','` -gt 0 ] ; then
echo commas detected
#Remove commas
style_nc=`echo $style | tr ',' ' '`
echo commas removed
#find num style images
wc=$(($(wc -w <<< "${style_nc}")))
wc2=`echo $wc 1 | awk '{print $1+$2}'`
content_c=`echo $styled_image_w $size_factor | awk '{print $1/$2}'`
#Create the Comparison
echo Creating output... This may take some time...
montage $content $style_nc -resize "$content_c"x"$styled_image_h" -tile 1x"$wc2" -geometry +0+0 $temp_dir/comparison_resize.png
convert $temp_dir/comparison_resize.png -resize x"$styled_image_h" $temp_dir/comparison.png
montage $temp_dir/comparison.png $input -tile 2x1 -geometry +0+0 comparison_final_h.png
#remove temp directory
rm -rf $temp_dir
else
echo no commas detected
#Remove commas
style_nc=${style/","/" "}
#find num style images
wc=$(($(wc -w <<< "${style_nc}")))
wc2=`echo $wc 1 | awk '{print $1+$2}'`
content_c=`echo $styled_image_w $size_factor | awk '{print $1/$2}'`
#Create the Comparison
echo Creating output... This may take some time...
montage $content $style_nc -resize "$content_c"x"$styled_image_h" -tile 1x"$wc2" -geometry +0+0 $temp_dir/comparison_resize.png
convert $temp_dir/comparison_resize.png -resize x"$styled_image_h" $temp_dir/comparison.png
montage $temp_dir/comparison.png $input -tile 2x1 -geometry +0+0 comparison_final_h.png
#remove temp directory
rm -rf $temp_dir
fi;