-size -density -units

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
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

-size -density -units

Post by Albireo »

Hi!

I want to control the size of the image results.
(as an example - if I want to make an image of A4 size - How do you do?)

Began with a simple example that I found here:
http://www.imagemagick.org/Usage/basics/

Code: Select all

convert -size 300x300 xc:red -append   c:\temp\pic\red_300x300.jpg
(translated to Windows)

When I created a jpg (or tif) image, I got the following results
and if I created an gif image - The image became black.... with the same size:?
72 dpi
300 x 300 Pixels
10.6 x 10.6 cm; 4.2 x 4.2 inches
and when I created a png image, I got the following results
2dpi
300 x 300 Pixels
381.0 x 381.0 cm; 150.0 x 150.0 inches
________________________________________________________________

Then I tried to add "-density" and "-units" like this:

Code: Select all

Set FileOut = c:\temp\pic\RedSquare_1x1inch.png
convert -size 300x300 -density 300x300 -units PixelsPerInch xc:red -append %FileOut%
I got an error :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -size -density -units

Post by fmw42 »

see the page dimensions at http://www.imagemagick.org/script/comma ... s.php#page and use the pixels for A4

convert -size 595x842 xc:red -density xxx -units pixelspercentimeter result.png

note PNG only supports densities in pixelspercentimeter and not inches!

see http://www.imagemagick.org/Usage/formats/#png_density

-append does nothing in your command as it only applies to multiple input images.

see http://www.imagemagick.org/script/comma ... php#append

create your input first, then specify density and units, then the output
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Re: -size -density -units (solved)

Post by Albireo »

Thank you
I got an idea how the problem should be solved :)

(I don't realy know, what the site you gave me has to say :? )
I made it in my way

The size on A4 is 210mm x 297mm
and if I want to have an density about 300dpi x 300dpi
It corresponds to a resolution of about, 120dots/cm

120dots/cm x 21,0cm = 2520dots
120dots/cm x 29,7cm = 3564dots

Code: Select all

convert -size 2520x3564 xc:red -density 120x120 -units pixelspercentimeter result.png
it work's. The size on the result image was 210mm x 297mm 205dpi :D

//Jan
Post Reply