diff --git a/autotests/README.md b/autotests/README.md index 11df784..36f1c4f 100644 --- a/autotests/README.md +++ b/autotests/README.md @@ -88,13 +88,17 @@ are iterated sequentially and the first object that matches the requirements is used for testing (successes are ignored). Supported values ​​for JSON objects: +- `colorSpace` : Type `object`. An object with the `description` (type +`string`), `primaries` (type `string`), `transferFunction` (type `string`), +`colorModel` (type `string`) and `gamma` (type `double`) values ​​of the +image color space. - `comment`: Type `string`. A string shown by the test when a condition occurs. - `description`: Type `string`. A description of the object. Not used by the test. - `disableAutoTransform`: Type `boolean`. By default, tests are run with autotransform enabled (i.e. rotation is applied if the plugin supports it). Set to `true` to disable autotransform. -- `filename`: Type `string`. Name of the template file to use. E.g. +- `fileName`: Type `string`. Name of the template file to use. E.g. "testRGB_Qt_6_2.png". - `fuzziness`: Type `integer`. Set the fuzziness only if not already set on the command line. The value set on the command line wins over the one in the JSON @@ -108,8 +112,8 @@ with (if not set means all). E.g. "6.2.0". - `perceptiveFuzziness` Type `boolean`. Set the perceptive fuzziness only if not already set on the command line. The value set on the command line wins over the one in the JSON file. -- `resolution`: Type `object`. An object with the `dotsPerMeterX` and -`dotsPerMeterY` (integer) values ​​of the image. +- `resolution`: Type `object`. An object with the `dotsPerMeterX` (type `integer`) +and `dotsPerMeterY` (type `integer`) values ​​of the image. - `seeAlso`: Type `string`. More info about the object. Normally used to point to bug reports. Not used by the test. - `skipSequential`: Type `boolean`. Skip the test on sequential access device. @@ -123,6 +127,7 @@ Some examples: - Example 3: [Metadata](read/psd/metadata.psd.json) - Example 4: [Check Qt version, resolution and metadata](read/psd/mch-16bits.psd.json) - Example 5: [Fuzziness setting](read/xcf/birthday16.xcf.json) +- Example 6: [Color space](read/dds/rgba_f16.dds.json) These are just a few examples. More examples can be found in the test folders. diff --git a/autotests/read/avif/metadata.avif.json b/autotests/read/avif/metadata.avif.json index a55909c..7023ef8 100644 --- a/autotests/read/avif/metadata.avif.json +++ b/autotests/read/avif/metadata.avif.json @@ -1,6 +1,12 @@ [ { "fileName" : "metadata.png", + "colorSpace" : { + "description" : "sRGB build-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "ModificationDate", diff --git a/autotests/read/dds/rgba_f16.dds.json b/autotests/read/dds/rgba_f16.dds.json index 9f974b6..b1af327 100644 --- a/autotests/read/dds/rgba_f16.dds.json +++ b/autotests/read/dds/rgba_f16.dds.json @@ -2,6 +2,12 @@ { "fileName" : "rgba_f16.png", "fuzziness" : 1, - "description" : "Minimum fuzziness value to pass the test on all architectures." + "description" : "Minimum fuzziness value to pass the test on all architectures.", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + } } ] diff --git a/autotests/read/exr/rgb-gimp.exr.json b/autotests/read/exr/rgb-gimp.exr.json index 279f25d..f424125 100644 --- a/autotests/read/exr/rgb-gimp.exr.json +++ b/autotests/read/exr/rgb-gimp.exr.json @@ -1,6 +1,12 @@ [ { "fileName" : "rgb-gimp.png", + "colorSpace" : { + "description" : "", + "primaries" : "Custom", + "transferFunction" : "Linear", + "gamma" : 1 + }, "resolution" : { "dotsPerMeterX" : 3937, "dotsPerMeterY" : 3937 diff --git a/autotests/read/hdr/orientation1.hdr.json b/autotests/read/hdr/orientation1.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation1.hdr.json +++ b/autotests/read/hdr/orientation1.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/hdr/orientation2.hdr.json b/autotests/read/hdr/orientation2.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation2.hdr.json +++ b/autotests/read/hdr/orientation2.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/hdr/orientation3.hdr.json b/autotests/read/hdr/orientation3.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation3.hdr.json +++ b/autotests/read/hdr/orientation3.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/hdr/orientation4.hdr.json b/autotests/read/hdr/orientation4.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation4.hdr.json +++ b/autotests/read/hdr/orientation4.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/hdr/orientation5.hdr.json b/autotests/read/hdr/orientation5.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation5.hdr.json +++ b/autotests/read/hdr/orientation5.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/hdr/orientation6.hdr.json b/autotests/read/hdr/orientation6.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation6.hdr.json +++ b/autotests/read/hdr/orientation6.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/hdr/orientation7.hdr.json b/autotests/read/hdr/orientation7.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation7.hdr.json +++ b/autotests/read/hdr/orientation7.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/hdr/orientation8.hdr.json b/autotests/read/hdr/orientation8.hdr.json index 17c883a..4fe008b 100644 --- a/autotests/read/hdr/orientation8.hdr.json +++ b/autotests/read/hdr/orientation8.hdr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/heif/metadata.heif.json b/autotests/read/heif/metadata.heif.json index 8669721..a3edab2 100644 --- a/autotests/read/heif/metadata.heif.json +++ b/autotests/read/heif/metadata.heif.json @@ -1,6 +1,12 @@ [ { "fileName" : "metadata.png", + "colorSpace" : { + "description" : "sRGB build-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "ModificationDate", diff --git a/autotests/read/iff/meta_rgba.iff.json b/autotests/read/iff/meta_rgba.iff.json index c7eba5b..510b86b 100644 --- a/autotests/read/iff/meta_rgba.iff.json +++ b/autotests/read/iff/meta_rgba.iff.json @@ -1,6 +1,12 @@ [ { "fileName" : "metadata.png", + "colorSpace" : { + "description" : "TICC ICC Profile", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "Author", diff --git a/autotests/read/jxl/gimp_exif.jxl.json b/autotests/read/jxl/gimp_exif.jxl.json index 36b764d..1a963c6 100644 --- a/autotests/read/jxl/gimp_exif.jxl.json +++ b/autotests/read/jxl/gimp_exif.jxl.json @@ -1,6 +1,12 @@ [ { "fileName" : "gimp_exif.png", + "colorSpace" : { + "description" : "sRGB build-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "ModificationDate", diff --git a/autotests/read/jxl/orientation6_notranfs.jxl.json b/autotests/read/jxl/orientation6_notranfs.jxl.json index 26cbd56..17aa7df 100644 --- a/autotests/read/jxl/orientation6_notranfs.jxl.json +++ b/autotests/read/jxl/orientation6_notranfs.jxl.json @@ -10,6 +10,12 @@ "minQtVersion" : "6.7.3", "disableAutoTransform": true, "fileName" : "orientation6_notranfs.png", + "colorSpace" : { + "description" : "GIMP built-in sRGB", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "comment" : "Test with automatic transformation disabled." }, { diff --git a/autotests/read/jxl/testcard_rgba_fp16.jxl.json b/autotests/read/jxl/testcard_rgba_fp16.jxl.json index 5230930..21fcb51 100644 --- a/autotests/read/jxl/testcard_rgba_fp16.jxl.json +++ b/autotests/read/jxl/testcard_rgba_fp16.jxl.json @@ -11,6 +11,12 @@ }, { "minQtVersion" : "6.6.2", + "colorSpace" : { + "description" : "sRGB built-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "fileName" : "testcard_rgba_fp16.png" }, { diff --git a/autotests/read/jxl/testcard_rgba_fp32.jxl.json b/autotests/read/jxl/testcard_rgba_fp32.jxl.json index 7d26f19..101a918 100644 --- a/autotests/read/jxl/testcard_rgba_fp32.jxl.json +++ b/autotests/read/jxl/testcard_rgba_fp32.jxl.json @@ -11,6 +11,12 @@ }, { "minQtVersion" : "6.6.2", + "colorSpace" : { + "description" : "sRGB built-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "fileName" : "testcard_rgba_fp32.png" }, { diff --git a/autotests/read/jxr/metadata.jxr.json b/autotests/read/jxr/metadata.jxr.json index e4f4f19..8012682 100644 --- a/autotests/read/jxr/metadata.jxr.json +++ b/autotests/read/jxr/metadata.jxr.json @@ -1,6 +1,12 @@ [ { "fileName" : "metadata.png", + "colorSpace" : { + "description" : "sRGB build-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "CreationDate", diff --git a/autotests/read/jxr/orientation1.jxr.json b/autotests/read/jxr/orientation1.jxr.json index 1ef49ac..7cc98e6 100644 --- a/autotests/read/jxr/orientation1.jxr.json +++ b/autotests/read/jxr/orientation1.jxr.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "GIMP built-in sRGB", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/jxr/testcard_cmyk8.jxr.json b/autotests/read/jxr/testcard_cmyk8.jxr.json index 5ca8feb..f179d3b 100644 --- a/autotests/read/jxr/testcard_cmyk8.jxr.json +++ b/autotests/read/jxr/testcard_cmyk8.jxr.json @@ -2,6 +2,13 @@ { "minQtVersion" : "6.8.0", "fileName" : "testcard_cmyk8.tif", + "colorSpace" : { + "description" : "U.S. Web Coated (SWOP) v2", + "colorModel" : "Cmyk", + "primaries" : "Custom", + "transferFunction" : "Custom", + "gamma" : 0 + }, "resolution" : { "dotsPerMeterX" : 3780, "dotsPerMeterY" : 3780 diff --git a/autotests/read/pfm/comment_gray_half.phm.json b/autotests/read/pfm/comment_gray_half.phm.json index 05c6f45..618b047 100644 --- a/autotests/read/pfm/comment_gray_half.phm.json +++ b/autotests/read/pfm/comment_gray_half.phm.json @@ -1,5 +1,11 @@ [ { - "fileName" : "testcard_gray_half.png" + "fileName" : "testcard_gray_half.png", + "colorSpace" : { + "description" : "Linear sRGB", + "primaries" : "SRgb", + "transferFunction" : "Linear", + "gamma" : 1 + } } ] diff --git a/autotests/read/psd/32bit_grayscale.psd.json b/autotests/read/psd/32bit_grayscale.psd.json new file mode 100644 index 0000000..2b0e102 --- /dev/null +++ b/autotests/read/psd/32bit_grayscale.psd.json @@ -0,0 +1,26 @@ +[ + { + "fileName" : "32bit_grayscale.png", + "colorSpace" : { + "description" : "Linear Grayscale Profile", + "colorModel" : "Gray", + "primaries" : "Custom", + "transferFunction" : "Linear", + "gamma" : 1 + }, + "metadata" : [ + { + "key" : "ModificationDate", + "value" : "2022-03-28T12:46:04" + }, + { + "key" : "Software" , + "value" : "Adobe Photoshop 23.2 (Windows)" + } + ], + "resolution" : { + "dotsPerMeterX" : 2232, + "dotsPerMeterY" : 2232 + } + } +] diff --git a/autotests/read/psd/cmyk16_testcard.psd.json b/autotests/read/psd/cmyk16_testcard.psd.json index 54b7623..e1ee7b8 100644 --- a/autotests/read/psd/cmyk16_testcard.psd.json +++ b/autotests/read/psd/cmyk16_testcard.psd.json @@ -1,7 +1,14 @@ [ { "minQtVersion" : "6.8.0", - "fileName" : "cmyk16_testcard_qt6_8.tif" + "fileName" : "cmyk16_testcard_qt6_8.tif", + "colorSpace" : { + "description" : "Coated FOGRA27 (ISO 12647-2:2004)", + "colorModel" : "Cmyk", + "primaries" : "Custom", + "transferFunction" : "Custom", + "gamma" : 0 + } }, { "minQtVersion" : "6.0.0", diff --git a/autotests/read/psd/cmyk8_testcard.psd.json b/autotests/read/psd/cmyk8_testcard.psd.json index 0f11cd9..a1039d4 100644 --- a/autotests/read/psd/cmyk8_testcard.psd.json +++ b/autotests/read/psd/cmyk8_testcard.psd.json @@ -1,7 +1,14 @@ [ { "minQtVersion" : "6.8.0", - "fileName" : "cmyk8_testcard_qt6_8.tif" + "fileName" : "cmyk8_testcard_qt6_8.tif", + "colorSpace" : { + "description" : "Coated FOGRA27 (ISO 12647-2:2004)", + "colorModel" : "Cmyk", + "primaries" : "Custom", + "transferFunction" : "Custom", + "gamma" : 0 + } }, { "minQtVersion" : "6.0.0", diff --git a/autotests/read/psd/metadata.psd.json b/autotests/read/psd/metadata.psd.json index a08c26c..b122c34 100644 --- a/autotests/read/psd/metadata.psd.json +++ b/autotests/read/psd/metadata.psd.json @@ -1,6 +1,12 @@ [ { "fileName" : "metadata.png", + "colorSpace" : { + "description" : "sRGB build-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "ModificationDate", diff --git a/autotests/read/psd/orientation1.psd.json b/autotests/read/psd/orientation1.psd.json index e09eb63..da43882 100644 --- a/autotests/read/psd/orientation1.psd.json +++ b/autotests/read/psd/orientation1.psd.json @@ -1,6 +1,12 @@ [ { "fileName" : "orientation_all.png", + "colorSpace" : { + "description" : "GIMP built-in sRGB", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "Software" , diff --git a/autotests/read/qoi/testcard_rgba.qoi.json b/autotests/read/qoi/testcard_rgba.qoi.json new file mode 100644 index 0000000..f7a87c9 --- /dev/null +++ b/autotests/read/qoi/testcard_rgba.qoi.json @@ -0,0 +1,11 @@ +[ + { + "fileName" : "testcard_rgba.qoi", + "colorSpace" : { + "description" : "sRGB", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 2.31 + } + } +] diff --git a/autotests/read/raw/RAW_KODAK_C330_FORMAT_NONE_YRGB.raw.json b/autotests/read/raw/RAW_KODAK_C330_FORMAT_NONE_YRGB.raw.json index 087a73a..07687f6 100644 --- a/autotests/read/raw/RAW_KODAK_C330_FORMAT_NONE_YRGB.raw.json +++ b/autotests/read/raw/RAW_KODAK_C330_FORMAT_NONE_YRGB.raw.json @@ -1,6 +1,12 @@ [ { "fileName" : "RAW_KODAK_C330_FORMAT_NONE_YRGB.png", + "colorSpace" : { + "description" : "sRGB", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 2.31 + }, "metadata" : [ { "key" : "Manufacturer", diff --git a/autotests/read/tga/devarea.tga.json b/autotests/read/tga/devarea.tga.json index 6423a99..044d9ba 100644 --- a/autotests/read/tga/devarea.tga.json +++ b/autotests/read/tga/devarea.tga.json @@ -2,6 +2,12 @@ { "fileName" : "extarea.png", "skipSequential" : true, + "colorSpace" : { + "description" : "sRGB build-in", + "primaries" : "SRgb", + "transferFunction" : "SRgb", + "gamma" : 0 + }, "metadata" : [ { "key" : "Author", diff --git a/autotests/templateimage.cpp b/autotests/templateimage.cpp index 15ad33c..6d96172 100644 --- a/autotests/templateimage.cpp +++ b/autotests/templateimage.cpp @@ -6,10 +6,12 @@ #include "templateimage.h" +#include #include #include #include #include +#include #include static QJsonObject searchObject(const QFileInfo& file) @@ -104,6 +106,47 @@ bool TemplateImage::checkOptionaInfo(const QImage& image, QString& error) const return true; } + // test color space (icc profile) + auto color = obj.value("colorSpace").toObject(); + if (!color.isEmpty()) { + auto dsc = color.value("description").toString(); + auto clm = color.value("colorModel").toString(QStringLiteral("Rgb")); + auto prm = color.value("primaries").toString(); + auto trf = color.value("transferFunction").toString(); + auto gmm = color.value("gamma").toDouble(); + auto cs = image.colorSpace(); + + if (cs.description() != dsc) { + error = QStringLiteral("ColorSpace Description mismatch (current: %1, expected: %2)!").arg(cs.description(), dsc); + return false; + } + + auto prmName = QString(QMetaEnum::fromType().valueToKey(quint64(cs.primaries()))); + if (prmName != prm) { + error = QStringLiteral("ColorSpace Primaries mismatch (current: %1, expected: %2)!").arg(prmName, prm); + return false; + } + + auto trfName = QString(QMetaEnum::fromType().valueToKey(quint64(cs.transferFunction()))); + if (trfName != trf) { + error = QStringLiteral("ColorSpace TransferFunction mismatch (current: %1, expected: %2)!").arg(trfName, trf); + return false; + } + + if (qAbs(cs.gamma() - gmm) > 0.01) { + error = QStringLiteral("ColorSpace Gamma mismatch (current: %1, expected: %2)!").arg(cs.gamma()).arg(gmm); + return false; + } + +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + auto clmName = QString(QMetaEnum::fromType().valueToKey(quint64(cs.colorModel()))); + if (clmName != clm) { + error = QStringLiteral("ColorSpace ColorModel mismatch (current: %1, expected: %2)!").arg(clmName, clm); + return false; + } +#endif + } + // Test resolution auto res = obj.value("resolution").toObject(); if (!res.isEmpty()) {