249 if (!io->isReadable()) {
250 errFile <<
"Cannot read image contents";
255 const auto data = io->readAll();
257 const auto validation =
258 JxlSignatureCheck(
reinterpret_cast<const uint8_t *
>(data.constData()),
static_cast<size_t>(data.size()));
260 switch (validation) {
261 case JXL_SIG_NOT_ENOUGH_BYTES:
262 errFile <<
"Failed magic byte validation, not enough data";
264 case JXL_SIG_INVALID:
265 errFile <<
"Failed magic byte validation, incorrect format";
272 auto runner = JxlResizableParallelRunnerMake(
nullptr);
273 auto dec = JxlDecoderMake(
nullptr);
278 static constexpr std::array<JxlBlendMode, 3> supportedBlendMode = {JXL_BLEND_REPLACE, JXL_BLEND_BLEND, JXL_BLEND_MULADD};
281 bool isAnimated =
false;
282 bool isMultilayer =
false;
283 bool isMultipage =
false;
284 bool forceCoalesce =
false;
287 != JxlDecoderSubscribeEvents(dec.get(), JXL_DEC_BASIC_INFO | JXL_DEC_FRAME)) {
288 errFile <<
"JxlDecoderSubscribeEvents failed";
292 if (JXL_DEC_SUCCESS != JxlDecoderSetParallelRunner(dec.get(), JxlResizableParallelRunner, runner.get())) {
293 errFile <<
"JxlDecoderSetParallelRunner failed";
298 != JxlDecoderSetInput(dec.get(),
299 reinterpret_cast<const uint8_t *
>(data.constData()),
300 static_cast<size_t>(data.size()))) {
301 errFile <<
"JxlDecoderSetInput failed";
304 JxlDecoderCloseInput(dec.get());
306 if (JXL_DEC_SUCCESS != JxlDecoderSetDecompressBoxes(dec.get(), JXL_TRUE)) {
307 errFile <<
"JxlDecoderSetDecompressBoxes failed";
311 if (JXL_DEC_SUCCESS != JxlDecoderSetCoalescing(dec.get(), JXL_FALSE)) {
312 errFile <<
"JxlDecoderSetCoalescing failed";
317 JxlDecoderStatus status = JxlDecoderProcessInput(dec.get());
319 if (status == JXL_DEC_ERROR) {
322 }
else if (status == JXL_DEC_NEED_MORE_INPUT) {
323 errFile <<
"Error, already provided all input";
325 }
else if (status == JXL_DEC_BASIC_INFO) {
326 if (JXL_DEC_SUCCESS != JxlDecoderGetBasicInfo(dec.get(), &
d.m_info)) {
327 errFile <<
"JxlDecoderGetBasicInfo failed";
331 if (
d.m_info.have_animation) {
332 isMultilayer =
false;
335 forceCoalesce =
true;
338 dbgFile <<
"Extra Channel[s] info:";
339 for (uint32_t i = 0; i <
d.m_info.num_extra_channels; i++) {
340 if (JXL_DEC_SUCCESS != JxlDecoderGetExtraChannelInfo(dec.get(), i, &
d.m_extra)) {
341 errFile <<
"JxlDecoderGetExtraChannelInfo failed";
347 const QString channelTypeString = [&]() {
348 switch (
d.m_extra.type) {
349 case JXL_CHANNEL_ALPHA:
350 return QString(
"JXL-Alpha");
351 case JXL_CHANNEL_DEPTH:
352 return QString(
"JXL-Depth");
353 case JXL_CHANNEL_SPOT_COLOR:
354 return QString(
"JXL-SpotColor");
355 case JXL_CHANNEL_SELECTION_MASK:
356 return QString(
"JXL-SelectionMask");
357 case JXL_CHANNEL_BLACK:
358 return QString(
"JXL-Black");
359 case JXL_CHANNEL_CFA:
360 return QString(
"JXL-CFA");
361 case JXL_CHANNEL_THERMAL:
362 return QString(
"JXL-Thermal");
364 return QString(
"JXL-UNKNOWN");
369 dbgFile <<
"index:" << i <<
" | type:" << channelTypeString;
370 if (
d.m_extra.type == JXL_CHANNEL_BLACK) {
374 if (
d.m_extra.type == JXL_CHANNEL_SPOT_COLOR) {
375 warnFile <<
"Spot color channels unsupported! Rewinding decoder with coalescing enabled";
376 document->setWarningMessage(i18nc(
"JPEG-XL errors",
377 "Detected JPEG-XL image with spot color channels, "
378 "importing flattened image."));
379 forceCoalesce =
true;
384 dbgFile <<
"Size:" <<
d.m_info.xsize <<
"x" <<
d.m_info.ysize;
385 dbgFile <<
"Depth:" <<
d.m_info.bits_per_sample <<
d.m_info.exponent_bits_per_sample;
386 dbgFile <<
"Number of color channels:" <<
d.m_info.num_color_channels;
387 dbgFile <<
"Number of extra channels:" <<
d.m_info.num_extra_channels;
388 dbgFile <<
"Extra channels depth:" <<
d.m_info.alpha_bits <<
d.m_info.alpha_exponent_bits;
389 dbgFile <<
"Has animation:" <<
d.m_info.have_animation <<
"loops:" <<
d.m_info.animation.num_loops
390 <<
"tick:" <<
d.m_info.animation.tps_numerator <<
d.m_info.animation.tps_denominator;
391 dbgFile <<
"Internal pixel format:" << (
d.m_info.uses_original_profile ?
"Original" :
"XYB");
392 JxlResizableParallelRunnerSetThreads(
394 JxlResizableParallelRunnerSuggestThreads(
d.m_info.xsize,
d.m_info.ysize));
396 if (
d.m_info.exponent_bits_per_sample != 0) {
397 if (
d.m_info.bits_per_sample <= 16) {
398 d.m_pixelFormat.data_type = JXL_TYPE_FLOAT16;
400 }
else if (
d.m_info.bits_per_sample <= 32) {
401 d.m_pixelFormat.data_type = JXL_TYPE_FLOAT;
404 errFile <<
"Unsupported JPEG-XL input depth" <<
d.m_info.bits_per_sample
405 <<
d.m_info.exponent_bits_per_sample;
408 }
else if (
d.m_info.bits_per_sample <= 8) {
409 d.m_pixelFormat.data_type = JXL_TYPE_UINT8;
411 }
else if (
d.m_info.bits_per_sample <= 16) {
412 d.m_pixelFormat.data_type = JXL_TYPE_UINT16;
415 errFile <<
"Unsupported JPEG-XL input depth" <<
d.m_info.bits_per_sample
416 <<
d.m_info.exponent_bits_per_sample;
420 if (
d.m_info.num_color_channels == 1) {
422 d.m_pixelFormat.num_channels = 2;
424 }
else if (
d.m_info.num_color_channels == 3 && !
d.isCMYK) {
426 d.m_pixelFormat.num_channels = 4;
428 }
else if (
d.m_info.num_color_channels == 3 &&
d.isCMYK) {
430 d.m_pixelFormat.num_channels = 4;
433 warnFile <<
"Forcing a RGBA conversion, unknown color space";
434 d.m_pixelFormat.num_channels = 4;
438 if (!
d.m_info.uses_original_profile) {
439 d.m_pixelFormat_target.data_type =
d.m_pixelFormat.data_type;
440 d.m_pixelFormat.data_type = JXL_TYPE_FLOAT;
441 d.m_depthID_target =
d.m_depthID;
442 d.m_colorID_target =
d.m_colorID;
449 }
else if (status == JXL_DEC_FRAME) {
450 if (JXL_DEC_SUCCESS != JxlDecoderGetFrameHeader(dec.get(), &
d.m_header)) {
451 errFile <<
"JxlDecoderGetFrameHeader failed";
455 const JxlBlendMode blendMode =
d.m_header.layer_info.blend_info.blendmode;
456 const bool isBlendSupported =
457 std::find(supportedBlendMode.begin(), supportedBlendMode.end(), blendMode) != supportedBlendMode.end();
459 if (!isBlendSupported) {
460 forceCoalesce =
true;
463 if (
d.m_header.duration == 0) {
465 }
else if (
d.m_header.duration == 0xFFFFFFFF) {
468 forceCoalesce =
true;
472 isMultilayer =
false;
473 forceCoalesce =
true;
475 }
else if (status == JXL_DEC_SUCCESS) {
480 JxlDecoderReset(dec.get());
483 if (JXL_DEC_SUCCESS != JxlDecoderSetCoalescing(dec.get(), forceCoalesce ? JXL_TRUE : JXL_FALSE)) {
484 errFile <<
"JxlDecoderSetCoalescing failed";
489 != JxlDecoderSubscribeEvents(dec.get(),
490 JXL_DEC_COLOR_ENCODING | JXL_DEC_FULL_IMAGE | JXL_DEC_BOX | JXL_DEC_FRAME)) {
491 errFile <<
"JxlDecoderSubscribeEvents failed";
495 if (JXL_DEC_SUCCESS != JxlDecoderSetParallelRunner(dec.get(), JxlResizableParallelRunner, runner.get())) {
496 errFile <<
"JxlDecoderSetParallelRunner failed";
501 != JxlDecoderSetInput(dec.get(),
502 reinterpret_cast<const uint8_t *
>(data.constData()),
503 static_cast<size_t>(data.size()))) {
504 errFile <<
"JxlDecoderSetInput failed";
507 JxlDecoderCloseInput(dec.get());
509 if (JXL_DEC_SUCCESS != JxlDecoderSetDecompressBoxes(dec.get(), JXL_TRUE)) {
510 errFile <<
"JxlDecoderSetDecompressBoxes failed";
516 std::multimap<QByteArray, QByteArray> metadataBoxes;
517 std::vector<KisLayerSP> additionalLayers;
518 bool bgLayerSet =
false;
519 bool needColorTransform =
false;
520 bool needIntermediateTransform =
false;
521 QByteArray boxType(5, 0x0);
522 QByteArray box(16384, 0x0);
523 auto boxSize = box.size();
527 JxlDecoderStatus status = JxlDecoderProcessInput(dec.get());
529 if (status == JXL_DEC_ERROR) {
532 }
else if (status == JXL_DEC_NEED_MORE_INPUT) {
533 errFile <<
"Error, already provided all input";
535 }
else if (status == JXL_DEC_COLOR_ENCODING) {
544 JxlColorEncoding colorEncoding{};
546 == JxlDecoderGetColorAsEncodedProfile(dec.get(),
547#
if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
550 JXL_COLOR_PROFILE_TARGET_DATA,
553 switch (colorEncoding.transfer_function) {
554 case JXL_TRANSFER_FUNCTION_PQ: {
555 dbgFile <<
"linearizing from PQ";
559 case JXL_TRANSFER_FUNCTION_HLG: {
560 dbgFile <<
"linearizing from HLG";
561 if (!document->fileBatchMode()) {
565 d.displayGamma = dlg.
gamma();
571 case JXL_TRANSFER_FUNCTION_DCI: {
572 dbgFile <<
"linearizing from SMPTE 428";
576 case JXL_TRANSFER_FUNCTION_709:
578 case JXL_TRANSFER_FUNCTION_SRGB:
580 case JXL_TRANSFER_FUNCTION_GAMMA: {
582 const double estGamma = 1.0 / colorEncoding.gamma;
583 const double error = 0.0001;
586 if ((std::fabs(estGamma - 1.8) < error) || (std::fabs(estGamma - (461.0 / 256.0)) < error)) {
588 }
else if (std::fabs(estGamma - 2.2) < error) {
590 }
else if (std::fabs(estGamma - (563.0 / 256.0)) < error) {
592 }
else if (std::fabs(estGamma - 2.4) < error) {
594 }
else if (std::fabs(estGamma - 2.8) < error) {
597 warnFile <<
"Found custom estimated gamma value for JXL color space" << estGamma;
601 case JXL_TRANSFER_FUNCTION_LINEAR:
603 case JXL_TRANSFER_FUNCTION_UNKNOWN:
611 switch (colorEncoding.primaries) {
612 case JXL_PRIMARIES_SRGB:
614 case JXL_PRIMARIES_2100:
616 case JXL_PRIMARIES_P3:
624 if (colorEncoding.primaries != JXL_PRIMARIES_CUSTOM) {
627 return {colorEncoding.white_point_xy[0],
628 colorEncoding.white_point_xy[1],
629 colorEncoding.primaries_red_xy[0],
630 colorEncoding.primaries_red_xy[1],
631 colorEncoding.primaries_green_xy[0],
632 colorEncoding.primaries_green_xy[1],
633 colorEncoding.primaries_blue_xy[0],
634 colorEncoding.primaries_blue_xy[1]};
638 if (colorEncoding.rendering_intent == JXL_RENDERING_INTENT_PERCEPTUAL) {
640 }
else if (colorEncoding.rendering_intent == JXL_RENDERING_INTENT_RELATIVE) {
642 }
else if (colorEncoding.rendering_intent == JXL_RENDERING_INTENT_ABSOLUTE) {
644 }
else if (colorEncoding.rendering_intent == JXL_RENDERING_INTENT_SATURATION) {
647 warnFile <<
"Cannot determine color rendering intent, set to Perceptual instead";
653 dbgFile <<
"CICP profile data:" << colorants << colorPrimaries << transferFunction;
656 dbgFile <<
"JXL CICP profile found" << profile->
name();
661 d.m_pixelFormat.data_type =
d.m_pixelFormat_target.data_type;
671 QByteArray iccProfile;
673 != JxlDecoderGetICCProfileSize(dec.get(),
674#
if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0,9,0)
677 JXL_COLOR_PROFILE_TARGET_DATA,
679 errFile <<
"ICC profile size retrieval failed";
680 document->setErrorMessage(i18nc(
"JPEG-XL errors",
"Unable to read the image profile."));
683 iccProfile.resize(
static_cast<int>(iccSize));
685 != JxlDecoderGetColorAsICCProfile(dec.get(),
686#
if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0,9,0)
689 JXL_COLOR_PROFILE_TARGET_DATA,
690 reinterpret_cast<uint8_t *
>(iccProfile.data()),
691 static_cast<size_t>(iccProfile.size()))) {
692 document->setErrorMessage(i18nc(
"JPEG-XL errors",
"Unable to read the image profile."));
697 size_t iccTargetSize = 0;
698 QByteArray iccTargetProfile;
699 if (!
d.m_info.uses_original_profile) {
701 != JxlDecoderGetICCProfileSize(dec.get(),
702#
if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0,9,0)
705 JXL_COLOR_PROFILE_TARGET_ORIGINAL,
707 errFile <<
"ICC profile size retrieval failed";
708 document->setErrorMessage(i18nc(
"JPEG-XL errors",
"Unable to read the image profile."));
711 iccTargetProfile.resize(
static_cast<int>(iccTargetSize));
713 != JxlDecoderGetColorAsICCProfile(dec.get(),
714#
if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0,9,0)
717 JXL_COLOR_PROFILE_TARGET_ORIGINAL,
718 reinterpret_cast<uint8_t *
>(iccTargetProfile.data()),
719 static_cast<size_t>(iccTargetProfile.size()))) {
720 document->setErrorMessage(i18nc(
"JPEG-XL errors",
"Unable to read the image profile."));
725 if (iccTargetSize && (iccProfile != iccTargetProfile)) {
732 dbgFile <<
"XYB with color transform needed";
733 needColorTransform =
true;
743 profileIntermediate);
745 d.m_depthID_target.id(),
748 d.m_depthID_target.id(),
754 needIntermediateTransform =
true;
756 }
else if (!
d.m_info.uses_original_profile) {
761 dbgFile <<
"XYB without color transform needed";
762 needColorTransform =
false;
763 d.m_depthID =
d.m_depthID_target;
764 d.m_colorID =
d.m_colorID_target;
765 d.m_pixelFormat.data_type =
d.m_pixelFormat_target.data_type;
770 dbgFile <<
"JXL CICP data couldn't be handled, falling back to ICC profile retrieval";
772 d.m_depthID_target.id(),
775 d.m_depthID_target.id(),
780 dbgFile <<
"Original without color transform needed";
781 needColorTransform =
false;
790 dbgFile <<
"Source profile:" <<
d.cs->profile()->name();
791 dbgFile <<
"Source space:" <<
d.cs->name() <<
d.cs->colorModelId() <<
d.cs->colorDepthId();
792 dbgFile <<
"Target profile:" <<
d.cs_target->profile()->name();
793 dbgFile <<
"Color space:" <<
d.cs_target->name() <<
d.cs_target->colorModelId()
794 <<
d.cs_target->colorDepthId();
796 dbgFile <<
"Color space:" <<
d.cs->name() <<
d.cs->colorModelId() <<
d.cs->colorDepthId();
798 dbgFile <<
"JXL depth" <<
d.m_pixelFormat.data_type;
800 d.lCoef =
d.cs->lumaCoefficients();
802 image =
new KisImage(document->createUndoStore(),
803 static_cast<int>(
d.m_info.xsize),
804 static_cast<int>(
d.m_info.ysize),
808 layer =
new KisPaintLayer(image, image->nextLayerName(), UCHAR_MAX);
809 }
else if (status == JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
814 if (JXL_DEC_SUCCESS != JxlDecoderImageOutBufferSize(dec.get(), &
d.m_pixelFormat, &rawSize)) {
815 qWarning() <<
"JxlDecoderImageOutBufferSize failed";
818 d.m_rawData.resize(rawSize);
820 != JxlDecoderSetImageOutBuffer(dec.get(),
822 reinterpret_cast<uint8_t *
>(
d.m_rawData.data()),
823 static_cast<size_t>(
d.m_rawData.size()))) {
824 qWarning() <<
"JxlDecoderSetImageOutBuffer failed";
830 size_t bufferSize = 0;
832 != JxlDecoderExtraChannelBufferSize(dec.get(), &
d.m_pixelFormat, &bufferSize,
d.cmykChannelID)) {
833 errFile <<
"JxlDecoderExtraChannelBufferSize failed";
837 d.kPlane.resize(bufferSize);
839 != JxlDecoderSetExtraChannelBuffer(dec.get(),
844 errFile <<
"JxlDecoderSetExtraChannelBuffer failed";
849 }
else if (status == JXL_DEC_FRAME) {
850 if (JXL_DEC_SUCCESS != JxlDecoderGetFrameHeader(dec.get(), &
d.m_header)) {
851 errFile <<
"JxlDecoderGetFrameHeader failed";
855 const JxlBlendMode blendMode =
d.m_header.layer_info.blend_info.blendmode;
857 if (isMultilayer || isMultipage) {
859 QByteArray layerNameRaw;
860 if (
d.m_header.name_length) {
863 document->setErrorMessage(i18nc(
"JPEG-XL",
"Invalid JPEG-XL layer name length"));
866 layerNameRaw.resize(
static_cast<int>(
d.m_header.name_length + 1));
868 != JxlDecoderGetFrameName(dec.get(),
870 static_cast<size_t>(layerNameRaw.size()))) {
871 errFile <<
"JxlDecoderGetFrameName failed";
874 dbgFile <<
"\tlayer name:" << QString(layerNameRaw);
875 layerName = QString(layerNameRaw);
877 layerName = QString(
"Layer");
881 if (!layerNameRaw.isEmpty()) {
882 layer->setName(layerName);
885 additionalLayers.emplace_back(
new KisPaintLayer(image, layerName, UCHAR_MAX));
886 if (blendMode == JXL_BLEND_MULADD) {
887 additionalLayers.back()->setCompositeOpId(QString(
"add"));
891 }
else if (status == JXL_DEC_FULL_IMAGE) {
894 const JxlLayerInfo layerInfo =
d.m_header.layer_info;
895 const QRect layerBounds = QRect(
static_cast<int>(layerInfo.crop_x0),
896 static_cast<int>(layerInfo.crop_y0),
897 static_cast<int>(layerInfo.xsize),
898 static_cast<int>(layerInfo.ysize));
900 dbgFile <<
"Importing frame @" <<
d.m_nextFrameTime
901 <<
d.m_header.duration;
907 const uint32_t frameDurationNorm =
d.m_header.duration == 0xFFFFFFFF ? 1 :
d.m_header.duration;
908 if (
d.m_nextFrameTime == 0) {
909 dbgFile <<
"Animation detected, ticks per second:"
910 <<
d.m_info.animation.tps_numerator
911 <<
d.m_info.animation.tps_denominator;
918 std::lround(
d.m_info.animation.tps_numerator
919 /
static_cast<double>(
920 d.m_info.animation.tps_denominator));
921 if (framerate > 240) {
922 warnFile <<
"JXL ticks per second value exceeds 240, "
923 "approximating FPS from the duration of "
925 document->setWarningMessage(
926 i18nc(
"JPEG-XL errors",
927 "The animation declares a frame rate of more "
929 const int approximatedFramerate = std::lround(
930 1000.0 /
static_cast<double>(
d.m_header.duration));
931 d.m_durationFrameInTicks =
932 static_cast<int>(frameDurationNorm);
933 framerate = std::max(approximatedFramerate, 1);
935 d.m_durationFrameInTicks = 1;
937 dbgFile <<
"Framerate:" << framerate;
938 layer->enableAnimation();
939 image->animationInterface()->setDocumentRangeStartFrame(0);
940 image->animationInterface()->setFramerate(framerate);
943 const int currentFrameTime = std::lround(
944 static_cast<double>(
d.m_nextFrameTime)
945 /
static_cast<double>(
d.m_durationFrameInTicks));
949 image->animationInterface()->setDocumentRangeEndFrame(
950 std::lround(
static_cast<double>(
d.m_nextFrameTime
952 /
static_cast<double>(
d.m_durationFrameInTicks))
954 frame->
importFrame(currentFrameTime,
d.m_currentFrame,
nullptr);
955 d.m_nextFrameTime +=
static_cast<int>(frameDurationNorm);
957 if (
d.isCMYK &&
d.m_info.uses_original_profile) {
961 layerBounds.height());
964 planes[3] =
reinterpret_cast<quint8 *
>(
d.kPlane.data());
965 d.m_currentFrame->writePlanarBytes(planes,
969 layerBounds.height());
978 f->process(
d.m_currentFrame, layerBounds, kfc->cloneWithResourcesSnapshot());
981 layer->paintDevice()->makeCloneFrom(
d.m_currentFrame, layerBounds);
984 additionalLayers.back()->paintDevice()->makeCloneFrom(
d.m_currentFrame, layerBounds);
987 }
else if (status == JXL_DEC_SUCCESS || status == JXL_DEC_BOX) {
988 if (std::strlen(boxType.data()) != 0) {
990 const auto availOut = JxlDecoderReleaseBoxBuffer(dec.get());
991 const int finalSize = box.size() -
static_cast<int>(availOut);
994 QByteArray type = boxType.toLower();
995 if ((std::equal(
exifTag.begin(),
exifTag.end(), type.constBegin())
996 || std::equal(
xmpTag.begin(),
xmpTag.end(), type.constBegin()))
998 metadataBoxes.emplace(type, QByteArray(box.data(), finalSize));
1004 if (status == JXL_DEC_SUCCESS) {
1009 for (
auto &metaBox : metadataBoxes) {
1010 const QByteArray &type = metaBox.first;
1011 QByteArray &
value = metaBox.second;
1012 QBuffer buf(&
value);
1013 if (std::equal(
exifTag.begin(),
exifTag.end(), type.constBegin())) {
1014 dbgFile <<
"Loading EXIF data. Size: " <<
value.size();
1016 const auto *backend =
1020 backend->
loadFrom(layer->metaData(), &buf);
1021 }
else if (std::equal(
xmpTag.begin(),
xmpTag.end(), type.constBegin())) {
1022 dbgFile <<
"Loading XMP or IPTC data. Size: " <<
value.size();
1024 const auto *xmpBackend =
1028 if (!xmpBackend->loadFrom(layer->metaData(), &buf)) {
1032 iptcBackend->
loadFrom(layer->metaData(), &buf);
1039 image->addNode(layer, image->rootLayer().data());
1041 for (
const KisLayerSP &addLayer : additionalLayers) {
1042 image->addNode(addLayer, image->rootLayer().data());
1044 if (needColorTransform) {
1045 if (needIntermediateTransform) {
1046 dbgFile <<
"Transforming to intermediate color space";
1047 image->convertImageColorSpace(
d.cs_intermediate,
1050 image->waitForDone();
1052 dbgFile <<
"Transforming to target color space";
1053 image->convertImageColorSpace(
d.cs_target,
1056 image->waitForDone();
1058 document->setCurrentImage(image);
1061 if (JxlDecoderGetBoxType(dec.get(), boxType.data(), JXL_TRUE) != JXL_DEC_SUCCESS) {
1062 errFile <<
"JxlDecoderGetBoxType failed";
1065 const QByteArray type = boxType.toLower();
1066 if (std::equal(
exifTag.begin(),
exifTag.end(), type.constBegin())
1067 || std::equal(
xmpTag.begin(),
xmpTag.end(), type.constBegin())) {
1068 if (JxlDecoderSetBoxBuffer(
1070 reinterpret_cast<uint8_t *
>(box.data()),
1071 static_cast<size_t>(box.size()))
1072 != JXL_DEC_SUCCESS) {
1073 errFile <<
"JxlDecoderSetBoxBuffer failed";
1077 dbgFile <<
"Skipping box" << boxType.data();
1080 }
else if (status == JXL_DEC_BOX_NEED_MORE_OUTPUT) {
1082 boxSize = box.size();
1083 box.resize(boxSize * 2);
1085 JxlDecoderReleaseBoxBuffer(dec.get());
1086 if (JxlDecoderSetBoxBuffer(
1088 reinterpret_cast<uint8_t *
>(box.data() + boxSize),
1089 static_cast<size_t>(box.size() - boxSize))
1090 != JXL_DEC_SUCCESS) {
1091 errFile <<
"JxlDecoderGetBoxType failed";
1095 errFile <<
"Unknown decoder status" << status;