-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-rotate-image
executable file
·35 lines (26 loc) · 1.14 KB
/
auto-rotate-image
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
#!/usr/bin/env fish
# auto-rotate-image - Correct image rotation based on its metadata. Outputs the filename of the result.
# Some software will write rotation information into an image incorrectly, which causes the image to show up wrong in certain programs. This script uses the rotation metadatum to write a rotated image sans that metadatum. The resulting image(s) are echoed to standard output.
# settings:
# The directory to save the resulting files in. When unset (as per the default), saves in /tmp/SCRIPT/ , where SCRIPT is the filename of this script.
set result_dir
# code:
set -- script "$(path basename (status filename))"
argparse -n auto-rotate-image 'h/help' -- $argv
if test -z "$result_dir"
set result_dir "/tmp/$script"
end
if set -q _flag_h
echo "$script - Correct image rotation based on its metadata. Outputs the filename of the result."
echo "Usage: $script image [image ...]"
echo
echo " -h/--help - Print help and exit."
exit
end
mkdir -p "$result_dir"
for file in $argv
set file (path basename "$file")
set output "$result_dir$file"
convert "$file" -auto-orient "$output"
echo "$output"
end