TIFF to PDF with compression

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
crazychris
Posts: 3
Joined: 2011-08-17T17:46:00-07:00
Authentication code: 8675308

TIFF to PDF with compression

Post by crazychris »

I have a folder full of very large TIFF files (between 30MB and 350MB each) that need to be converted into a PDF file. I can easily use convert to create it, but the size becomes an issue very quickly. I can convert the TIFF files to JPEGs and convert them into a PDF and save 80% of the size which still maintaining the 100% scale and 100% quality. However I am wanting a single-line method rather than a multi-stage one as this is a batched process to run through lots of folders, and due to the size of the files, it takes an eternity to run too.

My current method is to introduce some compression on the TIFF files

Code: Select all

convert -limit memory 0 -limit map 0 *.tif -compress zip -quality 100 out.pdf
But this is still way larger than using intemedary JPG files and making the PDF from them.

So, is there a way I can compress multiple TIFF files (not a multipage TIFF) into a PDF and achieve good (or great) compression, without loss of size or quality, without having to do a convert to JPEG in-between?

Using ImageMagick .6.78 Q16 windows in portable install mode.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TIFF to PDF with compression

Post by snibgo »

If you find jpeg compression work for you, you might use that instead of zip. This also means you can use "-quality" for very small PDF sizes.

Code: Select all

convert ... -quality 40 -compress jpeg out.pdf
snibgo's IM pages: im.snibgo.com
crazychris
Posts: 3
Joined: 2011-08-17T17:46:00-07:00
Authentication code: 8675308

Re: TIFF to PDF with compression

Post by crazychris »

Bingo!

I needed to retain 100% quality (no compression) but I wasn't aware of the jpeg compression option! Altered to:

Code: Select all

convert -limit memory 0 -limit map 0 *.tif -compress jpeg -quality 100 out.pdf
and the resulting file is now way smaller!

v1: TIFF -> PDF = 2.1GB
v2: TIFF -> zip compression -> PDF = 652MB
v3: TIFF -> jpeg compression -> PDF = 526MB

Doesn't quite meet the 482MB version that Acrobat produces, but I have a suspicion they added just a wee bit of compression in there!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TIFF to PDF with compression

Post by snibgo »

crazychris wrote:I needed to retain 100% quality (no compression) ...
Sadly, jpeg compression is always lossy, even at quality "100". If you don't want to lose any data, don't use jpeg.

EDIT: although, having said that, I see that "convert -list compress" includes "losslessjpeg". You might experiment with that, and other methods.
snibgo's IM pages: im.snibgo.com
Post Reply