Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to block out rectangle with imagemagick?


    Howdy:

    I've got some animated gif files in which I want to black out rectangular regions. Can't do it with gimp as I get some weird error message.

    I looked up imagemagick's convert function and it looks like that would do the job. However I just don't understand the usage of the geometry values.

  2. #2
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    They're pretty straight forward. For instance, the command below will create a white image sized 400 pixels wide by 600 pixels high and draw a rectangle from the 10,10 pixel location (from upper left) with a lower right corner 200,300. Try it and see.

    Code:
    convert -size 400x600 xc:white -fill black -stroke black -draw "rectangle 10,10 200,300" rect.gif

  3. #3
    Thank you, gregm, your example will definitely kick start me.

    It looks as if you're creating the rect.gif file from scratch. Will your same technique apply if I wanted to modify an existing gif, say rect0.gif, inserting the blacked out region, and producing rect.gif?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    Yes but the first argument to convert should be the file you wish to modify. Below I first create a white image and then edit it to create an image with the rectangle. In the end there are two images, one blank and one with a black rectangle.

    [code]
    convert -size 400x600 xc:white rect.gif
    convert rect.gif -fill black -stroke black -draw "rectangle 10,10 200,300" new_rect.gif
    [code]

  6. #5
    Thanks again, gregm, that works great.

  7. #6
    -->
    agree your work is impressive

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •