From 6da9a71aed7c862db3d839da041d0499420921af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Tue, 4 Jan 2022 13:16:23 +0100 Subject: [PATCH] plug-ins: adjust selection of precision during JXL import There is no change for lossless images, where import precision is directly related to bits_per_sample. However, according JXL developers, for lossy images (which generally use XYB color space), decoded data are not tightly bound to bits_per_sample from header, import in 32bit float precision can be used for better import quality (libjxl works internally in 32bit float precision). --- plug-ins/common/file-jpegxl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plug-ins/common/file-jpegxl.c b/plug-ins/common/file-jpegxl.c index 86802b2ead..aad74eb632 100644 --- a/plug-ins/common/file-jpegxl.c +++ b/plug-ins/common/file-jpegxl.c @@ -378,20 +378,20 @@ load_image (GFile *file, pixel_format.endianness = JXL_NATIVE_ENDIAN; pixel_format.align = 0; - if (basicinfo.bits_per_sample <= 8) - { - pixel_format.data_type = JXL_TYPE_UINT8; - channel_depth = 1; - precision_linear = GIMP_PRECISION_U8_LINEAR; - precision_non_linear = GIMP_PRECISION_U8_NON_LINEAR; - } - else if (basicinfo.bits_per_sample > 16) + if (basicinfo.uses_original_profile == JXL_FALSE || basicinfo.bits_per_sample > 16) { pixel_format.data_type = JXL_TYPE_FLOAT; channel_depth = 4; precision_linear = GIMP_PRECISION_FLOAT_LINEAR; precision_non_linear = GIMP_PRECISION_FLOAT_NON_LINEAR; } + else if (basicinfo.bits_per_sample <= 8) + { + pixel_format.data_type = JXL_TYPE_UINT8; + channel_depth = 1; + precision_linear = GIMP_PRECISION_U8_LINEAR; + precision_non_linear = GIMP_PRECISION_U8_NON_LINEAR; + } else { pixel_format.data_type = JXL_TYPE_UINT16;