Discussion:
Problems converting PDF to TIF
Cristian Livadaru
2010-10-06 16:18:55 UTC
Permalink
Hi list,

I have a strange issue converting a PDF file to TIF.
If I do it like this:

convert testfax.pdf '-compress' 'Fax' '+antialias' '-support' '0' '-filter' 'point' '-resize' '1728' '-density' '204x98' '-monochrome' '-define' 'quantum:polarity=min-is-white' testfax3.tif

The resulting file is:

TIFF 1728x2236 1728x2236+0+0 DirectClass 1-bit 90.0059kb

If I move the testfax.pdf to the end, like this:

convert '-compress' 'Fax' '+antialias' '-support' '0' '-filter' 'point' '-resize' '1728' '-density' '204x98' '-monochrome' '-define' 'quantum:polarity=min-is-white' testfax.pdf testfax3.tif

the resulting file is:

TIFF 1728x1074 1728x1074+0+0 DirectClass 1-bit 44.0859kb

So I am very confused. Any idea why?


Regards, Cristian
Wolfgang Hugemann
2010-10-09 10:10:11 UTC
Permalink
This is caused by the relative ordering of the 'density' statement and
the input file. Try the following simple example:

convert -size 200x200 xc:blue test.pdf

This will embed a raster image of 200x200 pixels into a PDF.
Then try

convert test.pdf -density 200x100 post.tif
convert -density 200x100 test.pdf pre.tif

It will turn out that post.pdf will have 200x200 pixels and pre.pdf will
have will have 556x278 pixels.

In the first command, the PDF is read assuming equal resolution in x-
and y-direction and the resolution of the TIF ist set to 200x100.

In the latter case, the PDF is read assuming a resolution of 200x100
(instead of the 72x72 standard resolution), resulting in dimensions of
200*200/72 = 556 in the x-direction and 200*100/72 = 278 in the y-direction.

Greetings from Münster, Germany
Wolfgang Hugemann
Cristian Livadaru
2010-10-09 10:29:49 UTC
Permalink
Post by Wolfgang Hugemann
This is caused by the relative ordering of the 'density' statement and
convert -size 200x200 xc:blue test.pdf
This will embed a raster image of 200x200 pixels into a PDF.
Then try
convert test.pdf -density 200x100 post.tif
convert -density 200x100 test.pdf pre.tif
It will turn out that post.pdf will have 200x200 pixels and pre.pdf will
have will have 556x278 pixels.
In the first command, the PDF is read assuming equal resolution in x-
and y-direction and the resolution of the TIF ist set to 200x100.
In the latter case, the PDF is read assuming a resolution of 200x100
(instead of the 72x72 standard resolution), resulting in dimensions of
200*200/72 = 556 in the x-direction and 200*100/72 = 278 in the y-direction.
Thanks for you help. I am using Paperclip for Rails (which uses imagemagick) to convert the images. Since the solution with changing the filename position does work I just wrote my own processor for Paperclip and moved the filename position. I was just curios why that was happening.
Post by Wolfgang Hugemann
Greetings from Münster, Germany
cool ... did spend quite some time in Muenster.
Greetings from Vienna.

Cristian Livadaru
Post by Wolfgang Hugemann
Wolfgang Hugemann
_______________________________________________
Magick-users mailing list
http://studio.imagemagick.org/mailman/listinfo/magick-users
Wolfgang Hugemann
2010-10-09 10:50:14 UTC
Permalink
Another hint:
I would rather avoid the '-resize' parameter in the command line.

Instead, I would set the '-density' parameter (before reading the input
file!) properly, such that the raster images have the desired
resolution. This will give better results, as the PDF is rasterised once
and for good.

Wolfgang Hugemann
Cristian Livadaru
2010-10-09 16:43:35 UTC
Permalink
Post by Wolfgang Hugemann
I would rather avoid the '-resize' parameter in the command line.
Instead, I would set the '-density' parameter (before reading the input
file!) properly, such that the raster images have the desired
resolution. This will give better results, as the PDF is rasterised once
and for good.
Wolfgang Hugemann
is the extra work worth it? After all ... this TIF is going to be sent as fax.

Cris

Loading...