How to convert, resize and center image with ImageMagick

I’m unable to center a converted *.png file with ImageMagick’s gravity option. Gravity seems to have no effect in the following command. On the contrary it erases everything and the output becomes white page.

convert puma1.png -compress jpeg 
                  -resize 1755x2475 
                  -units PixelsPerInch 
                  -density 150x150 
                  -page A3 
                  -gravity center puma1.pdf

ImageMagick version is 6.8.6-9 2014-03-06 Q16.

Asked By: mabalenk

||

Try using extent instead like this:

$ convert puma1.png -gravity center 
    -background white 
    -compress jpeg 
    -extent 1755x2475 puma1.pdf

Example

Your gravatar.

        ss #1

And the resulting PDF file.

$ convert 453f11e81477e1e0334962ee262b3bcd.png -gravity center 
    -background white 
    -extent 500x500 
    -compress jpeg 453f11e81477e1e0334962ee262b3bcd.pdf

ss #2

References

Answered By: slm
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.