Search code examples
image-processingimagemagickmogrify

mogrify to add 100px to the left and right of a jpg image?


I have a jpg image that is 100px by 100px. I want to use mogrify command from bash to add 100px of white space to the left and right side of the image. The resulting image should then have 300px width and 100px height. The image will be horizontally centered.

I tried mogrify -crop +200+0 image.jpg but that cut off 200 px from the left of the image. I tried mogrify -crop -200+0 image.jpg but that cut off 200 px from the right of the image. I'm having trouble understanding the documentation from imagemagick. I learn best by looking at sample code.

What is the command line statement that will achieve my objective?


Solution

  • I figured it out

    mogrify -extent 300x100 -gravity Center image.jpg