From 4026f41890e4394907dee13240ab6e38af7401f2 Mon Sep 17 00:00:00 2001 From: Mirco Miranda Date: Sun, 23 Mar 2025 22:31:23 +0000 Subject: [PATCH] PSD: use linear profile on float images On float images, if not color profile is present, a linear one should be chosen. Photoshop works on 32-bit images in a linear color space. --- src/imageformats/psd.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/imageformats/psd.cpp b/src/imageformats/psd.cpp index 40ae9c3..ab8a6ea 100644 --- a/src/imageformats/psd.cpp +++ b/src/imageformats/psd.cpp @@ -1504,7 +1504,18 @@ bool PSDHandler::read(QImage *image) img.setColorSpace(QColorSpace(QColorSpace::SRgb)); #endif } else if (!setColorSpace(img, irs)) { - // qDebug() << "No colorspace info set!"; + // Float images are used by Photoshop as linear: if no color space + // is present, a linear one should be chosen. + if (header.color_mode == CM_RGB && header.depth == 32) { + img.setColorSpace(QColorSpace(QColorSpace::SRgbLinear)); + } +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + if (header.color_mode == CM_GRAYSCALE && header.depth == 32) { + auto qs = QColorSpace(QPointF(0.3127, 0.3291), QColorSpace::TransferFunction::Linear); + qs.setDescription(QStringLiteral("Linear grayscale")); + img.setColorSpace(qs); + } +#endif } // XMP data