-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflicker
More file actions
executable file
·47 lines (37 loc) · 1.43 KB
/
flicker
File metadata and controls
executable file
·47 lines (37 loc) · 1.43 KB
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
#!/usr/bin/env bash
: '
Generates a flicker animation for a pair of images using ImageMagick.
'
ME=$(basename "$0") && readonly ME
# shellcheck disable=SC2164
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
readonly SCRIPT_PATH
source "${SCRIPT_PATH}"/common
if [[ $# -ne 3 ]]; then
logError "${ME}" "Usage: flicker $(blue "FILE1") $(blue "FILE2") $(green "OUTPUT_FILE")"; exit 1
fi
ERRORS=0
if [ ! -f "${1}" ]; then
ERRORS=1 && logError "${ME}" "First file not accessible at $(sQuote "$(red "${1}")")"
fi
if [ ! -f "${2}" ]; then
ERRORS=1 && logError "${ME}" "Second file not accessible at $(sQuote "$(red "${2}")")"
fi
if [ "${1}" == "${2}" ]; then
ERRORS=1 && logError "${ME}" "Both input files are the same $(sQuote "$(red "${1}")")"
fi
if [ -f "${3}" ]; then
ERRORS=1 && logError "${ME}" "Output file $(sQuote "$(red "${3}")") already exists."
fi
# Ensure that the ImageMagick 'animate' command is installed
animate -version &>/dev/null || \
{ ERRORS=1 && logError "${ME}" "ImageMagick $(sQuote "$(red "animate")") command not found." ; }
# Ensure that the ImageMagick 'convert' command is installed
convert -version &>/dev/null || \
{ ERRORS=1 && logError "${ME}" "ImageMagick $(sQuote "$(red "convert")") command not found." ; }
# If there's any error, exit
if [ "$ERRORS" -ne "0" ]; then
logError "${ME}" "Exiting due to previous errors."; exit 1
else
convert -delay 25 -loop 0 "${1}" "${2}" "${3}"
fi