-
Notifications
You must be signed in to change notification settings - Fork 3
/
tvify
executable file
·41 lines (34 loc) · 1.09 KB
/
tvify
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
#!/usr/bin/env bash
################################################################################
# tvify - this script takes a folder of images and converts them for display on
# a 1080p TV (memory stick or similar). Proper image orientation will be
# maintained, and all available cores will be used to speed up processing.
#
# Dependencies: mogrify (provided by imagemagick)
#
# Version 1
# Matthew Malensek <[email protected]>
################################################################################
print_usage() {
cat <<EOM
Usage: $(basename ${0}) <image_dir>
EOM
}
# First, make sure we actually have the utility we need.
if ! ( which mogrify &> /dev/null ); then
echo "Couldn't find 'mogrify' command!"
echo "Please install imagemagick: http://www.imagemagick.org"
exit 1
fi
dir="${1}"
if [[ ! -d "${dir}" ]]; then
print_usage
exit 1
fi
cpus=$(getconf _NPROCESSORS_ONLN)
if [[ ${cpus} -le 0 ]]; then
echo "Couldn't determine the number of CPUs. Falling back on 1."
cpus=1
fi
find "${dir}" | xargs -t -n1 -P"${cpus}" \
mogrify -resize 1920x1080 -auto-orient