]> git.netwichtig.de Git - user/henk/vcsh/zsh.git/blob - .zsh_functions/henks_scan_postproc
fix: stick to namespace
[user/henk/vcsh/zsh.git] / .zsh_functions / henks_scan_postproc
1 setopt PIPE_FAIL
2
3 local resize_by
4 local img
5 resize_by="$1"
6 shift
7 for img in $*
8 do
9         echo "Processing ${img} ..."
10         # mostly to remove the alpha channel so ocrmypdf can work with it
11         # does not seem to work all the time, so 'convert' is used as well below
12         # still nice to optimize
13         optipng "${img}"
14         if [ $? -ne 0 ]
15         then
16                 echo "optipng failed"
17                 return
18         fi
19         # resize
20         # and remove alpha channel so ocrmypdf can work with it
21         # ocrmypdf does the quantization of the png which reduces size drastically
22         convert -resize $resize_by% -alpha off "$img" - \
23         | ocrmypdf - "$(basename $img .png).pdf"
24         if [ $? -ne 0 ]
25         then
26                 echo "convert or ocrmypdf failed"
27                 return
28         fi
29 done
30