How to fit an image in a pdf page without increase weight?

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
gvdmoort
Posts: 4
Joined: 2010-10-05T02:06:31-07:00
Authentication code: 8675308

How to fit an image in a pdf page without increase weight?

Post by gvdmoort »

Hello,

In Gimp, it's possible to print (and thus exporting to PDF via a virtual printer) a small image and to fit it at the maximal size allowed but without increasing the number of pixels in the image. Eg I've an image of 180x180pixels here:
http://www.k1ka.be/pub/200px-Circle_-_b ... le.svg.png

In gimp, the printing dialog gives 72 dpi and a size of 63.5mm; I've adjusted the dpi to 24 and the image becomes 190.5mm of width.

The resulting pdf is here:
http://www.k1ka.be/pub/200px-Circle_-_b ... le_svg.pdf

As you can see, the weight of the PDF file is very close to this of the the bitmap one (5689 vs. 9513 bytes).

How to do the same with Image Magick ? When I try with or without the -page option, the result is the same:

Code: Select all

gv@fantasio:~$ convert    200px-Circle_-_black_simple.svg.png test.pdf
gv@fantasio:~$ ls -l test.pdf
-rw-r--r-- 1 gv gv 6277 oct 22 12:31 test.pdf
gv@fantasio:~$ convert  -page A4  200px-Circle_-_black_simple.svg.png test.pdf
gv@fantasio:~$ ls -l test.pdf
-rw-r--r-- 1 gv gv 6277 oct 22 12:31 test.pdf
and the image is not "scaled". Printed on a sheet of paper, the image is positionned at the bottom corner, and at a size around 63mm.

Has someone a proposition ?

Thanls in advance,

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

Re: How to fit an image in a pdf page without increase weigh

Post by fmw42 »

IM will pixelize before converting to PDF. see http://www.imagemagick.org/Usage/formats/#vector
gvdmoort
Posts: 4
Joined: 2010-10-05T02:06:31-07:00
Authentication code: 8675308

Re: How to fit an image in a pdf page without increase weigh

Post by gvdmoort »

fmw42 wrote:IM will pixelize before converting to PDF. see http://www.imagemagick.org/Usage/formats/#vector
I know that. A lot of people misunderstand and do conversions from vector formats to raster, and are surprised by the weight of the resulting file.

But that's not the case here, it's a conversion from raster to raster "wrapped" in a description-page format: the conversion with gimp shows it's possible to include the raster image unmodified in a pdf (or in a postscript) and display it at a larger scale.

I'm wondering if IM could do so. Otherwise, I don't see the purpose of the "-page" option.
Post Reply