开发者

Batch merging image files to pdf files using perl in windows

I have a bunch of image files in this naming format:

  • 313024_Page_1_Image_0001.png
  • 313024_Page_1_Image_0002.png
  • 313025_Page_1_Image_0001.png
  • 313025_Page_1_Image_0002.png
  • 313025_Page_2_Image_0001.png

And I would like to convert the files with the same numbers (pre "Page_") to a single pdf with that name. For example, using the above five files:

would merge to 313024.pdf

and

  • 313025_Page_1_Image_0001.png
  • 313025_Page_1_Image_0002.png
  • 313025_Page_2_Image_0001.png

would merge to 313025.pdf

I would like to be able to run this script in Perl in windows.

Thanks in advance, Jake


Imagemagick includes a convert program that will take PNG files and make PDF files from them, e.g.:

$ convert source.png -compress zip source.pdf

You can also append image files into a larger image file, before converting to PDF:

$ convert {listOfImageFilenames} -append -compress zip verticallyStitchedFilename.pdf

You can run this within a Perl script via system() or through the Imagemagick API (example).

You'll probably need to adjust these calls for the special way that Microsoft Windows does things, but it shouldn't be too hard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜