Page 1 of 1

Content-aware image extent?

Posted: 2014-06-17T12:59:09-07:00
by Marsu42
I'd like to add a alpha-masked border around my images, but without cutting too much into the original content.

The idea is to inconspicuously extent the outer content of the image to an added border - basically what you would do in Photoshop with extent canvas and context-sensitive fill. Of course an automated IM result isn't to be as good, but as there is only some content visible through the border it doesn't need to be.

Any hints on how to add a border region around this image that is filled with some extension of the content - or is this beyond IM?

Re: Content-aware image extent?

Posted: 2014-06-17T14:27:05-07:00
by snibgo
How big do you want the border?

This Windows BAT script gives a border of 4 pixels. Vary the blur, if you want. I have made the border opaque, but I'm not sure if that's what you want.

Code: Select all

convert ^
  rose: ^
  ( +clone ^
    -bordercolor None -border 4 ^
    -blur 0x1 ^
    -alpha off ^
  ) ^
  +swap ^
  -gravity Center -composite ^
  out.png

Re: Content-aware image extent?

Posted: 2014-06-17T15:30:46-07:00
by fmw42
see distort srt with viewport at http://www.imagemagick.org/Usage/distor ... t_viewport and set the virtual-pixel appropriately for extending the border. see http://www.imagemagick.org/script/comma ... tual-pixel

If on unix, see my script imageborder at the link below

Re: Content-aware image extent?

Posted: 2014-06-18T03:23:50-07:00
by Marsu42
fmw42 wrote:If on unix, see my script imageborder at the link below
Right, thanks, that's it! You can run *nix shell scripts on Windows through cygwin (or msys/mingw) bash just fine btw.

Re: Content-aware image extent?

Posted: 2014-06-18T09:37:13-07:00
by fmw42
Marsu42 wrote:
fmw42 wrote:If on unix, see my script imageborder at the link below
Right, thanks, that's it! You can run *nix shell scripts on Windows through cygwin (or msys/mingw) bash just fine btw.

Yes, I know that. Usually I mention Linux, Mac OS or Window with Cygwin. Just got lazy this time above and so just said unix.