Skip to content

Instantly share code, notes, and snippets.

@sasasin
Created October 7, 2012 07:56
Show Gist options
  • Save sasasin/3847479 to your computer and use it in GitHub Desktop.
Save sasasin/3847479 to your computer and use it in GitHub Desktop.
ディレクトリに集めた画像ファイルを、PDFファイルに固めるスクリプトです。コミックや小説のため「右から左へ」のフラグをPDFに埋め込んでいます。
#!/bin/sh
export MAGICK_TEMPORARY_PATH=$HOME
find "$@" -type d | while read f; do
OUTDIR=$f
rm -f "$(pwd)"/"${OUTDIR}".pdf
echo "converting $f "
(jpg2pdf.pl \
-d "$(pwd)"/"${OUTDIR}" \
-o "$(pwd)"/"${OUTDIR}".pdf \
-s "A4" -t "" -a "" \
) \
|| convert -limit memory 2gb -limit map 2gb \
"$(pwd)"/"${OUTDIR}"/*.{jpg,JPG,jpeg,JPEG,png,PNG} \
"$(pwd)"/"${OUTDIR}".pdf
run_pdfdirection.sh \
"$(pwd)"/"${OUTDIR}".pdf \
"$(pwd)"/"${OUTDIR}".R2L.pdf \
"R2L"
mv "$(pwd)"/"${OUTDIR}".R2L.pdf \
"$(pwd)"/"${OUTDIR}".pdf
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment