Skip to content

JPEG-XL & WebP: fix metadata handling, also fix WebP still image export

I found out that the metadata is not saved, even if the option is checked, either on JXL or WebP. This MR tries to fix the typo on export so that the metadata can be exported. Also a few more fixes:

JPEG-XL:

  • Fix error when opening JXL with an embedded metadata, such as this one: https://github.com/libjxl/conformance/tree/master/testcases/patches . As libjxl decoder asks to release the box buffer before setting it up again when status is at JXL_DEC_BOX_NEED_MORE_OUTPUT.
  • Prevent hangs when trying to open JXL when a metadata boxes exist but no data is present (eg. empty IPTC/XMP, possibly a broken/corrupted metadata), such as this one: DSC_6202-tiny.jxl.
  • Fix typo on export that prevents metadata being saved. The parameter on export dialog is storeMetaData, but its storeMetadata on export code.
  • Enable metadata compressing on lossy mode. We already built brotli along with libjxl, so it can be used here.

WebP:

  • Fix cannot save still image. On before, frame dimension is unset on still image export thus giving an error WebP picture conversion failure: 5.
  • Fix typo on export that prevents metadata being saved. Same as JXL.

However, I found some other bugs regarding to metadata handling, and it seems unrelated to both JXL and WebP:

  • Dublin Core Title field is lost after exporting on both files (or even beyond this scope, on JPEG export, its the Publisher field that lost). Title is not lost, its listed as Language Array on Layer > Edit Metadata > List.
  • On JXL, when IPTC is enabled, it triggers Error: XMP Toolkit error 201: Error in XMLValidator on reopening in Krita and loss in DC Publisher field. Disabling IPTC on export clears this error.

Edit: I found out that xmpBackend->loadFrom never returns false, even when XmpParser failed to decode packet. So IPTC is always skipped when doing JXL import.

Here's the test file along with the exported results: exifdebug.zip

Test Plan

Build Krita, export image to JXL or WebP with metadata enabled and check if metadata survives.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Rasyuqa A H (Kampidh)

Merge request reports