Page 1 of 1

the usage of -dissolve

Posted: 2012-04-08T18:49:19-07:00
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 -

Re: the usage of -dissolve

Posted: 2012-04-08T19:04:23-07:00
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:

Re: the usage of -dissolve

Posted: 2012-04-09T10:13:03-07:00
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?

Re: the usage of -dissolve

Posted: 2012-04-09T12:02:25-07:00
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.

Re: the usage of -dissolve

Posted: 2012-04-10T11:31:27-07:00
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 -

Re: the usage of -dissolve

Posted: 2012-04-10T11:44:59-07:00
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:

Re: the usage of -dissolve

Posted: 2012-04-13T18:59:36-07:00
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.

Re: the usage of -dissolve

Posted: 2012-04-13T19:12:25-07:00
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.

Re: the usage of -dissolve

Posted: 2012-04-14T08:06:23-07:00
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.

Re: the usage of -dissolve

Posted: 2012-04-14T10:10:23-07:00
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