Page 1 of 1
Converting Multiple Images into a PDF File
Posted: 2017-03-21T15:25:29-07:00
by cageybee
Hi,
I have a folder with a bunch of images in it. Some images have a particular string in the filename, like "mhk". I need to grab only those images from that folder and put them into a PDF file, with each image having its own page.
I tried different things but I can't even get past just combining them into a single image, let alone into a PDF.
Here is what I have:
Code: Select all
magick montage `dir /b | findstr mhk` -mode concatenate -tile 1x out.png
Somebody please help.
Thanks,
Ramin
Re: Converting Multiple Images into a PDF File
Posted: 2017-03-21T16:03:50-07:00
by snibgo
You say you want the PDF "with each image having its own page".
Then you say "I can't even get past just combining them into a single image".
Which of these do you want? A PDF with a single page, with a single image that is a combination of all the input images? Then:
Code: Select all
magick montage *mhk* -mode concatenate -tile 1x out.pdf
Or do you want a PDF with as many pages as there are input images, one image per page? Then:
Re: Converting Multiple Images into a PDF File
Posted: 2017-03-22T06:30:37-07:00
by cageybee
snibgo wrote: ↑2017-03-21T16:03:50-07:00
You say you want the PDF "with each image having its own page".
Then you say "I can't even get past just combining them into a single image".
Which of these do you want? A PDF with a single page, with a single image that is a combination of all the input images? Then:
Code: Select all
magick montage *mhk* -mode concatenate -tile 1x out.pdf
Or do you want a PDF with as many pages as there are input images, one image per page? Then:
Thank you very much! I wanted the second one but the first one I will save for future use. Thanks a million!
Re: Converting Multiple Images into a PDF File
Posted: 2017-03-22T06:46:16-07:00
by cageybee
snibgo,
I have a second question for you, if I may. How about this scenario:
I have several banners: Page1.png, Page2.png, ... Page10.png, and I have lots of images but they are in groups. Each group is identified with a special alphanumeric code, like "mhk" so, it looks like this:
image1mhk.png
image2mhk.png
...
image10mhk.png
image11xyz.png
image12xyz.png
...
image20xyz.png
...
And the group number varies. The group list can be in a text file like so:
mhk
xyz
...
I need to montage the banner with the image and then put it into its own PDF page. So, it will look like this.
=====Page 1 of PDF=====
Page1.png
image1mhk.png
=====Page 2 of PDF=====
Page2.png
image2mhk.png
...
=====Page 11 of PDF=====
Page1.png
image11.xyz.png
=====Page 12 of PDF=====
Page2.png
image12xyz.png
...
I would greatly appreciate your help.
Sorry, I am new to ImageMagick and I love it but I don't know much about it and I need to know a lot about it
Re: Converting Multiple Images into a PDF File
Posted: 2017-03-22T08:31:21-07:00
by snibgo
What's the problem? From your OP, you know how to montage two files together, to make a third. You can do that many times (or in a shell loop) to montage each Page*.png file with a image*xyz.png file.
Then you can take each result, making a PDF with one page per result, as I showed you:
I suggest you use leading zeroes in your numbering scheme, so they come out in the order you expect, eg result001.png, result002.png, ... result010.png.
Re: Converting Multiple Images into a PDF File
Posted: 2017-03-22T08:47:48-07:00
by cageybee
snibgo wrote: ↑2017-03-22T08:31:21-07:00
What's the problem? From your OP, you know how to montage two files together, to make a third. You can do that many times (or in a shell loop) to montage each Page*.png file with a image*xyz.png file.
Then you can take each result, making a PDF with one page per result, as I showed you:
I suggest you use leading zeroes in your numbering scheme, so they come out in the order you expect, eg result001.png, result002.png, ... result010.png.
Thank you, snibgo! I will work with that.
Can you also tell me what this command means:
I was looking at your page (
http://im.snibgo.com/spdsiz.htm) and I am confused about the percent sign before and after "IM". When I try using it on my Windows Server it doesn't recognize it. When I am trying to use the "convert" command, it is a Windows command and not a part of the IM. Where can I read more about this stuff?
Thank you so much for helping me! I truly appreciate it.
Re: Converting Multiple Images into a PDF File
Posted: 2017-03-22T09:26:30-07:00
by snibgo
I use an environment variable called IM, which is set to a directory that contains a v6 ImageMagick.
Code: Select all
f:\web\im>echo %IM%
c:\im\ImageMagick-6.9.5-3-Q16\
So my scripts use "%IM%convert" to run that particular version of IM. I have about 50 versions installed.
Another method is to tell IM at installation that you want it to add IM's directory to the front of your system path. Then you can just use "convert" and this will run IM's program, not the Microsoft program.
Re: Converting Multiple Images into a PDF File
Posted: 2017-03-22T09:49:53-07:00
by cageybee
snibgo wrote: ↑2017-03-22T09:26:30-07:00
I use an environment variable called IM, which is set to a directory that contains a v6 ImageMagick.
Code: Select all
f:\web\im>echo %IM%
c:\im\ImageMagick-6.9.5-3-Q16\
So my scripts use "%IM%convert" to run that particular version of IM. I have about 50 versions installed.
Another method is to tell IM at installation that you want it to add IM's directory to the front of your system path. Then you can just use "convert" and this will run IM's program, not the Microsoft program.
Got it. Thank you!