Last active
July 15, 2021 16:43
-
-
Save yudoufu/8a19824e3f8d647ce14eecd2585c8ccb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
main() { | |
input=~/Downloads/testfifle.pdf | |
outdir="./thumb" | |
prefix="thumb" | |
rm -rf $outdir && mkdir -p $outdir | |
echo "---- single task" | |
single_runner $input $outdir $prefix | |
rm -rf $outdir && mkdir -p $outdir | |
echo "---- separated task" | |
separate_runner $input $outdir $prefix | |
} | |
separate_runner() { | |
local input=$1 | |
local outdir=$2 | |
local prefix=$3 | |
rm -rf ./tmp && mkdir -p ./tmp | |
pagenum=$(pdfinfo $input |grep Pages | cut -f2 -d ':' | tr -d " \n") | |
echo "- separate to $pagenum pages" | |
time pdfseparate $input ./tmp/$prefix-%d.pdf | |
echo "- convert" | |
time seq 1 $pagenum | xargs -L 1 -P $pagenum -I {} pdftocairo -png -transp -r 150 -singlefile ./tmp/$prefix-{}.pdf $outdir/$prefix-{} | |
} | |
single_runner() { | |
local input=$1 | |
local outdir=$2 | |
local prefix=$3 | |
time pdftocairo -png -transp -r 150 $input $outdir/$prefix | |
} | |
# call main. | |
main "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
macは6coreなので早くて当たり前ではある。。。