Bug 460380

Summary: AVIF Images with Alpha Channel Don't Export With Expected Translucency When Using PQ
Product: [Applications] krita Reporter: robbtbeal
Component: File formatsAssignee: amyspark <amy>
Status: RESOLVED FIXED    
Severity: normal CC: amy
Priority: NOR    
Version: 5.1.1   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: Exported AVIF showing the issue. Ignore the file name change. It was for browser dev tools convenience.
.kra generated from .avif
recreated avif that corresponds to kra

Description robbtbeal 2022-10-13 16:47:28 UTC
Created attachment 152778 [details]
Exported AVIF showing the issue. Ignore the file name change. It was for browser dev tools convenience.

SUMMARY


STEPS TO REPRODUCE
1. File>Open a PNG with Transparency (https://testufo.com/images/blurbustersUFOborder-2x.png)
(Resize image via Scale Image to New Size... menu item)
2. Using the Krita HDR documentation at https://docs.krita.org/en/reference_manual/hdr_display.html, replace SDR pixels with HDR pixels with the color selector set to 1000 nits.
3. Everything in Krita suggests that there's a correct alpha channel and the image content is opaque.  
4. Export as AVIF via the Export Advanced menu, choosing Lossless, Chroma 444, Rec 2100 PQ.

OBSERVED RESULT
Exported image as seen in Chrome (Stable and Canary) has translucency in image content 

EXPECTED RESULT
Exported image as seen in Chrome (Stable and Canary) DOES NOT have translucency in image content 

SOFTWARE/OS VERSIONS
Windows: 11
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
A test of File>Open of the same png and immediately exporting as AVIF does not have erroneous/unexpected translucency.

I'm doing this HDR image work in the context of HDR capabilities being added to Chrome. Those capabilities are in Chrome Canary and this test page (where I substituted the exported AVIF above) is what surfaced the issue:

https://ccameron-chromium.github.io/webgl-examples/canvas-hdr.html
Comment 1 amyspark 2022-10-13 16:55:13 UTC
Will try to get back to this later this week or the next: https://invent.kde.org/graphics/krita/-/merge_requests/1585 (it's related to JXL as well)
Comment 2 robbtbeal 2022-10-13 19:15:05 UTC
(In reply to amyspark from comment #1)
> Will try to get back to this later this week or the next:
> https://invent.kde.org/graphics/krita/-/merge_requests/1585 (it's related to
> JXL as well)

Thanks for the quick advice.

Is there any risk in doing the HDR painting (which are really luminance changes to the existing SDR assets) in 5.1.1 and saving as Krita and then use a future, corrected version of Krita to do the AVIF export? Or, best to wait before continuing to HDR paint additional assets?
Comment 3 amyspark 2022-10-13 22:08:32 UTC
Using KRA is OK, the changes that need to be done only affect the export plugins.
Comment 4 amyspark 2022-10-27 00:20:23 UTC
So far I could not reproduce the bug, could you please send me the following?

- The altered demo file, stored as KRA and with the profile and depth you were using
- Screenshots (if possible) of the broken transparency
Comment 5 amyspark 2022-10-27 00:20:48 UTC
(marking as NEEDSINFO due to the above)
Comment 6 robbtbeal 2022-10-27 01:39:19 UTC
Created attachment 153226 [details]
.kra generated from .avif

See .kra attached. Note" to gen a .kra, I needed to do a throw-away export as webp because it's the only way I could see the Also Save as KRA UI. I open the transparent png, do my HDR painting, and do an export as avif.
Comment 7 robbtbeal 2022-10-27 01:40:15 UTC
Created attachment 153227 [details]
recreated avif that corresponds to kra
Comment 8 Bug Janitor Service 2022-10-27 05:05:47 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 9 amyspark 2022-11-01 18:21:37 UTC
Git commit e6e7b4670057515c3a2abf6df7f6060650285826 by L. E. Segovia.
Committed on 01/11/2022 at 18:19.
Pushed by lsegovia into branch 'master'.

JPEG-XL: fix import/export of HDR alpha channels

M  +8    -3    plugins/impex/jxl/JPEGXLExport.cpp
M  +9    -2    plugins/impex/jxl/JPEGXLImport.cpp

https://invent.kde.org/graphics/krita/commit/e6e7b4670057515c3a2abf6df7f6060650285826
Comment 10 amyspark 2022-11-01 18:21:45 UTC
Git commit a5d1d31d7ecd6e5189523ab8ca42a771b2271c6a by L. E. Segovia.
Committed on 01/11/2022 at 18:19.
Pushed by lsegovia into branch 'master'.

HEIF: fix import/export of HDR alpha channels

M  +17   -6    plugins/impex/heif/kis_heif_export_tools.h
M  +53   -17   plugins/impex/heif/kis_heif_import_tools.cpp

https://invent.kde.org/graphics/krita/commit/a5d1d31d7ecd6e5189523ab8ca42a771b2271c6a
Comment 11 amyspark 2022-11-01 20:30:54 UTC
Git commit 9177afd72e0edd75b6fdd3453c257b9797acacdd by L. E. Segovia.
Committed on 01/11/2022 at 20:05.
Pushed by lsegovia into branch 'krita/5.1'.

JPEG-XL: fix import/export of HDR alpha channels
(cherry picked from commit e6e7b4670057515c3a2abf6df7f6060650285826)

M  +8    -3    plugins/impex/jxl/JPEGXLExport.cpp
M  +9    -2    plugins/impex/jxl/JPEGXLImport.cpp

https://invent.kde.org/graphics/krita/commit/9177afd72e0edd75b6fdd3453c257b9797acacdd
Comment 12 amyspark 2022-11-01 20:31:02 UTC
Git commit 3b6b341425803cc69f4446852207d0154cfd708c by L. E. Segovia.
Committed on 01/11/2022 at 20:05.
Pushed by lsegovia into branch 'krita/5.1'.

HEIF: fix import/export of HDR alpha channels
(cherry picked from commit a5d1d31d7ecd6e5189523ab8ca42a771b2271c6a)

M  +10   -9    plugins/impex/heif/HeifExport.cpp
M  +38   -28   plugins/impex/heif/HeifImport.cpp

https://invent.kde.org/graphics/krita/commit/3b6b341425803cc69f4446852207d0154cfd708c