8

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.

  • Can you post the puma1.png file please? BTW that command doesn't work for me either. – slm Jul 4 '14 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 '15 at 11:35
12

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

  • That... looks UGLY! – Braiam Jul 4 '14 at 17:19
  • That's the switches. – slm Jul 4 '14 at 18:15
  • 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 '14 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.