How to make an image transparent with gradient effect?

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
bil80
Posts: 2
Joined: 2014-04-02T02:55:05-07:00
Authentication code: 6789

How to make an image transparent with gradient effect?

Post by bil80 »

I am not an expert in ImageMagick, and i want to make an image transparent with gradient effect as on Photoshop:

Image
Transparency effect with Photoshop:
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to make an image transparent with gradient effect?

Post by snibgo »

Windows BAT syntax:

Code: Select all

convert ^
  clooney.jpg ^
  ( +clone ^
    -sparse-color barycentric "0,0,white %%[fx:w-1],0,white 0,%%[fx:h-1],black %%[fx:w-1],%%[fx:h-1],black" ^
  ) ^
  -compose CopyOpacity -composite ^
  c.png
snibgo's IM pages: im.snibgo.com
bil80
Posts: 2
Joined: 2014-04-02T02:55:05-07:00
Authentication code: 6789

Re: How to make an image transparent with gradient effect?

Post by bil80 »

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

Re: How to make an image transparent with gradient effect?

Post by snibgo »

My solution was over-complex. I had forgotten that barycentric can work with just two coordinates:

Code: Select all

convert ^
  clooney.jpg ^
  ( +clone ^
    -sparse-color barycentric "0,0,white 0,%%[fx:h-1],black" ^
  ) ^
  -compose CopyOpacity -composite ^
  c.png
snibgo's IM pages: im.snibgo.com
Post Reply