Add semi-transparent inner border over source image

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
christiaan
Posts: 13
Joined: 2013-08-09T01:20:06-07:00
Authentication code: 6789

Add semi-transparent inner border over source image

Post by christiaan »

First, I've searched the forum and docs but I can't find a similar question to mine. I hope you all can help me.

I want to add an semi-transparent surrounding inner-border of 20 pixels (for example) to a single jpg image. With -shave and -border I've created the inner border effect already, but I've lost all image information "under" the border then. Transparency will not succeed anyhow then.

Things that crossed my mind to solve this (but need help in the right direction):
- Create a transparent image (with the same size as original), give that the -shave and -border commands and create a composition with -blend over the original.
- Create 4 transparent boxes as borders (but I think it should be much more easier)

I think this should not be as hard as it seems, but I can't find a way to get started.

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Add semi-transparent inner border over source image

Post by snibgo »

It could be something like this Windows BAT script:

Code: Select all

convert ^
  logo: ^
  ( +clone -alpha Transparent ^
    -shave 20x20 ^
    -bordercolor None ^
    -mattecolor brown -frame 20x20 ^
    -channel A -evaluate Multiply 0.75 ^
  ) ^
  -composite ^
  t.png
Instead of "-bordercolor None -mattecolor brown -frame 20x20", do whatever you want.
snibgo's IM pages: im.snibgo.com
christiaan
Posts: 13
Joined: 2013-08-09T01:20:06-07:00
Authentication code: 6789

Re: Add semi-transparent inner border over source image

Post by christiaan »

Thanks snibgo, exactly as I needed! This proves again this forum is a great way of IM support :)
Post Reply