Page 1 of 1

Merging transparent layers

Posted: 2018-12-31T07:33:52-07:00
by samuelpenn
I have a script which takes an XCF file and converts it to a PNG at a given scale. The XCF consists of three layers - all have transparency, and the bottom layer is set to have 50% opacity. The command I am using is this:

Code: Select all

convert -background none -layers merge -scale "$size"x"$size" "$src" "$dst"
I'm currently using the version which comes with Ubuntu 18.04: ImageMagick 6.9.7-4 Q16 x86_64 20170114

The image consists of:
1) A white circle, on a layer set to have 50% opacity.
2) A portrait, which is set within the circle.
3) A black ring, which gives a border to the circle.

Each layer has a transparency, so the end result should be a portrait in a circle, with a partially translucent white background within the circle. Everything outside the circle should be transparent.

What I get, is that the white circle (layer 1) is drawn as solid white. The layer opacity is being ignored. The parts of the image which are fully transparent are correctly drawn, but it seems to be ignoring the layer opacity.

Should the above work to give me what I want, or am I missing an option?

For background information, this used to work. I think it stopped working when I moved from Ubuntu 14.04 to Ubuntu 16.04.

Sample files showing what I'm trying to achieve:

XCF file:
https://drive.google.com/open?id=1Tk2a_ ... H4C3QNeKHE

Correct conversion (using GIMP):
https://drive.google.com/open?id=18yaf9 ... aH5RoOKnY-

Incorrect conversion (using convert):
https://drive.google.com/open?id=1o4uk5 ... A8sTk9Rd-p

Re: Merging transparent layers

Posted: 2018-12-31T07:50:41-07:00
by snibgo
samuelpenn wrote:The layer opacity is being ignored. The parts of the image which are fully transparent are correctly drawn, but it seems to be ignoring the layer opacity.
As far as I know, IM cannot read XCF layer opacity.