sas wrote:Still seems weird that this would cause "-background transparent -flatten" to clear the whole image, doesn't it?.
This command (IM 7.0.3 on Windows 10 64) outputs an example of the fully transparent image...
Code: Select all
magick -background none -bordercolor green ^
-size 240x240 ( gradient:white-blue -page +20+20 ) ^
-size 120x120 ( gradient:red-yellow -page +70+70 ) ^
-flatten -border 2x2 sample1.png
The suggested solution is to add "-alpha on" immediately before the "-flatten" operation like this...
Code: Select all
magick -background none -bordercolor green ^
-size 240x240 ( gradient:white-blue -page +20+20 ) ^
-size 120x120 ( gradient:red-yellow -page +70+70 ) ^
-alpha on -flatten -border 2x2 sample2.png
That provides the result I might have expected from the first command example above. The two gradient images are composited to their "-page" positions with a 20 pixel transparent background showing on the left and top. Here's where it gets confusing...
Adding the "-edge 4" operation after "-flatten", the entire image goes transparent again.
Code: Select all
magick -background none -bordercolor green ^
-size 240x240 ( gradient:white-blue -page +20+20 ) ^
-size 120x120 ( gradient:red-yellow -page +70+70 ) ^
-alpha on -flatten -edge 4 -border 2x2 sample3.png
Oddly enough, if I remove the "-border" operation, there's a 4 pixel wide strip around the upper left of the white-blue gradient area. It's a gradient, not the sort of line I normally expect from the "-edge" operator, and it leaves everything else in the image fully transparent again.
Code: Select all
magick -background none -bordercolor green ^
-size 240x240 ( gradient:white-blue -page +20+20 ) ^
-size 120x120 ( gradient:red-yellow -page +70+70 ) ^
-alpha on -flatten -edge 4 sample4.png
If I do "-alpha off" again before the "-edge" operation like this...
Code: Select all
magick -background none -bordercolor green ^
-size 240x240 ( gradient:white-blue -page +20+20 ) ^
-size 120x120 ( gradient:red-yellow -page +70+70 ) ^
-alpha on -flatten -alpha off -edge 4 -border 2x2 sample5.png
... the result is more like I'd expect. Somehow it doesn't seem like it should be necessary to turn "-alpha on" or "off" before and after each operation that affects the alpha channel.
As always, maybe I'm misunderstanding or overlooking something.