2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macでmupdf-toolsとImageMagickを使ってPDFを分割、JPEGに変換

Posted at

やりたかったこと

  • 複数ページのPDFを1ページずつに分割する
  • 分割したPDFをJPEGに変換する
  • (予期せぬタスク)ページサイズが意図したものと違ったのでリサイズ

環境

  • Mac OSX 10.13.1
  • ImageMagick 7.0.7-14
  • mupdf-tools 1.12.0

やったこと

参考:
http://a244.hateblo.jp/entry/2017/03/30/060000
http://o.inchiki.jp/obbr/125

インストール

brew install imagemagick mupdf-tools

PDFを1ページずつJPEGに変換

mutool draw -o %d.jpg input.pdf

ページサイズが意図したものと違ったのでリサイズ

resize.sh
for i in $(seq 1 10) ; do
  convert -resize 666x842 $i.jpg resized/$i.jpg
done

リサイズされたJPEGから分割されたPDFを再生成

topdf.sh
for i in $(seq 1 10) ; do
  convert resized/$i.jpg pdf/$i.pdf
done

振り返り

繰り返し処理が頭悪そうな感じあるが放置されている…。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?