Commit Graph

35 Commits

Author SHA1 Message Date
Daniel Novomeský
64a43fb04f readtest: special handling for HEIF format 2025-03-12 16:17:59 +01:00
Daniel Novomeský
e4d95c03fa SKIP tests when libheif configuration is incomplete 2025-03-10 22:01:14 +01:00
Mirco Miranda
49060026b7 Read test: added perceptive fuzziness
Added a new parameter to the read tests called `perceptive-fuzz`.
The parameter, when active, modifies the fuzziness value based on the alpha value of the pixel. The more transparent the pixel, the more the fuzziness value increases.

We have found that some image manipulation functions give different results depending on the architecture (we think it is differences in rounding). These differences can become problematic with small alpha values ​​when there are several image conversions from normal alpha to premultiplied alpha (and vice versa).
In particular, the offending plugin is XCF.

The parameter should be set if and only if necessary. CMakeList has not been modified to allow it to be enabled on all format images (you can still try it from the command line). To use it, you need to set it in the JSON file of the image that has problems (after careful analysis).

More info about the issue on #18 

This MR also fixes a bug in `fazzeq()`: it only compared 1/4 of the image.

Below is the same XCF image rendered on AMD64 and PowerPC:

- AMD64:

![image](/uploads/7815ee49fac9b06d08bf1e0e3879f16e/image.png)

- PowerPC:

![image](/uploads/d7432902d638f6caf9589ebb4ad99827/image.png)

The image is visually the same because the differences are with very low alpha and therefore are negligible. The patch proposed with this MR is useful in these cases.
2025-01-24 13:07:32 +00:00
Mirco Miranda
5f92bcbf26 DDS: Fix warning in qfloat16 and test failure on PowerPC
Fixes the following warning:
```
/home/daniel/kimageformats/src/imageformats/dds.cpp: In function ‘qfloat16 readFloat16(QDataStream&)’:
/home/daniel/kimageformats/src/imageformats/dds.cpp:1037:11: warning: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘class qfloat16’ from an array of ‘quint16’ {aka ‘short unsigned int’} [-Wclass-memaccess]
 1037 |     memcpy(&f16, &rawData, sizeof(rawData));
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/qt6/QtCore/qmetatype.h:14,
                 from /usr/include/qt6/QtCore/qobject.h:18,
                 from /usr/include/qt6/QtCore/qiodevice.h:10,
                 from /usr/include/qt6/QtGui/qimageiohandler.h:9,
                 from /usr/include/qt6/QtGui/QImageIOPlugin:1,
                 from /home/daniel/kimageformats/src/imageformats/dds_p.h:13,
                 from /home/daniel/kimageformats/src/imageformats/dds.cpp:12:
/usr/include/qt6/QtCore/qfloat16.h:46:7: note: ‘class qfloat16’ declared here
   46 | class qfloat16
      |       ^~~~~~~~

```

Should also fixes the following failed tests under PowerPC (32-bits):
```
INFO : rgba16dx10.dds: converting rgba16dx10.dds from RGBA16FPx4 to ARGB32
FAIL : rgba16dx10.dds: differs from rgba16dx10.png
       expected data written to rgba16dx10.dds-expected.data
       actual data written to rgba16dx10.dds-actual.data
```
```
INFO : rgba_f16.dds: converting rgba_f16.dds from RGBA16FPx4 to ARGB32
FAIL : rgba_f16.dds: differs from rgba_f16.png
       expected data written to rgba_f16.dds-expected.data
       actual data written to rgba_f16.dds-actual.data
```
2025-01-15 17:45:57 +00:00
Mirco Miranda
ae00c110f2 JXL: Resolution and metadata support via EXIF
- Added a class to read and write minimal exif metadata.
- JXL plugin uses EXIF metadata to load/save the resolution of the image (like GIMP).
- JXL plugin uses EXIF metadata to set/store text metadata and date/time.
- Enable info display in Dolphin (JXL File -> Properties -> Details on a JXL file, see image below).
- Enabled read test to check also image metadata and resolution.

![_52C044E4-1BA9-4D84-AC0A-B834CDAF72D8_](/uploads/f1649c2b506bf61a5f5488da0d4a4534/_52C044E4-1BA9-4D84-AC0A-B834CDAF72D8_.png){width=401 height=357}
2025-01-15 06:12:07 +00:00
Mirco Miranda
a6f7482957 Read / Write test: added NULL device test
DDS plugin crashes if I request supportedSubTypes()

- Fixed DDS plugin crash
- Added NULL device test on both read and write tests

Closes #14
2024-12-16 13:52:06 +00:00
Mirco Miranda
ecbcf3b7f4 DDS: fix buffer overflow in readCubeMap
The issue was identified by OSS Fuzz and the feature was not covered by our tests.

- Added earth-cubemap.dds under MIT licenses taken from [Open Toolkit library](https://github.com/mono/opentk/tree/main/Source/Examples/Data/Textures)
- Fix a wrong image size returned by a cubemap image
- Read test skips .license files
2024-12-12 09:42:24 +00:00
Mirco Miranda
f7c8eaa140 FIxed comparison of unsigned expression
Fix of [Issue 9](https://invent.kde.org/frameworks/kimageformats/-/issues/9)

Same of MR !253 to solve the `Fix of [Issue 9](https://invent.kde.org/frameworks/kimageformats/-/issues/9)` when rebasing.
2024-09-15 15:00:11 +00:00
Mirco Miranda
219d9cb2c2 JXL: added ImageTransformation option
Let Qt rotate the image when the ImageAutotransform option is set to true.

In tests it also solves the image size control with the value returned by the options with certain rotations.
2024-07-30 22:46:52 +00:00
Mirco Miranda
f5a6de7280 Full range HDR support
EXR, HDR, JXR and PFM formats support High Dynamic Range images (FP values grater than 1).

In summary, here is the list of changes:

    EXR, HDR, JXR and PFM: When working with FP formats, the clamp between 0 and 1 ​​is no longer done.
    EXR: Removed old SDR code and conversions. Due to the lack of a QImage Gray FP format, Gray images are output as RGB FP (recently added code for Qt 6.8 has been removed).
    PFM: Due to the lack of a QImage Gray FP format, Gray images are output as RGB FP.
    HDR: Added rotation and exposure support.

With this patch, EXR, JXR, HDR, PFM behave like Qt's TIFF plugin when working with FP images.
2024-07-17 22:24:57 +02:00
Mirco Miranda
b849e48ef4 Fixed wrong plugin options behaviour
While working on MR !230 I noticed that the options read I entered into several plugins could not be read after reading the image.

**The patch fixes problems reading options in plugins and adds option checking in the readtest.cpp.**

In particular, the reading test does the following additional actions:
- reads options before reading the image;
- compare the options read with the options returned by the reader after reading the image;
- compares the format and size of the returned image with the format and size returned by the reader.
2024-06-19 22:18:45 +00:00
Mirco Miranda
cb5ca7fc48 JXR: added CMYK image to read test
Improved read test to skip unsupported image format: the CMYK image test only works if you compile with Qt 6.8 or higher.
2024-06-07 14:09:34 +00:00
Mirco Miranda
4995c9cd15 PSD: support native CMYK introduced by Qt 6.8
Qt 6.8 will introduce native support for the CMYK (8-bit) format.
With this patch you will finally be able to correctly see the colors of CMYK images with ICC profile.
The testing part has been updated with the addition of an (optional) json file for each image to test. Inside you enter which image to use depending on the Qt version.

In short:
- Added native CMYK suport to PSD reader
- CMYK with alpha is converted using QColorSpace in a RGBA image
- Read tests changed to use the correct comparison image based on the Qt version
- Fixed also XCF tests: now works with all Qt version (see also [QTBUG-120614](https://bugreports.qt.io/browse/QTBUG-120614))
- Work around for CCBUG: 468288
2024-06-07 10:16:58 +00:00
Mirco Miranda
41f0411b62 PSD: fix test failure on some systems and fix wrong check on alpha conversion
- Fix PSD alpha conversion
- Fix autoread test to use also TIFF images
2023-04-18 22:14:41 +00:00
Volker Krause
d34c1668aa Bump Qt deprecation level to 6.4 2023-02-01 17:16:45 +01:00
Daniel Novomeský
b1f3a87896 Auto-rotate input images in readtest
Currently, there is no difference in the tests but in the future
we will add images with various transformations defined.
2022-10-12 15:33:08 +02:00
Mirco Miranda
ea14882ff7 Fix messages 2022-10-02 06:01:23 +00:00
Mirco Miranda
524f083ee4 Added EXR test image 2022-10-02 06:01:23 +00:00
Mirco Miranda
c96ad6ba8a Fixes for sequential devices 2022-10-02 06:01:23 +00:00
Mirco Miranda
65a20b43fc Camera RAW images plugin
Plugin to read RAW camera images based on LibRAW.

- Supersedes MR !86 
- Support to LibRaw 0.20 and 0.21-Beta
- Support to multi-shot images: use imageCount(), jumpToImage() to select the wanted shot
- By default generates 16-bits sRGB images using camera white balance and interpolation AHD
- Should fix CCBUG: 454208: on my Debian with KF5.96 and the pulgin installed, I see the preview of all my RAW files (ARW included) in Dolphin

News compared to V1 (MR !86)

- Fix possible stack overflow due to the huge size of LibRaw class
- Fix image allocation with Qt 6 (make use of QImageIOHandler::allocateImage()) 
- Support to XMP metapacket
- Support to quality option. For e.g. you can focus on quality (q = 10) or speed (q = 1)
- oss-fuzz available [here](https://github.com/mircomir/oss-fuzz/tree/raw_fuzz/projects/kimageformats)
2022-09-19 23:52:43 +00:00
Albert Astals Cid
4afafee6c1 Add write tests for heif/avif/jxl
Unfortunately none of them pass since it seems they can't load a png,
save it to their format with loseless quality and read it back and get
exactly the same contents than the png
2022-02-18 00:05:01 +01:00
Ahmad Samir
f5d574b3ad clang-tidy: one declaration per line; braces around statements
clang-tidy checks:
readability-isolate-declaration and readability-braces-around-statements

KF task: https://phabricator.kde.org/T14729

GIT_SILENT
2021-08-13 15:13:21 +02:00
Ahmad Samir
1169859b07 Run clang-format on all cpp/h files
NO_CHANGELOG
2021-03-08 20:15:33 +02:00
Gary Wang
6cf05cf305 test: don't convert image format if possible 2020-11-10 13:03:37 +08:00
Andreas Cord-Landwehr
f4281984c1 Adapt license to LGPL-2.0-or-later
According to relicensecheck Brad is OK with changing LGPLv2 to LGPLv2+,
which is required to be compatible with the LGPL-2.1-or-later licensed
source files.
2020-07-21 09:26:47 +00:00
David Faure
1d12b345f9 GIT_SILENT add missing newline 2020-03-29 01:06:42 +01:00
David Faure
becd7aff3a autotests: print QImageReader::supportedImageFormats, to debug CI failures 2020-03-29 00:47:47 +01:00
Albert Astals Cid
75ef81a109 QImage::byteCount -> QImage::sizeInByes 2019-07-04 22:26:53 +02:00
Albert Astals Cid
a24ece396a autotests: Also exercise canRead 2019-03-31 20:58:26 +02:00
Laurent Montel
f1c6c15b06 compile without foreach
Summary: compile without foreach

Reviewers: dfaure, apol

Reviewed By: apol

Subscribers: apol, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D19317
2019-02-28 23:02:41 +01:00
Albert Astals Cid
03c3c07004 Fix tests on jenkins
Qt also has a tga image plugin so unless we make sure ours is used first
tests are not testing what they should

On a side note their plugin fails our tests so someone with enough time
should report the failures to them
2019-01-28 21:27:22 +01:00
Montel Laurent
d7f457a124 Use QStringLiteral 2015-11-02 21:57:43 +01:00
Alex Merry
0f795e6625 Implement fuzzy image matching in readtest
Images are converted to ARGB32 format, then each byte (ie: each pixel
channel) in the read image is allowed to deviate by some specified
amount from the corresponding byte in the expected image, to allow for
rounding errors etc.

By default, no deviation is permitted, but the XCF tests are allowed a
deviation of 1, as the alpha blending can result in rounding errors
(depending on whether hardware acceleration is used, for example).  In
the end, we are not too concerned about a small deviation that is
invisible to the human eye.

REVIEW: 116567
2014-03-05 12:10:45 +00:00
Alex Merry
6d24f585b1 read autotest: write out data when comparison fails
This helps with debugging, as we can just grab the data rather than
using imageconvertor.

Reviewed-by: David Faure
2014-03-01 14:49:38 +00:00
Alex Merry
f0f6d14367 Add simple autotests
Two main tests: read the file and compare to a given image (loaded from
png), and write a file out and compare to a previously-written image.

The write test in particular is kind of fragile, but it should help
catch some errors where a code change was not intended to affect the
output of the plugin.

Tests are included for all the writable formats, as well as every
readable format that GIMP can write to (and so I could easily get an
example of).

REVIEW: 115430
2014-02-03 15:03:29 +00:00