transparency not working

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
rihad
Posts: 6
Joined: 2017-05-26T12:47:21-07:00
Authentication code: 1151

transparency not working

Post by rihad »

composite -gravity Center -dissolve 20% overlay.png background.jpg output.jpg

This command works fine in 6.9.6, and produces a non-transparent overlay in 6.9.8.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: transparency not working

Post by fmw42 »

What is your exact version and platform. IM is at 6.9.8.6 currently. It would help if you posted your two images to some free hosting service and put the URLs here so we can test with your exact IM version and images.
rihad
Posts: 6
Joined: 2017-05-26T12:47:21-07:00
Authentication code: 1151

Re: transparency not working

Post by rihad »

The OS is FreeBSD 10.3
Working: ImageMagick-nox11-6.9.6.4_2,1 Image processing tools (legacy version)
Not working: ImageMagick-nox11-6.9.8.6,1 Image processing tools (legacy version)

Just about any kind of real-world photograph can be used as background, and "a text string" as a watermark in overlay.png, in which the white text is drawn on a transparent background, non-technically speaking :) It's neither black nor white, it's nothing. So the problem is - the white letters aren't dissolved (made sem-transparent) in the newer version, but are left as they were. I'll try to make up an example later.
rihad
Posts: 6
Joined: 2017-05-26T12:47:21-07:00
Authentication code: 1151

Re: transparency not working

Post by rihad »

Ok, here's what I've come up with.
First, I made a screenshot of this browser window and saved it as background.jpg.
Image
Then I used a free online tool to create a text string with a transparent background (http://www.picturetopeople.org/text_gen ... rator.html)
Image

Now for the good part. The barely visible overlaid text using the command in the first post & IM 6.9.6.
Image

And the failing IM 6.9.8:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: transparency not working

Post by fmw42 »

Try using the more current IM 6 convert. It is more flexible than composite. This seems to work fine for me on IM 6.9.8.6 Q16 Mac OS X.

Code: Select all

convert background.jpg transparent_text_effect.png -gravity Center -set option:compose:args 100,20 -compose dissolve -composite tmp.png
or

Code: Select all

convert background.jpg transparent_text_effect.png -gravity Center -define compose:args=100,20 -compose dissolve -composite tmp.png
See
http://www.imagemagick.org/Usage/compose/
http://www.imagemagick.org/script/compose.php
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: transparency not working

Post by fmw42 »

Note that values used in composite are typically reversed when used in convert.

Perhaps you really want 20,100. So if I have the results backwards, then use 20,100 in place of 100,20 (or perhaps you want 20,80).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: transparency not working

Post by fmw42 »

If you still find that results from 6.9.8.6 and 6.9.6.4 have swapped values, then let me know and I will download a version of 6.9.6.4 tomorrow and check it out. Perhaps that version had a transient bug?
rihad
Posts: 6
Joined: 2017-05-26T12:47:21-07:00
Authentication code: 1151

Re: transparency not working

Post by rihad »

Thank you, sir! This now works as expected in both versions.
convert bg.jpg overlay.png -gravity Center -define compose:args=20,100 -compose dissolve -composite out.jpg
rihad
Posts: 6
Joined: 2017-05-26T12:47:21-07:00
Authentication code: 1151

Re: transparency not working

Post by rihad »

FYI, the composite command in my original post produces the desired result in ImageMagick7-nox11-7.0.5.7
It looks like there's a bug in IM 6.9.8
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: transparency not working

Post by fmw42 »

I get exactly the same results using 6.9.8-7 and 7.0.5-8

Code: Select all

convert bg.jpg overlay.png -gravity Center -define compose:args=20,100 -compose dissolve -composite out6.jpg

Code: Select all

magick bg.jpg overlay.png -gravity Center -define compose:args=20,100 -compose dissolve -composite out7.jpg
rihad
Posts: 6
Joined: 2017-05-26T12:47:21-07:00
Authentication code: 1151

Re: transparency not working

Post by rihad »

I was talking about the "composite" binary itself.
Works in 6.9.6.4 and 7.0.5.7
Fails in 6.9.8.6
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: transparency not working

Post by fmw42 »

composite is an older syntax. You should always use the convert syntax these days since it is more flexible.
Post Reply