Imagemagick: fill white color dimension taken from GIMP

43 Views Asked by At

Say there is a following image. I'd like to fill the part with letters ry with white color (ry is an example for a question). It can be done by the following command:

mogrify -fill white -draw "rectangle <coordinates, size>" *.jpg

I'd like to know how do I "convert" selection of ry part of the image from GIMP to be understood by imagemagick? In other words, given selection made in GIMP, what values do I use instead of <coordinates, size>?

enter image description here

As per request, I show how GIMP coordinates look:

enter image description here

On a side node, I use the following command to crop image using mogrify when using coordinates from GIMP mogrify -crop 0x0+4248+6336 *.jpg

where 0 -> position from left, 0 -> position from right 4248 -> size from left, 6336 -> size from right Perhaps this helps.

1

There are 1 best solutions below

3
fmw42 On BEST ANSWER

If I assume your coordinates are top-left corner, width and height, then there are two ways to fill white in Imagemagick. The first is to overlay a white image. The second is to draw a white rectangle.

Overlay White Image:

convert ry.jpg -size 389x260 xc:white -geometry +1179+486 -compose over -composite result.jpg

-size specifies the size of the white image
-geometry specifies the top left corner of the white image in the background image

enter image description here

Draw White Rectangle:

convert ry.jpg -fill white -draw "rectangle 1179,486 1568,746" -alpha off result2.jpg

The top-left corner and the bottom-right corner coordinates are used

enter image description here