-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_read
More file actions
executable file
·46 lines (41 loc) · 835 Bytes
/
Copy pathimage_read
File metadata and controls
executable file
·46 lines (41 loc) · 835 Bytes
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
#!/bin/bash
INFO=$'
Usage:
\timage_read H,W <file or directory>
\timage_read H,W,3 <file or directory>
'
if [ ! -e "$2" ]; then
echo "$INFO" 1>&2
exit 1
fi
case "$1" in
*,*,*,*)
echo "$INFO" 1>&2
exit 1
;;
*,*,3)
OUT_FMT="${1%,*}"
OUT_FMT="-resize ${OUT_FMT##*,}x${OUT_FMT%%,*}! -depth 8 RGB:-"
;;
*,*,*)
echo "$INFO" 1>&2
exit 1
;;
*,*)
OUT_FMT="-resize ${1##*,}x${1%%,*}! -depth 8 GRAY:-"
;;
*)
echo "$INFO" 1>&2
exit 1
;;
esac
if [ -d "$2" ]; then
while IFS='' read -r f; do
[ ! -d "$2/$f" ] || continue
echo "Reading '$2/$f'..." 1>&2
convert "$2/$f" $OUT_FMT || exit 1
done <<<$(ls "$2") || exit 1
else
echo "Reading '$2'..." 1>&2
convert "$2" $OUT_FMT || exit 1
fi