-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflicker_imgs
123 lines (113 loc) · 3.91 KB
/
flicker_imgs
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
#
# flicker_cmp [options] image1 image2 ...
#
# Generate and display an animation of the images given with 1/2 second delay
# so that you can see and compare the very slight differences between the two
# images. A label is added to the image so you know which image is which.
#
# Additional options allow you to resize scale a specific area of interest
# in the two images, so you can more closely check on slight color changes
# or look closely at much larger images.
#
# Any number of images (even just one, or a whole animation) may be given.
#
# OPTIONS
# -d delay the delay for each frame in centi-seconds (def = 50)
# -l label Set label handling to this. EG: '%l' or '%s' (def = '%f')
# -b color label/background fill color
#
# -r size resize image to this size (pixels or percentage)
# -s size scale image to this size (pixels or percentage)
# -c crop crop/extent images at given offset prior to scaling
# -j size limit the jpeg reading (for really large images)
#
# -o file output to this image file, don't display
#
# Examples...
#
# Compare two enlarged images
#
# flicker_cmp -s 300% rose_1.png rose2.png
#
# Check a area where two images were merged (from "overlap" script)
#
# flicker_cmp -c 200x200+550+550 -scale 300% map_orig.png merged_*.png
#
# Advanced pre-prepared label handling (broken? Why?)
#
# convert -size 100x100 xc:red xc:blue -set color '%[pixel:u]' miff:- |\
# flicker_cmp -l '%[color]' -d 100 -
#
###
#
# Last update: 20 March 2013 (new options added)
#
# Created by Anthony Thyssen 5 September 2007
#
PROGNAME=$(type "$0" | awk '{print $3}') # search for executable on path
PROGDIR=$(dirname "$PROGNAME") # extract directory of program
PROGNAME=$(basename "$PROGNAME") # base name of program
Usage() { # output the script comments as docs
echo >&2 "$PROGNAME:" "$@"
sed >&2 -n '/^###/q; /^#/!q; s/^#//; s/^ //; 3s/^/Usage: /; 2,$ p' "$PROGDIR/$PROGNAME"
exit 10;
}
resize=''
crop=''
color=skyblue
delay=50
output=''
while [ $# -gt 0 ]; do
case "$1" in
--help|--doc*) Usage ;;
-b|-background) shift; color="$1" ;; # label/background fill color
-l|-label) shift; label="$1" ;; # set displayed label to this string
-d|-delay) shift; delay="$1" ;; # animation delay
-c|-crop) shift; crop="$1" ;; # crop/extent images
-r|-resize) shift; resize="-resize $1" ;; # resize image to this size
-s|-scale) shift; resize="-scale $1" ;; # scale image to this size
-j|-jpeg) shift; jpeg="-define jpeg:size=$1" ;;
-o|-output) shift; output="$1" ;; # output to file, don't display
-) break ;; # STDIN, end of user options
--) shift; break ;; # end of user options
-*) Usage "Unknown option \"$1\"" ;;
*) break ;; # end of user options
esac
shift # next option
done
# add crop/extent option before any resize
# Not this goes wrong with negative offsets
# but that does not make sense, so okay!
if [ "X$crop" != 'X' ]; then
case "$crop" in
*[+-]*)
extent=$(echo "$crop" | sed 's/[+-].*//')
;;
*)
extent="$crop"
crop="$crop+0+0"
gravity="-gravity center"
;;
esac
resize="$gravity -crop $crop! -extent $extent $resize"
fi
# set labeling defaults, different for stdin vs filenames
if [ "X$label" = "X" ]; then
case "$*" in
-|*:-) label='%s:%l' ;;
*) label='%f' ;;
esac
fi
#convert $jpegsize \
#convert "$@" -set label "$label" -background $color $resize miff:- |
# Do each image seperatally as they could be very large
for img in "$@"; do
convert $jpeg "$img" -set label "$label" -background $color $resize miff:-
done |
montage - -geometry +0+0 -tile 1x1 -background $color miff:- |
if [ "X$output" = "X" ]; then
animate -delay "$delay" -dispose background -loop 0 -
else
convert - -delay "$delay" -dispose background -loop 0 "$output"
fi