PDF is too small (in cm)

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: PDF is too small (in cm)

Post by pipitas »

fmw42 wrote:I install my delegates from MacPorts, but install IM from source manually
I was trying to do exactly that recently (install IM from source -- but from current SVN, not from an officially released tarball). However, it did not compile for me.

Unfortunately, I didn't have the time to take a closer look, nor time to write up all the details in order to ask for help here. But sometime in the next two weeks I will (unless it resolves itself by some near-future SVN update).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF is too small (in cm)

Post by fmw42 »

I would suggest that you use either the release or a beta rather than from SVN. I do not know much about SVN, but my technique that I mentioned earlier in this post works fine for me. It allows me to stay current with IM releases or test betas.
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: PDF is too small (in cm)

Post by pipitas »

fmw42 wrote:I install my delegates from MacPorts, but install IM from source manually. see viewtopic.php?f=1&t=21502&p=88202&hilit ... rts#p88202
IIRC, I tried to also compile a released source tarball (as opposed to current SVN checkout), and this also failed. I'll revisit the topic as soon as I'll have more time for it again...
akapuma
Posts: 11
Joined: 2014-05-14T06:49:47-07:00
Authentication code: 6789

Re: PDF is too small (in cm)

Post by akapuma »

Hellp pepitas,

Code: Select all

   gs -o testpage.tif -sDEVICE=tiffg4 -r300 testpage.ps

   tiff2pdf -p A4 -F testpage.tif > testpage.tif.pdf
Thank you for the great idea to solve my problem with ghostscript. It works fine, but unfortunately the gs uses dithering. Any idea to convert in back/white without dithering?

Best regards

akapuma
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: PDF is too small (in cm)

Post by pipitas »

akapuma wrote:

Code: Select all

   gs -o testpage.tif -sDEVICE=tiffg4 -r300 testpage.ps

   tiff2pdf -p A4 -F testpage.tif > testpage.tif.pdf
Thank you for the great idea to solve my problem with ghostscript. It works fine, but unfortunately the gs uses dithering. Any idea to convert in back/white without dithering?
Look more closely at the result. Zoom in. Zoom in more. Look closely: The PDF page IS black/white only, and it uses a "1 bit per pixel" depth.

I would not call it "unfortunately", but "fortunately, that gs uses dithering" by default!

This is the first time you are mentioning that you want pure black/white without dithering. (You only mentioned "1 bit per pixel" before -- and this requirement is matched by my suggested procedure.)

If you do not want dithering, but black filled areas and white filled areas all over the page, you need to use a different workflow. That is also possible. Please as a new question for this, and clearly state your goals. (And please do not put your question under the "bugs" section of these forums...)
akapuma
Posts: 11
Joined: 2014-05-14T06:49:47-07:00
Authentication code: 6789

Re: PDF is too small (in cm)

Post by akapuma »

Hello pipitas,
If you do not want dithering, but black filled areas and white filled areas all over the page, you need to use a different workflow. That is also possible. Please as a new question for this, and clearly state your goals.
The following command line from my first post does, what I want. Black and white without dithering:

Code: Select all

convert -limit memory 1GiB -limit map 2GiB -define registry:temporary-path="c:\tmp" -density 300x300 -page A4 -colors 2 +dither -monochrome -compress group4  input.ps output.pdf
Please as a new question for this, and clearly state your goals.
Your idea to make the TIFF without imagemagick is very good. But I will not ask for a solution in this forum. It's an imagemagick forum, not a gs forum.
(And please do not put your question under the "bugs" section of these forums...)
I defined A4, and I expected an A4 output = 21cm x 29,7cm. But I got a 5,04cm x 7,13cm file. I thought, this is a bug. Sorry for this.

Best regards

akapuma
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: PDF is too small (in cm)

Post by pipitas »

akapuma wrote:
If you do not want dithering, but black filled areas and white filled areas all over the page, you need to use a different workflow. That is also possible. Please as a new question for this, and clearly state your goals.
The following command line from my first post does, what I want. Black and white without dithering:

Code: Select all

convert -limit memory 1GiB -limit map 2GiB -define registry:temporary-path="c:\tmp" -density 300x300 -page A4 -colors 2 +dither -monochrome -compress group4  input.ps output.pdf
Please as a new question for this, and clearly state your goals.
Your idea to make the TIFF without imagemagick is very good. But I will not ask for a solution in this forum. It's an imagemagick forum, not a gs forum.
(And please do not put your question under the "bugs" section of these forums...)
I defined A4, and I expected an A4 output = 21cm x 29,7cm. But I got a 5,04cm x 7,13cm file. I thought, this is a bug. Sorry for this.
Your command's output is also "dithered" (with 1 bit depth). Just like the one from my command.

But my command's output IS A4, which is what you asked for.

I still don't understand what you don't like about my command's output when you ask for "not dithered".
akapuma
Posts: 11
Joined: 2014-05-14T06:49:47-07:00
Authentication code: 6789

Re: PDF is too small (in cm)

Post by akapuma »

I think, some samples will help:

This is a text in different sizes and colors:
http://akapuma.info/sonstiges/coloured.pdf

Conversion with ghostsript only (tiff2pdf after that):

Code: Select all

gs -o testpage.tif -sDEVICE=tiffg4 -r300 testpage.ps
Result: http://akapuma.info/sonstiges/gsonly.pdf
=> the yellow text is missing
=> due to dithering, the small text is not good readable (last line)
=> correct size 21,0cm x 29,7cm

Conversion with imagemagick:

Code: Select all

convert -limit memory 1GiB -limit map 2GiB -define registry:temporary-path="c:\tmp" -density 300x300 -page A4 -colors 2 +dither -monochrome -compress group4  input.ps output.pdf
Remark: "+dither" means no dithering

Result: http://akapuma.info/sonstiges/imagemagick.pdf
=> the yellow text is readable
=> the small text is good readable (last line)
=> wrong size 5,07cm x 7,13cm

The only problem is the size of 5,07cm x 7,13cm.

Best regards

akapuma
Last edited by akapuma on 2014-11-18T23:47:13-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PDF is too small (in cm)

Post by snibgo »

For "-page A4", see http://www.imagemagick.org/script/comma ... s.php#page

This is shorthand for "-page 595x842", which is A4 at 72 dpi. But you have 300 dpi, so the result won't be A4.
snibgo's IM pages: im.snibgo.com
akapuma
Posts: 11
Joined: 2014-05-14T06:49:47-07:00
Authentication code: 6789

Re: PDF is too small (in cm)

Post by akapuma »

This is shorthand for "-page 595x842", which is A4 at 72 dpi. But you have 300 dpi, so the result won't be A4.
That's interesting. Now, I tried:
convert -limit memory 1GiB -limit map 2GiB -define registry:temporary-path="c:\tmp" -size 2480x3508 -density 300x300 -units pixelsperinch -colors 2 +dither -monochrome -compress group4 input.ps output.pdf
21,0cm / 2,54cm/inch * 300pixels/inch = 2480pixels
29,7cm / 2,54cm/inch * 300pixels/inch = 3508pixels

The result is 20,14cm x 28,85cm. Expected was 21,0cm x 29,7cm.

The small discrepancy is unclear for me. But I can live with the new result. Thank you very much.

Best regards

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

Re: PDF is too small (in cm)

Post by fmw42 »

I do not think -size is relevant here. It is for creating a new image, not converting. Also things like -colors +dither -monochrome -compress should come after reading the input image.
akapuma
Posts: 11
Joined: 2014-05-14T06:49:47-07:00
Authentication code: 6789

Re: PDF is too small (in cm)

Post by akapuma »

fmw42 wrote:I do not think -size is relevant here.
I think, size is relevant, because the input file is not a raster file. It's a postscript, without a size in pixels.

Best regards

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

Re: PDF is too small (in cm)

Post by fmw42 »

I am not a vector expert or expert in ps files, but the size of most vector files is controlled by the density. Perhaps ps files are different.
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: PDF is too small (in cm)

Post by pipitas »

fmw42 wrote:[...] the size of most vector files is controlled by the density. Perhaps ps files are different.
This wording is not the best to express your intended meaning.

Maybe better and technically more correct say:

"Vertical and horizontal dimensions of raster images created by converting from vector files are controlled by the '-density' parameter."
Post Reply