Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Single

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?".
Post Reply
tareywolf
Posts: 7
Joined: 2014-01-04T14:02:39-07:00
Authentication code: 6789

Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Single

Post by tareywolf »

I just started using ImageMagick and it is working perfectly for my needs, mostly conversion of file types. I just need to know how to use it to convert multiple page PDFs to single page tiffs or PDFs and also how to convert multiple page tiffs to single tiffs or pdfs, using mogrify, and to also select an output path (-path).

Is there any kind of switch that will delete the original files after they have been converted? Haven't been able to find that.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by snibgo »

To convert a multi-page PDF to a single tiff image (with the input pages beneath each other):

Code: Select all

convert in.pdf -append out.tiff
The same will work if the output is pdf or the input is tiff. However, IM will rasterise an input PDF, so an output PDF will contain one large raster (bitmap) image. If the inputs are large you can gobble memory.

I don't know how to do it in mogrify.

To delete input images after they have been used, try the prefix "ephemeral:".
snibgo's IM pages: im.snibgo.com
tareywolf
Posts: 7
Joined: 2014-01-04T14:02:39-07:00
Authentication code: 6789

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by tareywolf »

Hey thanks....How would I tweak this to do it batch on a whole folder?
tareywolf
Posts: 7
Joined: 2014-01-04T14:02:39-07:00
Authentication code: 6789

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by tareywolf »

...or does this do batch?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by fmw42 »

I was not sure this would work, but it does.

# create two test pdf files each with 3 pages
convert rose: rose: rose: rose1.pdf
convert rose: rose: rose: rose2.pdf

# use mogify to append each page horizontally
mogrify -format tif +append rose*.pdf


For mogrify, see http://www.imagemagick.org/Usage/basics/#mogrify
tareywolf
Posts: 7
Joined: 2014-01-04T14:02:39-07:00
Authentication code: 6789

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by tareywolf »

Hi - I thoroughly perused the website, including the mogrify section. +append isn't the right command... What I have right now will convert a PDF to a Tif and render it in the same format as the original - in other words, if the PDF is multipage, it will output Tif multipage. If the PDF is single page it will output as a single tif.

mogrify -format tif *.pdf

Is there some script or switch that will tell mogrify to convert PDF multi to single tif? Not appended as one image, but each output file coming out one after another into the folder, with the ".tif" filetype?

I have something I am using right now. It does work, though it puts the output into the same directory as the input/bat file I'm running. So either I need to know how to designate an output folder with this command below or learn how to accomplish the same thing with Mogrify:

:: Change %%~ni to %%~ni_%%03d to export out single-page tif's
@ECHO OFF
FOR %%i in (*.pdf) DO (
ECHO Processing "%%i"...
convert -density 300 -units PixelsPerInch -compress Group4 %%i %%~ni_%%03d.tif
)

Thanks.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by snibgo »

snibgo's IM pages: im.snibgo.com
tareywolf
Posts: 7
Joined: 2014-01-04T14:02:39-07:00
Authentication code: 6789

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by tareywolf »

I think another great question is... what language are these shell or mogrify commands in - unix? bash?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by snibgo »

Windows BAT.
snibgo's IM pages: im.snibgo.com
tareywolf
Posts: 7
Joined: 2014-01-04T14:02:39-07:00
Authentication code: 6789

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by tareywolf »

Thanks a lot for your input. The +adjoin doesn't seem to work with mogrify unfortunately. Get a command not recognized error. I'll keep churning away...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by fmw42 »

mogrify only produces one output for each input. It is very simple and does not allow many IM commands. You will likely need to write a script loop over each pdf and then use convert to process to multiple output images.
tareywolf
Posts: 7
Joined: 2014-01-04T14:02:39-07:00
Authentication code: 6789

Re: Mogrify Convert Multi PDF to Single PDFs,Multi Tif to Si

Post by tareywolf »

Thanks... :)
Post Reply