imagemagick

How to add a band at the bottom of image by a percentage of its height?


How can I add a red band at the bottom of an image, regardless of its dimensions? In this case I have an image that is 16x9 and I would like to add a red band at the bottom of the same width as the original image and about 20% of the height of the original image, keeping the quality of the image intact.

With my current attempt I set exactly 100 pixels for the height of the red band, but don't know how to set exactly the 20%, since I have images of different sizes.

magick input.jpg -coalesce -gravity South -background red -splice 0x100 output.jpg

Then, if the input image is like this

enter image description here

I'd like to get an output like this

enter image description here


Solution

  • It works better with -extent:

    in

    convert input.png -gravity North -background red -extent '100%x120%' output.png
    

    out