Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
wchelly@hotmail.com
Posts: 14
Joined: 2011-04-16T22:18:03-07:00
Authentication code: 8675308

Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by wchelly@hotmail.com »

I have a collection of 10,000 or so PDF files that need to be converted to Multi-Page Tiff's. I would like to group the files and do this in chunks. At some point I would like to also do this on Windows, but at this point we are just working on Linux.

Using ImageMagick 6.4.5 and 'Q' 16, and the platform (Linux) and at this point we are just using the convert command directly with no API. (Python is the scripting language I know the best, however)

The code that I've tried is this...

convert multipage.pdf img_%d.tif
convert *.tif -adjoin output.tif

It works to convert one image file but it makes a duplicate page 1 (so there are two page 1 files in the output)
-- I'd like to know what is creating this problem and how to fix it.
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by whugemann »

You are making things too complicated.

convert test.pdf test.tif

will already convert the PDF into a multipage TIFF, with no need for interim steps.

Wolfgang Hugemann
Wolfgang Hugemann
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by anthony »

Basically IM will use store multiple images into one file, if that file can accept it, AND you don't specify a %d or +adjoin

See IM Examples, Saving Images, Writing Multiple Images
http://www.imagemagick.org/Usage/files/#adjoin
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
wchelly@hotmail.com
Posts: 14
Joined: 2011-04-16T22:18:03-07:00
Authentication code: 8675308

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by wchelly@hotmail.com »

I tried Wolfgangs commands, and the problem we have with this is that it only converts the first page of the PDF. Pages 2-N do not get converted or even transferred. When I start with a 4 page PDF, the output is a 1 page TIF. This is what led us to adding the extra commands which does convert all of the pages, we just get an extra page 1. :)

Anthony, we looked at your link. I understand from the examples what the commands are suppose to do but I'm not any closer to making it happen.

I wonder if there could be something about the formatting of the PDF that could interfere with the conversion??
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by fmw42 »

This seems to work just fine for me on IM 6.6.9.5 Q16 Mac OSX Tiger

convert zelda3.png lena2.png checks.png test.pdf
convert test.pdf test.tif

Both test.pdf and test.tif each have 3 frames/pages.

Perhaps you have the wrong device specified in delegates.xml file for pdf, such that it allows transparency but not multiple pages. I am not really an expert on this and I could be wrong. So hopefully Anthony or some one else can clarify this.

Also how many frames/pages do you have in your pdf files? Could you be running out of memory?
wchelly@hotmail.com
Posts: 14
Joined: 2011-04-16T22:18:03-07:00
Authentication code: 8675308

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by wchelly@hotmail.com »

I don't think it's a memory issue, the PDF's I'm using have only 4 pages. I've switched to different PDF's and still having the same issue. I found the topic "possible bug converting acrobat pdf to other formats" in the list after searching for PDF Delegates....after reading through it sounds like it may be a version problem. They created a patch in a newer version so maybe I'll try the newer version. I have to admit that I am an ameteur so I would appreciate any input on this theory. The link is below. Thanks

http://www.wizards-toolkit.org/discours ... =3&t=18001
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by fmw42 »

wchelly@hotmail.com wrote:I don't think it's a memory issue, the PDF's I'm using have only 4 pages. I've switched to different PDF's and still having the same issue. I found the topic "possible bug converting acrobat pdf to other formats" in the list after searching for PDF Delegates....after reading through it sounds like it may be a version problem. They created a patch in a newer version so maybe I'll try the newer version. I have to admit that I am an ameteur so I would appreciate any input on this theory. The link is below. Thanks

http://www.wizards-toolkit.org/discours ... =3&t=18001

That could very well be your problem and an upgrade to the most current version of IM would be best if you can do that.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by anthony »

NOTE that all PDF images generated will be raster wrapped PDF images, and as such has a internal 'ideal' density or resolution.

Other people have had problems geting small PDF's that work well. one of the best methods has been to save images as JPEG and then convert those to PDF using non-IM tools.

See IM examples, Postscript/PDF Output Alternatives
http://www.imagemagick.org/Usage/format ... turnatives
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
wchelly@hotmail.com
Posts: 14
Joined: 2011-04-16T22:18:03-07:00
Authentication code: 8675308

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by wchelly@hotmail.com »

hmmm.....the whole point of doing this was to reduce the amount of work. If I have to convert from PDF-->JPEG (Non IM)-->PDF---> TIF(IM) that is a whole lot more work than I had to begin with. These are text documents.... 10,000 of them or so, that need to be converted to TIF. I am beginning to think that it would be smarter just to get some other software to do this. My husband has used this software all the time (for many many years) for other imaging tasks, and he tells me he has never had this much difficulty either installing it or running functions. I think I am going to have to seriously consider my alternatives.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by anthony »

The problem is that PDF is not really a Raster Image Format. Which is what ImageMagick is designed to work with. basically the wrong tool for the job.

See A Word about Vector Image Formats
http://www.imagemagick.org/Usage/formats/#vector
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
wchelly@hotmail.com
Posts: 14
Joined: 2011-04-16T22:18:03-07:00
Authentication code: 8675308

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by wchelly@hotmail.com »

I understand what you are saying here, it can be put into a script to make it efficient.
Last edited by wchelly@hotmail.com on 2011-04-20T22:46:53-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by fmw42 »

I don't understand Anthony's reply. Seems like going from vector to raster is just what you wanted. It works for me in IM 6.6.9.5 Q16. The quality of the result will depend upon the density you use for reading in the pdf file.

convert -density xxx image.pdf image.tif

or

convert density xxx image.pdf -resize yyy% image.tif

for example, the latter is called supersampling.

For density=72x4=288 you would use a -resize of 25%. But if you want a larger tiff image, just leave off the -resize and find the density you desire to produce the tif size you want.

I suspect you problem with not getting multiple frames for the tif is either a bug in your version of IM or an issue with the proper device for the PDF in your delegates.xml file. See the comments in http://www.wizards-toolkit.org/discours ... =3&t=18001.

So the issue is really why you cannot get an updated IM to install, in my opinion.
wchelly@hotmail.com
Posts: 14
Joined: 2011-04-16T22:18:03-07:00
Authentication code: 8675308

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by wchelly@hotmail.com »

I see what you are saying and I agree that updating my versionI is necessary at this point, and unless anyone has any suggestions about these libraries, I am going to have to wipe my whole computer and start over.

The issue that Andrew raised is one of quality, I think if I understood him correctly. It's not that it's impossible to do, but the quality of the converted image may be an issue simply because of the way the software works. I guess the only way to know for sure is to test it.
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by whugemann »

I really don't understand the fuzz. We are converting PDFs to TIFFs and JPEGs with IM on a regular basis. And it is just as easy as skeched by me. Give me a link to your four pages PDF and I will give it a try.

Wolfgang
Wolfgang Hugemann
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Convert Multi-page PDF(s) to Multi-page Tiff(s)

Post by fmw42 »

As to quality, you can always supersample. It takes a bit more time, but you get better results.

convert -density 288 image.pdf -resize 25% resultimage.tif

72dpi*4=288 and 1/4=25%

or just make the tiff file bigger by leaving off or making the resize % larger.
Post Reply