Aha! This was a little tricky to find, but here is the fix:
https://github.com/OpenImageIO/oiio/pull/2172
<https://github.com/OpenImageIO/oiio/pull/2172>
I believe that with this fix in place, the following command ought to work with
your file:
oiiotool -iconfig oiio:UnassociatedAlpha 1 steveparker.png -ch
R,G=R,B=R,A=R -o out.tif
> On Feb 8, 2019, at 3:18 PM, Larry Gritz <[email protected]> wrote:
>
> There's definitely something going wrong on the oiiotool side... in
> particular, the -iconfig oiio:UnassociatedAlpha 1 is getting lost somehow.
>
>
>> On Feb 8, 2019, at 3:15 PM, Stephen Parker <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> re: unassociated alpha - I ran into something similar when pushing PNG's to
>> iOS devices from XCode. Apparently Apple uses a modified libpng and added a
>> special chunk denoting that the file (against the png spec) is premultiplied
>> and XCode did that premult step automagically when bundling. That took
>> awhile to figure out. This test.png is NOT one of those files though. It
>> comes from Unity. Thanks again for digging into it.
>>
>>
>> On Fri, Feb 8, 2019 at 3:02 PM Larry Gritz <[email protected]
>> <mailto:[email protected]>> wrote:
>> I can answer that question, but then it leads right back to something ELSE
>> that's probably my fault. :-)
>>
>> OK, so PNG is, by specification, "unassociated alpha" (what some people call
>> "un-premultiplied"), and OIIO by convention always passes <ahem, CORRECT>
>> "associated alpha", which means that when reading unassoc files it will
>> automatically multiply RGB by A before giving the values to the app.
>>
>> Your file has alpha = 0, which is supposed to mean (for PNG) that the
>> appearance is black everywhere.
>>
>> This auto-conversion of unassociated to associated that happens in OIIO's
>> PNG reader can be disabled with a special configuration attribute, so the
>> correct command line should have been this:
>>
>> oiiotool -iconfig oiio:UnassociatedAlpha 1 steveparker.png -ch R,G=R,B=R,A=R
>> -o out.tif
>>
>> ... Except something is going wrong there as well. Ugh. I'm trying to
>> understand why. Stand by.
>>
>>
>>
>>> On Feb 8, 2019, at 2:52 PM, Stephen Parker <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>> Indeed. That was my first reaction too. But then why doesn't this work:
>>>
>>> oiiotool test.png --ch "R=R,B=R,G=R" -o out.png
>>>
>>> oiiotool test.png --ch "R=R,B=R,G=R,A=1.0" -o out.png
>>>
>>> I figured it was user error.
>>>
>>>
>>>
>>>
>>> On Fri, Feb 8, 2019 at 2:39 PM Larry Gritz <[email protected]
>>> <mailto:[email protected]>> wrote:
>>> Doesn't the fact that everything interesting ends up in out-0.png tell us
>>> that the alpha was black all along, and it was the red channel that you're
>>> after?
>>>
>>>
>>>> On Feb 8, 2019, at 2:03 PM, Stephen Parker <[email protected]
>>>> <mailto:[email protected]>> wrote:
>>>>
>>>> ... actually, disregard the -swap as -separate is all that's needed.
>>>>
>>>> convert test.png -separate out.png
>>>>
>>>> On Fri, Feb 8, 2019 at 1:51 PM Stephen Parker <[email protected]
>>>> <mailto:[email protected]>> wrote:
>>>> Try:
>>>>
>>>> convert test.png -separate -swap 4,0 out.png
>>>>
>>>> You should get an image written out for each channel. "out-0.png" can be
>>>> opened in Preview.app.
>>>>
>>>> -s
>>>>
>>>>
>>>> On Fri, Feb 8, 2019 at 1:38 PM Larry Gritz <[email protected]
>>>> <mailto:[email protected]>> wrote:
>>>> On my mac, ImageMagick "convert test.png test.tif" also results in what
>>>> appears to be a black image.
>>>>
>>>> And using ImageMagick's "identify -verbose", I see these stats:
>>>>
>>>> Alpha:
>>>> min: 0 (0)
>>>> max: 0 (0)
>>>> mean: 0 (0)
>>>> standard deviation: 0 (0)
>>>> kurtosis: -3
>>>> skewness: 0
>>>> entropy: 0
>>>>
>>>> Are you *sure* that the alpha channel isn't really 0 everywhere?
>>>>
>>>>
>>>>
>>>>> On Feb 8, 2019, at 11:55 AM, Larry Gritz <[email protected]
>>>>> <mailto:[email protected]>> wrote:
>>>>>
>>>>> Hmmm... it's not just "--ch", that image looks "black" (all 0.0 values)
>>>>> in all channels to all OIIO tools. (For example, `oiiotool -stats
>>>>> test.png`) I'm suspecting something in the reader rather than an issue
>>>>> with channel selection.
>>>>>
>>>>> Looking into it.
>>>>>
>>>>> -- lg
>>>>>
>>>>>
>>>>>> On Feb 8, 2019, at 11:31 AM, Stephen Parker <[email protected]
>>>>>> <mailto:[email protected]>> wrote:
>>>>>>
>>>>>> Hi Larry,
>>>>>>
>>>>>> I'm on the release branch. Here is the PNG in question (attached).
>>>>>>
>>>>>> thanks
>>>>>>
>>>>>> On Fri, Feb 8, 2019 at 11:12 AM Larry Gritz <[email protected]
>>>>>> <mailto:[email protected]>> wrote:
>>>>>> Which version of OIIO?
>>>>>> And I don't suppose you can send me an example PNG that has the problem?
>>>>>> Or is it weird for every png you try?
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On Feb 8, 2019, at 10:59 AM, Stephen Parker <[email protected]
>>>>>>> <mailto:[email protected]>> wrote:
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I'm having some trouble using oiiotool's copy channel operator. It
>>>>>>> might be user error but I wanted to check and see if it's intended
>>>>>>> behavior. I've only glanced at the code so far.
>>>>>>>
>>>>>>> My test image is a PNG (4-channel RGBA), but only has information in
>>>>>>> the Alpha. When attempting to copy the Alpha into the other 3 channels
>>>>>>> and write out an RGB image (no Alpha), I get black. Imagemagick's
>>>>>>> 'convert' did what I expected.
>>>>>>>
>>>>>>> invoked as:
>>>>>>>
>>>>>>> oiiotool input.png --ch "R=A,G=A,B=A" -o output.png
>>>>>>>
>>>>>>> I also tried using the numeric channel labels to no avail.
>>>>>>>
>>>>>>> -sp
>>>>>>> _______________________________________________
>>>>>>> Oiio-dev mailing list
>>>>>>> [email protected] <mailto:[email protected]>
>>>>>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>>>>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>>>>>
>>>>>> --
>>>>>> Larry Gritz
>>>>>> [email protected] <mailto:[email protected]>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Oiio-dev mailing list
>>>>>> [email protected] <mailto:[email protected]>
>>>>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>>>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>>>>> <test.png>_______________________________________________
>>>>>> Oiio-dev mailing list
>>>>>> [email protected] <mailto:[email protected]>
>>>>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>>>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>>>>
>>>>> --
>>>>> Larry Gritz
>>>>> [email protected] <mailto:[email protected]>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Oiio-dev mailing list
>>>>> [email protected] <mailto:[email protected]>
>>>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>>>
>>>> --
>>>> Larry Gritz
>>>> [email protected] <mailto:[email protected]>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Oiio-dev mailing list
>>>> [email protected] <mailto:[email protected]>
>>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>>> _______________________________________________
>>>> Oiio-dev mailing list
>>>> [email protected] <mailto:[email protected]>
>>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>>
>>> --
>>> Larry Gritz
>>> [email protected] <mailto:[email protected]>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Oiio-dev mailing list
>>> [email protected] <mailto:[email protected]>
>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>> _______________________________________________
>>> Oiio-dev mailing list
>>> [email protected] <mailto:[email protected]>
>>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>>
>> --
>> Larry Gritz
>> [email protected] <mailto:[email protected]>
>>
>>
>>
>>
>> _______________________________________________
>> Oiio-dev mailing list
>> [email protected] <mailto:[email protected]>
>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
>> _______________________________________________
>> Oiio-dev mailing list
>> [email protected] <mailto:[email protected]>
>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>
> --
> Larry Gritz
> [email protected] <mailto:[email protected]>
>
>
>
>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org