Converting from jpg or tif to pdf: size of the pdf

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
Jean-Pierre Coulon
Posts: 22
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Converting from jpg or tif to pdf: size of the pdf

Post by Jean-Pierre Coulon » 2017-02-25T23:52:14-07:00

How can I change the size (in cm or in) of the pdf without changing the resolution? Of course -resize change this size but it also changes the resolution.

User avatar
fmw42
Posts: 21832
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Converting from jpg or tif to pdf: size of the pdf

Post by fmw42 » 2017-02-25T23:57:56-07:00

What do you mean by resolution? If you have a PDF, it is a vector file with no defined resolution. You have to use -density before reading the pdf to change the resolution for converting to raster or for printing. Please clarify your question.

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/

snibgo
Posts: 9245
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting from jpg or tif to pdf: size of the pdf

Post by snibgo » 2017-02-26T09:51:51-07:00

"-density" will change the physical size (in inches or centimetres) of the PDF without changing the pixels. Eg:

Code: Select all

convert rose: -density 300 out.pdf
Does that answer the question?
snibgo's IM pages: im.snibgo.com

Jean-Pierre Coulon
Posts: 22
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Re: Converting from jpg or tif to pdf: size of the pdf

Post by Jean-Pierre Coulon » 2017-02-26T12:47:37-07:00

snibgo wrote:
2017-02-26T09:51:51-07:00
"-density" will change the physical size (in inches or centimetres) of the PDF without changing the pixels. Eg:

Code: Select all

convert rose: -density 300 out.pdf
Does that answer the question?
Yes it does. With Acrobat Reader, Document properties, I see the document size decrease when the density increases. But I have to try a density at random and calculate the ratio present size/desired size and adapt the new density to it.

Can't I specify the new desired size directly?

Which command line can give me my IM version?

snibgo
Posts: 9245
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting from jpg or tif to pdf: size of the pdf

Post by snibgo » 2017-02-26T13:06:43-07:00

"convert -version" will output the version information.

In v6, "-density" needs a number. You can calculate that in a shell script.

In v7, "-density" can use a calculation. For example:

Code: Select all

magick in.png -density %[fx:w/2] out.pdf
This will make the PDF 2 inches wide.
snibgo's IM pages: im.snibgo.com

Jean-Pierre Coulon
Posts: 22
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Re: Converting from jpg or tif to pdf: size of the pdf

Post by Jean-Pierre Coulon » 2017-02-27T02:41:48-07:00

snibgo wrote:
2017-02-26T13:06:43-07:00
In v7, "-density" can use a calculation. For example:

Code: Select all

magick in.png -density %[fx:w/2] out.pdf
This will make the PDF 2 inches wide.
Works fine, thanks.

Post Reply