diff options
author | Hendrik Jäger <gitcommit@henk.geekmail.org> | 2023-02-22 11:37:18 +0100 |
---|---|---|
committer | Hendrik Jäger <gitcommit@henk.geekmail.org> | 2023-02-22 11:37:18 +0100 |
commit | e5b5ca1f1628248349ef81a46abdf48be2a3330c (patch) | |
tree | 59a1ab0abcc863adbdf3a826716010c0fc892d46 /.zsh_functions/henks_scan_postproc | |
parent | f9783cb5764dc1fba551fb577df0da08acd9e74a (diff) |
fix: stick to namespace
Diffstat (limited to '.zsh_functions/henks_scan_postproc')
-rw-r--r-- | .zsh_functions/henks_scan_postproc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/.zsh_functions/henks_scan_postproc b/.zsh_functions/henks_scan_postproc new file mode 100644 index 0000000..e721f4c --- /dev/null +++ b/.zsh_functions/henks_scan_postproc @@ -0,0 +1,30 @@ +setopt PIPE_FAIL + +local resize_by +local img +resize_by="$1" +shift +for img in $* +do + echo "Processing ${img} ..." + # mostly to remove the alpha channel so ocrmypdf can work with it + # does not seem to work all the time, so 'convert' is used as well below + # still nice to optimize + optipng "${img}" + if [ $? -ne 0 ] + then + echo "optipng failed" + return + fi + # resize + # and remove alpha channel so ocrmypdf can work with it + # ocrmypdf does the quantization of the png which reduces size drastically + convert -resize $resize_by% -alpha off "$img" - \ + | ocrmypdf - "$(basename $img .png).pdf" + if [ $? -ne 0 ] + then + echo "convert or ocrmypdf failed" + return + fi +done + |