TIF -> PDF file size grows after annotate

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
moby11

TIF -> PDF file size grows after annotate

Post by moby11 »

When I do a simple convert (using 6.4.8 for Windows) from a small tif file to pdf, the file is roughly the same size. When I include any code to annotate, however, the file grows to 2x - 15x the original file size (depending on the source file).

Code: Select all

convert logo: logo.tif
results in a 45KB file.

Code: Select all

convert logo.tif logo.pdf
results in a 46KB file

Code: Select all

convert logo.tif -gravity north -pointsize 10 -fill black -annotate 0 "TEST" logo_annotate.pdf
results in a 75KB file

The file sizes of one of the tif files I'm using goes from 43KB original tif to a 574KB PDF when I use annotate, but only 46KB without.

Interesting clue, even if the text in the annotate is empty " ", it results in the larger file size even though the resulting image is exactly the same as no annotate.

I've tried tif -> ps -> pdf along with various options of compress, flatten, colors, etc. all to no avail.

Any help would be greatly appreciated.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIF -> PDF file size grows after annotate

Post by magick »

You can reduce the image size by converting your truecolor image to colormapped by adding -colors 256 to your command line or by compressing the results. Try -compress zip or -compress RLE.
moby11

Re: TIF -> PDF file size grows after annotate

Post by moby11 »

Thanks for the quick response. That helps quite a bit using the logo image, but still results in files nearly double in size than the original on my actual scanned tif images (44KB to 82KB or 271KB to 567KB). This is a huge improvement over what I had originally found, but I still think there is something that could be done considering this increase occurs even if the text used in annotate is just empty space (" "). If I remove the annotate function, the conversion results in a size much more comparable to the original.

Any other ideas?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIF -> PDF file size grows after annotate

Post by magick »

You could try -compress jpeg. If that does not work, you could try a solution other than ImageMagick.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: TIF -> PDF file size grows after annotate

Post by el_supremo »

The original version had 231 unique colours and was stored as a palette type of image. The annotated image has 258 unique colours which pushed it over the limit for a palette-based image and so it was saved as truecolor. You can force a palette image by adding:

Code: Select all

-type palette
after the annotate.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Post Reply