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:
- 313024_Page_1_Imag开发者_如何转开发e_0001.png
- 313024_Page_1_Image_0002.png
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.
精彩评论