mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-10-09 16:14:40 -04:00
Add color space check during read test
This commit is contained in:
@ -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.
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "metadata.png",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB build-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "ModificationDate",
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "rgb-gimp.png",
|
||||
"colorSpace" : {
|
||||
"description" : "",
|
||||
"primaries" : "Custom",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"resolution" : {
|
||||
"dotsPerMeterX" : 3937,
|
||||
"dotsPerMeterY" : 3937
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "metadata.png",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB build-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "ModificationDate",
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "metadata.png",
|
||||
"colorSpace" : {
|
||||
"description" : "TICC ICC Profile",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Author",
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "gimp_exif.png",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB build-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "ModificationDate",
|
||||
|
@ -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."
|
||||
},
|
||||
{
|
||||
|
@ -11,6 +11,12 @@
|
||||
},
|
||||
{
|
||||
"minQtVersion" : "6.6.2",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB built-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"fileName" : "testcard_rgba_fp16.png"
|
||||
},
|
||||
{
|
||||
|
@ -11,6 +11,12 @@
|
||||
},
|
||||
{
|
||||
"minQtVersion" : "6.6.2",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB built-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"fileName" : "testcard_rgba_fp32.png"
|
||||
},
|
||||
{
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "metadata.png",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB build-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "CreationDate",
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "GIMP built-in sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,11 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "testcard_gray_half.png"
|
||||
"fileName" : "testcard_gray_half.png",
|
||||
"colorSpace" : {
|
||||
"description" : "Linear sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "Linear",
|
||||
"gamma" : 1
|
||||
}
|
||||
}
|
||||
]
|
||||
|
26
autotests/read/psd/32bit_grayscale.psd.json
Normal file
26
autotests/read/psd/32bit_grayscale.psd.json
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
]
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "metadata.png",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB build-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "ModificationDate",
|
||||
|
@ -1,6 +1,12 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "orientation_all.png",
|
||||
"colorSpace" : {
|
||||
"description" : "GIMP built-in sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Software" ,
|
||||
|
11
autotests/read/qoi/testcard_rgba.qoi.json
Normal file
11
autotests/read/qoi/testcard_rgba.qoi.json
Normal file
@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"fileName" : "testcard_rgba.qoi",
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 2.31
|
||||
}
|
||||
}
|
||||
]
|
@ -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",
|
||||
|
@ -2,6 +2,12 @@
|
||||
{
|
||||
"fileName" : "extarea.png",
|
||||
"skipSequential" : true,
|
||||
"colorSpace" : {
|
||||
"description" : "sRGB build-in",
|
||||
"primaries" : "SRgb",
|
||||
"transferFunction" : "SRgb",
|
||||
"gamma" : 0
|
||||
},
|
||||
"metadata" : [
|
||||
{
|
||||
"key" : "Author",
|
||||
|
@ -6,10 +6,12 @@
|
||||
|
||||
#include "templateimage.h"
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QMetaEnum>
|
||||
#include <QVersionNumber>
|
||||
|
||||
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<QColorSpace::Primaries>().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<QColorSpace::TransferFunction>().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<QColorSpace::ColorModel>().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()) {
|
||||
|
Reference in New Issue
Block a user