[SOLVED] transparent overlay minus a rectangle?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
teracow
Posts: 19
Joined: 2013-04-30T02:55:12-07:00
Authentication code: 6789
Location: Brisbane, Australia

[SOLVED] transparent overlay minus a rectangle?

Post by teracow »

Hi all, 8)

I'm hoping someone can help me here.

I have a .jpg that I'd like to overlay with a semi-transparent color (yellow) over the whole image - EXCEPT for a small rectangle (of 60 x 120 pixels) near the top right corner of this image that would NOT have the semi-transparent overlay. Thus, the .jpg as seen through this rectangle would appear without the overlay.

I think that this might involve creating a mask (?) but I'm unsure how to code the command-line for this operation.

OS's that I can test this on are Linux 8) & Windows :(

Any advice would be welcome.

Thanks.
Last edited by teracow on 2013-05-01T00:53:37-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: transparent overlay minus a rectangle?

Post by snibgo »

There are many methods, and this probably isn't the best. Windows script:

Code: Select all

convert ^
  input.jpg ^
  ( +clone -fill rgba(100%%,100%%,0,0.5) -colorize 100 ) ^
  ( +clone -fill White -colorize 100 -fill Black -draw "rectangle 400,50,520,170" ) ^
  -composite x.png
"rgba(100%%,100%%,0,0.5)" is semi-transparent yellow.
snibgo's IM pages: im.snibgo.com
User avatar
teracow
Posts: 19
Joined: 2013-04-30T02:55:12-07:00
Authentication code: 6789
Location: Brisbane, Australia

Re: transparent overlay minus a rectangle?

Post by teracow »

thank you, that's exactly what I wanted! :D
Post Reply