11

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.

2
  • Can you post the puma1.png file please? BTW that command doesn't work for me either.
    – slm
    Jul 4, 2014 at 16:14
  • Closely related: "How to mount a .jpg centered into a .pdf (using defined page size and borders)?" unix.stackexchange.com/q/43946
    – tanius
    Aug 4, 2015 at 11:35

1 Answer 1

16

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

3
  • That... looks UGLY!
    – Braiam
    Jul 4, 2014 at 17:19
  • That's the switches.
    – slm
    Jul 4, 2014 at 18:15
  • 1
    Thank you. That solved my problem. The original command with the new options is: convert puma1.png -gravity center -background white -compress jpeg -resize 1755x2475 -extent 1755x2475 -units PixelsPerInch -density 150x150 puma1.pdf It seems the option -page A3 kills the output. In case I use it, I still get the blanc page at an output. What about -resize and -extent. Are they mutually exclusive?
    – mabalenk
    Jul 4, 2014 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .