the usage of -dissolve

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
vita001
Posts: 5
Joined: 2012-04-08T18:31:46-07:00
Authentication code: 8675308

the usage of -dissolve

Post by vita001 »

Hi,
the following images greenbox.jpg and bluebox.jpg are two boxes of different dimension. I want the greenbox to cover the bluebox. I find the -dissolve,
from http://www.imagemagick.org/Usage/compose/#blend and I want to achieve the similar result as the dissolve 100% effect which is the greenbox cover part of the bluebox. However, when I do the following, the blue box are complete gone. Any help is appreciated.

convert -size 640x640 xc:black -fill green -draw "rectangle 0, 128, 639,256" greenbox.jpg
convert -size 640x640 xc:black -fill blue -draw "rectangle 64,64,576,576" bluebox.jpg
composite -dissolve 100% greenbox.jpg bluebox.jpg gif:-|display -
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: the usage of -dissolve

Post by fmw42 »

composite -dissolve 100% greenbox.jpg bluebox.jpg gif:-|display -
a dissolve of 100% will make one image completely cover the other. You need to specify two dissolve values or one value that is not 0 or 100%. see http://www.imagemagick.org/Usage/compose/#dissolve. Or make the background transparent and not black.

try

composite -dissolve 50% greenbox.jpg bluebox.jpg show:
vita001
Posts: 5
Joined: 2012-04-08T18:31:46-07:00
Authentication code: 8675308

Re: the usage of -dissolve

Post by vita001 »

In the given link http://www.imagemagick.org/Usage/compose/#dissolve, the dissolve 100% example show two pictures which is what I want.
How can I make the background transient?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: the usage of -dissolve

Post by fmw42 »

try using xc:none in your code above for your green image, so that the background is transparent like Anthony's example.

Or make the first image smaller in both dimensions than the other.
vita001
Posts: 5
Joined: 2012-04-08T18:31:46-07:00
Authentication code: 8675308

Re: the usage of -dissolve

Post by vita001 »

xc:none cannot make the background transparent. This is what I tried.

convert -size 640x640 xc:none -fill green -draw "rectangle 0, 128, 639,256" greenbox.jpg

convert -size 640x640 xc:black -fill blue -draw "rectangle 64,64,576,576" bluebox.jpg

composite -dissolve 100% greenbox.jpg bluebox.jpg gif:-|display -
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: the usage of -dissolve

Post by fmw42 »

vita001 wrote:xc:none cannot make the background transparent. This is what I tried.

convert -size 640x640 xc:none -fill green -draw "rectangle 0, 128, 639,256" greenbox.jpg

convert -size 640x640 xc:black -fill blue -draw "rectangle 64,64,576,576" bluebox.jpg

composite -dissolve 100% greenbox.jpg bluebox.jpg gif:-|display -
JPG does NOT support transparency. Change your greenbox (and bluebox) to png. That way you don't have quality loss from jpg.


convert -size 640x640 xc:none -fill green -draw "rectangle 0, 128, 639,256" greenbox.png

convert -size 640x640 xc:black -fill blue -draw "rectangle 64,64,576,576" bluebox.png

composite -dissolve 100% greenbox.png bluebox.png show:
vita001
Posts: 5
Joined: 2012-04-08T18:31:46-07:00
Authentication code: 8675308

Re: the usage of -dissolve

Post by vita001 »

If I have a png file(which is obtained by converting a jpg files), I want to change the black background color to transparent. So I do the following:
convert test.png -fill xc:none -opaque black -fuzz 20% test.png

However, it seems not working, if I do the following
composite -dissolve 100% test.png test2.png gif:-|display -

test.png still completely covers test2.png.

Any solutions? Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: the usage of -dissolve

Post by fmw42 »

If I have a png file(which is obtained by converting a jpg files), I want to change the black background color to transparent. So I do the following:
convert test.png -fill xc:none -opaque black -fuzz 20% test.png
Your -fill xc:none is an invalid command.



To change black to transparent use either

convert test.png -fuzz 20% -fill none -opaque black test.png[/quote]

or better

convert test.png -fuzz XX% -transparent black result.png

Note that -fuzz must come before -transparent or -fill.
vita001
Posts: 5
Joined: 2012-04-08T18:31:46-07:00
Authentication code: 8675308

Re: the usage of -dissolve

Post by vita001 »

This one doesn't work :convert test.png -fuzz 20% -fill none -opaque black test.png
But this one does: convert test.png -fuzz XX% -transparent black result.png

Thank you very much. I finally have what I want.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: the usage of -dissolve

Post by fmw42 »

vita001 wrote:This one doesn't work :convert test.png -fuzz 20% -fill none -opaque black test.png
But this one does: convert test.png -fuzz XX% -transparent black result.png

Thank you very much. I finally have what I want.

The first one should be working as I thought it had been fixed. You can make it work by


convert test.png -channel rgba -fill none -opaque white result.png
Post Reply