Page 1 of 1

Re: How to pad image in PythonMagick (or *Magick)?

Posted: 2009-03-12T13:12:16-07:00
by pwnedd
Hi Jerry,

I haven't tried using PythonMagick yet, but if you are interested, here is how you can do it using PHP:

Code: Select all

<?php
        // e.g. Pad left and right with 100px white bg
        $im = new Imagick("myImage.png");

        $white = new ImagickPixel( "white" );
        
        $im->borderImage($white, 100, 0);

        $im->writeImage("output.png");
?>
Padding add of the sides, or both top & bottom or left & right is pretty straight-forward. To pad just one corner however is a little tricker: you have to first
pad all sides, then remove the padding (via cropImage) that you don't want.

Check out the IMagick Docs for more info if you are interested.

Hope this helps.

Re: How to pad image in PythonMagick (or *Magick)?

Posted: 2009-03-15T20:42:51-07:00
by anthony
For padding a corner you can append xc: images, or use Spilce to insert rows and columns. This addes the row/columns relative to gravity too.

See the Command Line examples, the API should also be available
http://www.imagemagick.org/Usage/crop/#splice