Compare commits

..

1 Commits

Author SHA1 Message Date
Tomaz Canabrava
2c4e678664 Default to build heif support
Heif is now being widely used because of android and iphones
and it's not really nice to discover that even if I have the
library to handle heif, it's not compilling.
2024-12-09 16:05:24 +01:00
321 changed files with 981 additions and 9667 deletions

View File

@@ -5,18 +5,7 @@ include:
- project: sysadmin/ci-utilities - project: sysadmin/ci-utilities
file: file:
- /gitlab-templates/linux-qt6.yml - /gitlab-templates/linux-qt6.yml
- /gitlab-templates/linux-qt6-next.yml
- /gitlab-templates/alpine-qt6.yml - /gitlab-templates/alpine-qt6.yml
- /gitlab-templates/android-qt6.yml - /gitlab-templates/android-qt6.yml
- /gitlab-templates/freebsd-qt6.yml - /gitlab-templates/freebsd-qt6.yml
- /gitlab-templates/windows-qt6.yml - /gitlab-templates/windows-qt6.yml
- /gitlab-templates/xml-lint.yml
- /gitlab-templates/yaml-lint.yml
image_json_validate:
stage: validate
image: invent-registry.kde.org/sysadmin/ci-images/suse-qt68:latest
tags:
- Linux
script:
- find src/imageformats/ -name *.json | xargs -I file bash -c "echo file && jq -e '(.Keys | type == \"array\") and (.MimeTypes | type == \"array\") and (.MimeTypes | length) == (.Keys | length)' file"

View File

@@ -1,11 +1,10 @@
Dependencies: Dependencies:
- 'on': ['Linux', 'FreeBSD', 'macOS', 'Windows', 'Android'] - 'on': ['Linux', 'FreeBSD', 'macOS', 'Windows', 'Android']
'require': 'require':
'frameworks/extra-cmake-modules': '@same' 'frameworks/extra-cmake-modules': '@same'
'frameworks/karchive': '@same' 'frameworks/karchive' : '@same'
Options: Options:
test-before-installing: True test-before-installing: True
require-passing-tests-on: ['Linux', 'FreeBSD', 'Windows'] require-passing-tests-on: [ 'Linux', 'FreeBSD', 'Windows' ]
cmake-options: "-DKIMAGEFORMATS_DDS=ON -DKIMAGEFORMATS_JXR=ON -DKIMAGEFORMATS_HEIF=ON" cmake-options: "-DKIMAGEFORMATS_JXR=ON"
per-test-timeout: 90

View File

@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
set(KF_VERSION "6.13.0") # handled by release scripts set(KF_VERSION "6.10.0") # handled by release scripts
set(KF_DEP_VERSION "6.13.0") # handled by release scripts set(KF_DEP_VERSION "6.9.0") # handled by release scripts
project(KImageFormats VERSION ${KF_VERSION}) project(KImageFormats VERSION ${KF_VERSION})
include(FeatureSummary) include(FeatureSummary)
find_package(ECM 6.13.0 NO_MODULE) find_package(ECM 6.9.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
@@ -62,9 +62,7 @@ set_package_properties(libavif PROPERTIES
PURPOSE "Required for the QImage plugin for AVIF images" PURPOSE "Required for the QImage plugin for AVIF images"
) )
option(KIMAGEFORMATS_DDS "Enable plugin for DDS format" ON) option(KIMAGEFORMATS_HEIF "Enable plugin for HEIF format" ON)
option(KIMAGEFORMATS_HEIF "Enable plugin for HEIF format" OFF)
if(KIMAGEFORMATS_HEIF) if(KIMAGEFORMATS_HEIF)
pkg_check_modules(LibHeif IMPORTED_TARGET libheif>=1.10.0) pkg_check_modules(LibHeif IMPORTED_TARGET libheif>=1.10.0)
endif() endif()
@@ -72,26 +70,18 @@ add_feature_info(LibHeif LibHeif_FOUND "required for the QImage plugin for HEIF/
option(KIMAGEFORMATS_JXL "Enable plugin for JPEG XL format" ON) option(KIMAGEFORMATS_JXL "Enable plugin for JPEG XL format" ON)
if(KIMAGEFORMATS_JXL) if(KIMAGEFORMATS_JXL)
pkg_check_modules(LibJXL IMPORTED_TARGET libjxl>=0.9.4) pkg_check_modules(LibJXL IMPORTED_TARGET libjxl>=0.7.0)
pkg_check_modules(LibJXLThreads IMPORTED_TARGET libjxl_threads>=0.9.4) pkg_check_modules(LibJXLThreads IMPORTED_TARGET libjxl_threads>=0.7.0)
pkg_check_modules(LibJXLCMS IMPORTED_TARGET libjxl_cms>=0.9.4) pkg_check_modules(LibJXLCMS IMPORTED_TARGET libjxl_cms>=0.9.0)
endif() endif()
add_feature_info(LibJXL LibJXL_FOUND "required for the QImage plugin for JPEG XL images") add_feature_info(LibJXL LibJXL_FOUND "required for the QImage plugin for JPEG XL images")
option(KIMAGEFORMATS_JP2 "Enable plugin for JPEG 2000 format" ON)
if(KIMAGEFORMATS_JP2)
find_package(OpenJPEG CONFIG)
endif()
add_feature_info(OpenJPEG OpenJPEG_FOUND "required for the QImage plugin for JPEG 2000 images")
find_package(LibRaw 0.20.2) find_package(LibRaw 0.20.2)
set_package_properties(LibRaw PROPERTIES set_package_properties(LibRaw PROPERTIES
TYPE OPTIONAL TYPE OPTIONAL
PURPOSE "Required for the QImage plugin for RAW images" PURPOSE "Required for the QImage plugin for RAW images"
) )
# JXR plugin disabled by default due to security issues
option(KIMAGEFORMATS_JXR "Enable plugin for JPEG XR format" OFF) option(KIMAGEFORMATS_JXR "Enable plugin for JPEG XR format" OFF)
if(KIMAGEFORMATS_JXR) if(KIMAGEFORMATS_JXR)
find_package(LibJXR) find_package(LibJXR)
@@ -99,8 +89,8 @@ endif()
add_feature_info(LibJXR LibJXR_FOUND "required for the QImage plugin for JPEG XR images") add_feature_info(LibJXR LibJXR_FOUND "required for the QImage plugin for JPEG XR images")
ecm_set_disabled_deprecation_versions( ecm_set_disabled_deprecation_versions(
QT 6.9.0 QT 6.8.0
KF 6.12.0 KF 6.8.0
) )
add_subdirectory(src) add_subdirectory(src)

271
README.md
View File

@@ -1,7 +1,6 @@
# KImageFormats # KImageFormats
Plugins to allow [`QImage`](https://doc.qt.io/qt-6/qimage.html) to support Plugins to allow `QImage` to support extra file formats.
extra file formats.
## Introduction ## Introduction
@@ -29,10 +28,8 @@ The following image formats have read-only support:
The following image formats have read and write support: The following image formats have read and write support:
- AV1 Image File Format (avif) - AV1 Image File Format (avif)
- DirectDraw Surface (dds)
- Encapsulated PostScript (eps) - Encapsulated PostScript (eps)
- High Efficiency Image File Format (heif) - High Efficiency Image File Format (heif)
- JPEG 2000 (jp2, j2k, jpf)
- JPEG XL (jxl) - JPEG XL (jxl)
- JPEG XR (jxr) - JPEG XR (jxr)
- OpenEXR (exr) - OpenEXR (exr)
@@ -44,22 +41,16 @@ The following image formats have read and write support:
## Contributing ## Contributing
See the [`QImageIOPlugin`](https://doc.qt.io/qt-6/qimageioplugin.html) See the [`QImageIOPlugin`](https://doc.qt.io/qt-6/qimageioplugin.html) documentation for information on how to write a
documentation for information on how to write a new plugin. new plugin.
The main difference between this framework and the image formats of Qt is The main difference between this framework and the qimageformats module
the license. As such, if you write an image format plugin and you are of Qt is the license. As such, if you write an imageformat plugin and
willing to sign the Qt Project contributor agreement, it may be better to you are willing to sign the Qt Project contributor agreement, it may be
submit the plugin directly to the Qt Project. better to submit the plugin directly to the Qt Project.
To be accepted, contributions must:
- Contain the test images needed to verify that the changes work correctly
- Pass the tests successfully
## Duplicated Plugins ## Duplicated Plugins
### The TGA plugin
The TGA plugin supports more formats than Qt's own TGA plugin; The TGA plugin supports more formats than Qt's own TGA plugin;
specifically, the one provided here supports indexed, greyscale and RLE specifically, the one provided here supports indexed, greyscale and RLE
images (types 1-3 and 9-11), while Qt's plugin only supports type 2 images (types 1-3 and 9-11), while Qt's plugin only supports type 2
@@ -70,18 +61,6 @@ licensing. If anyone were willing to write fresh code to improve Qt's
TGA plugin, it would allow the TGA plugin in this framework to be TGA plugin, it would allow the TGA plugin in this framework to be
removed. removed.
### The DDS plugin
The DDS plugin is a fork from Qt 5.6 with bug fixes and improvements.
The plugin was forked because Qt Project no longer supports its DDS plugin.
### The JP2 plugin
The JP2 plugin is based on the popular and wide used OpenJPEG library.
The Qt project has a no longer supported JPEG 2000 plugin based on Jasper.
## License ## License
This framework is licensed under the This framework is licensed under the
@@ -92,117 +71,37 @@ The CMake code in this framework is licensed under the
## Plugin status ## Plugin status
The current implementation of a plugin may not be complete or may have The current implementation of a plugin may not be complete or may have limitations
limitations of various kinds. Typically the limitations are on maximum size of various kinds. Typically the limitations are on maximum size and color depth.
and color depth.
The various plugins are also limited by the formats natively supported by Qt. The various plugins are also limited by the formats natively supported by Qt.
For example, native support for CMYK images is only available since Qt 6.8. For example, native support for CMYK images is only available since Qt 6.8.
### HDR images ### HDR images
HDR images are supported via floating point image formats from DDS, EXR, HDR, HDR images are supported via floating point image formats from EXR, HDR, JXL,
JXL, JXR, PFM and PSD plugins. JXR, PFM and PSD plugins.
It is important to note that in the past these plugins stripped away HDR It is important to note that in the past these plugins stripped away HDR
information, returning SDR images. information, returning SDR images.
HDR images return R, G and B values outside the range 0.0 - 1.0. HDR images return R, G and B values outside the range 0.0 - 1.0.
While Qt painters handles HDR data correctly, some older programs may display While Qt painters handles HDR data correctly, some older programs may display
strange artifacts if they do not use a tone mapping operator (or at least a strange artifacts if they do not use a tone mapping operator (or at least a
clamp). This is not a plugin issue. clamp). This is not a plugin issue.
### Metadata ### Metadata
Metadata support is available in formats that include it via Metadata support is implemented in all formats that support it. In particular,
`QImage::setText()` and `QImage::text()`. To ensure consistent metadata in addition to the classic `"Description"`, `"Author"`, `"Copyright"`, etc... where
functionality, the following keys have been adopted. possible, XMP data is supported via the `"XML:com.adobe.xmp"` key.
About the image: Please note that only the most common metadata is supported.
- `Altitude`: Floating-point number indicating the GPS altitude in meters
above sea level (e.g. 35.4).
- `Author`: Person who created the image.
- `Comment`: Additional image information in human-readable form, for
example a verbal description of the image.
- `Copyright`: Copyright notice of the person or organization that claims
the copyright to the image.
- `CreationDate`: When the image was created or captured. Date and time in
ISO 8601 format without milliseconds (e.g. 2024-03-23T15:30:43). This value
should be kept unchanged when present.
- `Description`: A string that describes the subject of the image.
- `Direction`: Floating-point number indicating the direction of the image
when it was captured in degrees (e.g. 123.3).
- `DocumentName`: The name of the document from which this image was
scanned.
- `HostComputer`: The computer and/or operating system in use at the time
of image creation.
- `Latitude`: Floating-point number indicating the latitude in degrees
north of the equator (e.g. 27.717).
- `Longitude`: Floating-point number indicating the longitude in degrees
east of Greenwich (e.g. 85.317).
- `ModificationDate`: Last modification date and time in ISO 8601 format
without milliseconds (e.g. 2024-03-23T15:30:43). This value should be
updated every time the image is saved.
- `Owner`: Name of the owner of the image.
- `Software`: Name and version number of the software package(s) used to
create the image.
- `Title`: The title of the image.
About the camera:
- `Manufacturer`: The manufacturer of the recording equipment.
- `Model`: The model name or model number of the recording equipment.
- `SerialNumber`: The serial number of the recording equipment.
About the lens:
- `LensManufacturer`: The manufacturer of the interchangeable lens that was
used.
- `LensModel`: The model name or model number of the lens that was used.
- `LensSerialNumber`: The serial number of the interchangeable lens that was
used.
Complex metadata (requires a parser):
- `XML:org.gimp.xml`: XML metadata generated by GIMP and present only in XCF
files.
- `XML:com.adobe.xmp`: [Extensible Metadata Platform (XMP)](https://developer.adobe.com/xmp/docs/)
is the metadata standard used by Adobe applications and is supported by all
common image formats. **Note that XMP metadata is read and written by
plugins as is.** Since it may contain information present in other metadata
(e.g. `Description`), it is the user's responsibility to ensure consistency
between all metadata and XMP metadata when writing an image.
Supported metadata may vary from one plugin to another. Please note that only
the most common metadata are supported and some plugins may return keys not
listed here.
### EXIF Metadata
[EXIF (Exchangeable Image File Format)](https://en.wikipedia.org/wiki/Exif)
metadata is a standard for embedding information within the image file itself.
Unlike the metadata described above, EXIF metadata is used internally by some
plugins to standardize image handling. For example, the JXL plugin uses them
to **set/get the image resolution and metadata**. They are also needed to
make the image properties appear in the file details of some file managers
(e.g. Dolphin).
When reading, EXIF metadata is converted into simple metadata (e.g.
`Description`) and inserted into the image if and only if it is not already
present.
On writing, the image metadata is converted to EXIF and saved appropriately.
Note that, if not present in the image to be saved, the following metadata
are created automatically:
- `Software`: Created using `applicationName` and `applicationVersion` methods
of [`QCoreApplication`](https://doc.qt.io/qt-6/qcoreapplication.html).
- `CreationDate`: Set to current time and date.
- `ModificationDate`: Set to current time and date.
### ICC profile support ### ICC profile support
ICC profile support is implemented in all formats that handle them using ICC support is fully implemented in all formats that support it. When saving,
[`QColorSpace`](https://doc.qt.io/qt-6/qcolorspace.html). When saving, some some formats convert the image using color profiles according to
plugins convert the image using color profiles according to format specifications. In particular, HDR formats almost always convert to linear
specifications. In particular, HDR formats almost always convert to linear
RGB. RGB.
### Maximum image size ### Maximum image size
@@ -215,16 +114,11 @@ plugin ('n/a' means no limit, i.e. the limit depends on the format encoding).
- ANI: n/a - ANI: n/a
- AVIF: 32,768 x 32,768 pixels, in any case no larger than 256 megapixels - AVIF: 32,768 x 32,768 pixels, in any case no larger than 256 megapixels
- DDS: n/a
- EXR: 300,000 x 300,000 pixels - EXR: 300,000 x 300,000 pixels
- EPS: n/a
- HDR: n/a (large image) - HDR: n/a (large image)
- HEIF: n/a - HEIF: n/a
- JP2: 300,000 x 300,000 pixels, in any case no larger than 2 gigapixels
- JXL: 262,144 x 262,144 pixels, in any case no larger than 256 megapixels - JXL: 262,144 x 262,144 pixels, in any case no larger than 256 megapixels
- JXR: n/a, in any case no larger than 4 GB - JXR: n/a, in any case no larger than 4 GB
- KRA: same size as Qt's PNG plugin
- ORA: same size as Qt's PNG plugin
- PCX: 65,535 x 65,535 pixels - PCX: 65,535 x 65,535 pixels
- PFM: n/a (large image) - PFM: n/a (large image)
- PIC: 65,535 x 65,535 pixels - PIC: 65,535 x 65,535 pixels
@@ -265,125 +159,56 @@ been used or the maximum size of the image that can be saved has been limited.
PSD plugin loads CMYK, Lab and Multichannel images and converts them to RGB PSD plugin loads CMYK, Lab and Multichannel images and converts them to RGB
without using the ICC profile. without using the ICC profile.
JP2, JXL, JXR, PSD and SCT plugins natively support 4-channel CMYK images when JXR, PSD and SCT plugins natively support 4-channel CMYK images when compiled
compiled with Qt 6.8+. with Qt 6.8+.
### The DDS plugin
**This plugin can be disabled by setting `KIMAGEFORMATS_DDS` to `OFF`
in your cmake options.**
The following defines can be defined in cmake to modify the behavior of the
plugin:
- `DDS_DISABLE_STRIDE_ALIGNMENT`: disable the stride aligment based on DDS
pitch: it is known that some writers do not set it correctly.
### The HEIF plugin ### The HEIF plugin
**This plugin is disabled by default. It can be enabled by settings **This plugin is disabled by default. It can be enabled with the
`KIMAGEFORMATS_HEIF` to `ON` in your cmake options.** `KIMAGEFORMATS_HEIF` build option in the cmake file.**
The plugin is disabled due to issues with the heif library on certain
distributions. In particular, it is necessary that the HEIF library has
support for HEVC codec. If HEVC codec is not available the plugin
will compile but will fail the tests.
### The EXR plugin ### The EXR plugin
The following defines can be defined in cmake to modify the behavior of the The following defines can be defined in cmake to modify the behavior of the plugin:
plugin: - `EXR_CONVERT_TO_SRGB`: the linear data is converted to sRGB on read to accommodate programs that do not support color profiles.
- `EXR_CONVERT_TO_SRGB`: the linear data is converted to sRGB on read to - `EXR_DISABLE_XMP_ATTRIBUTE`: disables the stores XMP values in a non-standard attribute named "xmp". Note that Gimp reads the "xmp" attribute and Darktable writes it as well.
accommodate programs that do not support color profiles.
- `EXR_DISABLE_XMP_ATTRIBUTE`: disables the stores XMP values in a non-standard
attribute named "xmp". Note that Gimp reads the "xmp" attribute and Darktable
writes it as well.
### The EPS plugin
The plugin uses `Ghostscript` to convert the raster image. When reading it
converts the EPS to PPM and uses the Qt PPM plugin to read the image.
When writing it uses [`QPrinter`](https://doc.qt.io/qt-6/qprinter.html) to
create a temporary PDF file which is then converted to EPS. Therefore, if
`Ghostscript` is not installed, the plugin will not work.
### The HDR plugin ### The HDR plugin
The following defines can be defined in cmake to modify the behavior of the The following defines can be defined in cmake to modify the behavior of the plugin:
plugin: - `HDR_HALF_QUALITY`: on read, a 16-bit float image is returned instead of a 32-bit float one.
- `HDR_HALF_QUALITY`: on read, a 16-bit float image is returned instead of a
32-bit float one.
### The JP2 plugin
**This plugin can be disabled by setting `KIMAGEFORMATS_JP2` to `OFF`
in your cmake options.**
JP2 plugin has the following limitations due to the lack of support by OpenJPEG:
- Metadata are not supported.
- Image resolution is not supported.
- To write ICC profiles you need OpenJPEG V2.5.4 or higher
### The JXL plugin ### The JXL plugin
**The current version of the plugin limits the image size to 256 megapixels **The current version of the plugin limits the image size to 256 megapixels
according to feature level 5 of the JXL stream encoding.** according to feature level 5 of the JXL stream encoding.**
The following defines can be defined in cmake to modify the behavior of the The following defines can be defined in cmake to modify the behavior of the plugin:
plugin: - `JXL_HDR_PRESERVATION_DISABLED`: disable floating point images (both read and write) by converting them to UINT16 images. Any HDR data is lost. Note that FP images are always disabled when compiling with libJXL less than v0.9.
- `JXL_HDR_PRESERVATION_DISABLED`: disable floating point images (both read
and write) by converting them to UINT16 images. Any HDR data is lost. Note
that FP images are always disabled when compiling with libJXL less than v0.9.
- `JXL_DECODE_BOXES_DISABLED`: disable reading of metadata (e.g. XMP). - `JXL_DECODE_BOXES_DISABLED`: disable reading of metadata (e.g. XMP).
### The JXR plugin ### The JXR plugin
**This plugin is disabled by default. It can be enabled by settings **This plugin is disabled by default. It can be enabled with the
`KIMAGEFORMATS_JXR` to `ON` in your cmake options.** `KIMAGEFORMATS_JXR` build option in the cmake file.**
The following defines can be defined in cmake to modify the behavior of the The following defines can be defined in cmake to modify the behavior of the plugin:
plugin: - `JXR_DENY_FLOAT_IMAGE`: disables the use of float images and consequently any HDR data will be lost.
- `JXR_DENY_FLOAT_IMAGE`: disables the use of float images and consequently - `JXR_DISABLE_DEPTH_CONVERSION`: remove the neeeds of additional memory by disabling the conversion between different color depths (e.g. RGBA64bpp to RGBA32bpp) at the cost of reduced compatibility.
any HDR data will be lost. - `JXR_DISABLE_BGRA_HACK`: Windows displays and opens JXR files correctly out of the box. Unfortunately it doesn't seem to open (P)RGBA @32bpp files as it only wants (P)BGRA32bpp files (a format not supported by Qt). Only for this format an hack is activated to guarantee total compatibility of the plugin with Windows.
- `JXR_DISABLE_DEPTH_CONVERSION`: remove the neeeds of additional memory by - `JXR_ENABLE_ADVANCED_METADATA`: enable metadata support (e.g. XMP). Some distributions use an incomplete JXR library that does not allow reading metadata, causing compilation errors.
disabling the conversion between different color depths (e.g. RGBA64bpp to
RGBA32bpp) at the cost of reduced compatibility.
- `JXR_DISABLE_BGRA_HACK`: Windows displays and opens JXR files correctly out
of the box. Unfortunately it doesn't seem to open (P)RGBA @32bpp files as
it only wants (P)BGRA32bpp files (a format not supported by Qt). Only for
this format an hack is activated to guarantee total compatibility of the
plugin with Windows.
- `JXR_ENABLE_ADVANCED_METADATA`: enable metadata support (e.g. XMP). Some
distributions use an incomplete JXR library that does not allow reading
metadata, causing compilation errors.
### The KRA plugin
The KRA format is a ZIP archive containing image data. In particular, the
rendered image in PNG format is saved in the root: the plugin reads this
image.
### The ORA plugin
The ORA format is a ZIP archive containing image data. In particular, the
rendered image in PNG format is saved in the root: the plugin reads this
image.
### The PSD plugin ### The PSD plugin
PSD support has the following limitations: PSD support has the following limitations:
- Only images saved by Photoshop using compatibility mode enabled (Photoshop - Only images saved by Photoshop using compatibility mode enabled (Photoshop default) can be decoded.
default) can be decoded. - Multichannel images are treated as CMY/CMYK and are only loaded if they have 3 or more channels.
- Multichannel images are treated as CMYK if they have 2 or more channels.
- Multichannel images are treated as Grayscale if they have 1 channel.
- Duotone images are treated as grayscale images. - Duotone images are treated as grayscale images.
- Extra channels other than alpha are discarded. - Extra channels other than alpha are discarded.
The following defines can be defined in cmake to modify the behavior of the The following defines can be defined in cmake to modify the behavior of the plugin:
plugin: - `PSD_FAST_LAB_CONVERSION`: the LAB image is converted to linear sRGB instead of sRGB which significantly increases performance.
- `PSD_FAST_LAB_CONVERSION`: the LAB image is converted to linear sRGB instead - `PSD_NATIVE_CMYK_SUPPORT_DISABLED`: disable native support for CMYK images when compiled with Qt 6.8+
of sRGB which significantly increases performance.
- `PSD_NATIVE_CMYK_SUPPORT_DISABLED`: disable native support for CMYK images
when compiled with Qt 6.8+
### The RAW plugin ### The RAW plugin
@@ -398,9 +223,7 @@ The default setting tries to balance quality and conversion speed.
### The XCF plugin ### The XCF plugin
XCF support has the following limitations: XCF support has the following limitations:
- XCF format up to [version 12](https://testing.developer.gimp.org/core/standards/xcf/#version-history) - XCF format up to [version 12](https://testing.developer.gimp.org/core/standards/xcf/#version-history) (no support for GIMP 3).
(no support for GIMP 3).
- The returned image is always 8-bit. - The returned image is always 8-bit.
- Cannot read zlib compressed files. - Cannot read zlib compressed files.
- The rendered image may be slightly different (colors/transparencies) than - The rendered image may be slightly different (colors/transparencies) than in GIMP.
in GIMP.

View File

@@ -19,15 +19,9 @@ macro(kimageformats_read_tests)
endif() endif()
foreach(_testname ${KIF_RT_UNPARSED_ARGUMENTS}) foreach(_testname ${KIF_RT_UNPARSED_ARGUMENTS})
string(REGEX MATCH "-skipoptional" _is_skip_optional "${_testname}")
unset(skip_optional_arg)
if (_is_skip_optional)
set(skip_optional_arg "--skip-optional-tests")
string(REGEX REPLACE "-skipoptional$" "" _testname "${_testname}")
endif()
add_test( add_test(
NAME kimageformats-read-${_testname} NAME kimageformats-read-${_testname}
COMMAND readtest ${skip_optional_arg} ${_fuzzarg} ${_testname} COMMAND readtest ${_fuzzarg} ${_testname}
) )
endforeach(_testname) endforeach(_testname)
endmacro() endmacro()
@@ -49,8 +43,6 @@ macro(kimageformats_write_tests)
foreach(_testname ${KIF_RT_UNPARSED_ARGUMENTS}) foreach(_testname ${KIF_RT_UNPARSED_ARGUMENTS})
string(REGEX MATCH "-lossless$" _is_lossless "${_testname}") string(REGEX MATCH "-lossless$" _is_lossless "${_testname}")
string(REGEX MATCH "-nodatacheck" _is_no_data_check "${_testname}") string(REGEX MATCH "-nodatacheck" _is_no_data_check "${_testname}")
string(REGEX MATCH "-skipoptional" _is_skip_optional "${_testname}")
unset(skip_optional_arg)
unset(lossless_arg) unset(lossless_arg)
unset(no_data_check_arg) unset(no_data_check_arg)
if (_is_lossless) if (_is_lossless)
@@ -61,13 +53,9 @@ macro(kimageformats_write_tests)
set(no_data_check_arg "--no-data-check") set(no_data_check_arg "--no-data-check")
string(REGEX REPLACE "-nodatacheck$" "" _testname "${_testname}") string(REGEX REPLACE "-nodatacheck$" "" _testname "${_testname}")
endif() endif()
if (_is_skip_optional)
set(skip_optional_arg "--skip-optional-tests")
string(REGEX REPLACE "-skipoptional$" "" _testname "${_testname}")
endif()
add_test( add_test(
NAME kimageformats-write-${_testname} NAME kimageformats-write-${_testname}
COMMAND writetest ${lossless_arg} ${no_data_check_arg} ${skip_optional_arg} ${_fuzzarg} ${_testname} COMMAND writetest ${lossless_arg} ${no_data_check_arg} ${_fuzzarg} ${_testname}
) )
endforeach(_testname) endforeach(_testname)
endmacro() endmacro()
@@ -88,11 +76,6 @@ kimageformats_read_tests(
tga tga
) )
if(KIMAGEFORMATS_DDS)
kimageformats_read_tests(dds)
kimageformats_write_tests(dds-nodatacheck-lossless)
endif()
if (KF6Archive_FOUND) if (KF6Archive_FOUND)
kimageformats_read_tests( kimageformats_read_tests(
kra kra
@@ -122,46 +105,16 @@ if (LibHeif_FOUND)
kimageformats_read_tests(FUZZ 1 kimageformats_read_tests(FUZZ 1
hej2 hej2
) )
kimageformats_write_tests(FUZZ 1
hej2-nodatacheck-lossless
)
endif()
if (LibHeif_VERSION VERSION_GREATER_EQUAL "1.19.6")
kimageformats_read_tests(FUZZ 4
avci
)
endif()
endif()
if (OpenJPEG_FOUND)
kimageformats_read_tests(
jp2
)
# CMYK writing is incorrect in versions before 2.5.3
if ("${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}" VERSION_GREATER_EQUAL "2.5.3")
kimageformats_write_tests(
jp2-nodatacheck-lossless
)
endif() endif()
endif() endif()
if (LibJXL_FOUND AND LibJXLThreads_FOUND) if (LibJXL_FOUND AND LibJXLThreads_FOUND)
if(LibJXL_VERSION VERSION_GREATER_EQUAL "0.11.0") kimageformats_read_tests(
kimageformats_read_tests( jxl
jxl )
) kimageformats_write_tests(
kimageformats_write_tests( jxl-nodatacheck-lossless
jxl-nodatacheck-lossless )
)
else()
kimageformats_read_tests(
jxl-skipoptional
)
kimageformats_write_tests(
jxl-skipoptional-nodatacheck-lossless
)
endif()
endif() endif()
if (LibJXR_FOUND) if (LibJXR_FOUND)
@@ -173,7 +126,9 @@ if (LibJXR_FOUND)
) )
endif() endif()
kimageformats_read_tests( # Allow some fuzziness when reading this formats, to allow for
# rounding errors (eg: in alpha blending).
kimageformats_read_tests(FUZZ 1
xcf xcf
) )
@@ -184,7 +139,7 @@ kimageformats_read_tests(
# You can append -lossless to the format to indicate that # You can append -lossless to the format to indicate that
# reading back the image data will result in an identical image. # reading back the image data will result in an identical image.
kimageformats_write_tests( kimageformats_write_tests(
pcx-nodatacheck pcx-lossless
pic-lossless pic-lossless
qoi-lossless qoi-lossless
rgb-lossless rgb-lossless
@@ -203,7 +158,7 @@ if (OpenEXR_FOUND)
) )
# Color space conversions from sRGB to linear on saving and # Color space conversions from sRGB to linear on saving and
# from linear to sRGB on loading result in some rounding errors. # from linear to sRGB on loading result in some rounding errors.
kimageformats_write_tests(FUZZ 6 kimageformats_write_tests(FUZZ 5
exr-nodatacheck-lossless exr-nodatacheck-lossless
) )
endif() endif()

View File

@@ -4,66 +4,34 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/ */
#include <QImage>
#include <QRgb>
#include <QRgba64>
inline int iAbs(const int &v)
{
return v < 0 ? -v : v;
}
template<class Trait> template<class Trait>
static bool fuzzyeq(const QImage &im1, const QImage &im2, int fuzziness, bool perceptiveFuzzer) static bool fuzzyeq(const QImage &im1, const QImage &im2, uchar fuzziness)
{ {
Q_ASSERT(im1.format() == im2.format()); Q_ASSERT(im1.format() == im2.format());
Q_ASSERT(im1.depth() == 24 || im1.depth() == 32 || im1.depth() == 64); Q_ASSERT(im1.depth() == 24 || im1.depth() == 32 || im1.depth() == 64);
const bool hasAlpha = im1.hasAlphaChannel();
const int height = im1.height(); const int height = im1.height();
const int width = im1.width(); const int width = im1.width();
for (int i = 0; i < height; ++i) { for (int i = 0; i < height; ++i) {
const Trait *line1 = reinterpret_cast<const Trait *>(im1.scanLine(i)); const Trait *line1 = reinterpret_cast<const Trait *>(im1.scanLine(i));
const Trait *line2 = reinterpret_cast<const Trait *>(im2.scanLine(i)); const Trait *line2 = reinterpret_cast<const Trait *>(im2.scanLine(i));
for (int j = 0; j < width; ++j) { for (int j = 0; j < width; ++j) {
auto &&px1 = line1[j]; if (line1[j] > line2[j]) {
auto &&px2 = line2[j]; if (line1[j] - line2[j] > fuzziness) {
auto fuzz = int(fuzziness); return false;
}
// Calculate the deltas } else {
auto dr = iAbs(int(qRed(px2)) - int(qRed(px1))); if (line2[j] - line1[j] > fuzziness) {
auto dg = iAbs(int(qGreen(px2)) - int(qGreen(px1))); return false;
auto db = iAbs(int(qBlue(px2)) - int(qBlue(px1))); }
auto da = iAbs(int(qAlpha(px2)) - int(qAlpha(px1)));
// Always compare alpha even on images without it: some formats (e.g. RGBX64),
// want it set to a certain value (e.g. 65535).
if (da > fuzz)
return false;
// Calculate the perceptive fuzziness.
if (hasAlpha && perceptiveFuzzer) {
auto alpha = std::max(4, int(qAlpha(px1)));
if (sizeof(Trait) == 4)
fuzz = std::min(fuzz * (255 / alpha), 255);
else
fuzz = std::min(fuzz * (65535 / alpha), 255 * 257);
} }
// Compare the deltas of R, G, B components.
if (dr > fuzz)
return false;
if (dg > fuzz)
return false;
if (db > fuzz)
return false;
} }
} }
return true; return true;
} }
// allow each byte to be different by up to 1, to allow for rounding errors // allow each byte to be different by up to 1, to allow for rounding errors
static bool fuzzyeq(const QImage &im1, const QImage &im2, uchar fuzziness, bool perceptiveFuzzer = false) static bool fuzzyeq(const QImage &im1, const QImage &im2, uchar fuzziness)
{ {
return (im1.depth() == 64) ? fuzzyeq<QRgba64>(im1, im2, int(fuzziness) * 257, perceptiveFuzzer) : fuzzyeq<QRgb>(im1, im2, int(fuzziness), perceptiveFuzzer); return (im1.depth() == 64) ? fuzzyeq<quint16>(im1, im2, fuzziness) : fuzzyeq<quint8>(im1, im2, fuzziness);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -1,59 +0,0 @@
[
{
"fileName" : "metadata.png",
"metadata" : [
{
"key" : "ModificationDate",
"value" : "2025-02-19T08:27:22+01:00"
},
{
"key" : "Software" ,
"value" : "GIMP 3.0.0-RC3"
},
{
"key" : "Altitude",
"value" : "34"
},
{
"key" : "Author",
"value" : "KDE Project"
},
{
"key" : "Copyright",
"value" : "@2025 KDE Project"
},
{
"key" : "Description",
"value" : "TV broadcast test image."
},
{
"key" : "Latitude",
"value" : "44.6478"
},
{
"key" : "LensManufacturer",
"value" : "KDE Glasses"
},
{
"key" : "LensModel",
"value" : "A1234"
},
{
"key" : "Longitude",
"value" : "10.9254"
},
{
"key" : "Manufacturer",
"value" : "KFramework"
},
{
"key" : "Model",
"value" : "KImageFormats"
}
],
"resolution" : {
"dotsPerMeterX" : 11811,
"dotsPerMeterY" : 5905
}
}
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

View File

@@ -1,2 +0,0 @@
SPDX-FileCopyrightText: Copyright (c) 2006 - 2010 The Open Toolkit library.
SPDX-License-Identifier: MIT

Binary file not shown.

Before

Width:  |  Height:  |  Size: 956 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

View File

@@ -1,7 +0,0 @@
[
{
"fileName" : "rgba16dx10.png",
"fuzziness" : 1,
"description" : "Minimum fuzziness value to pass the test on all architectures."
}
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

View File

@@ -1,7 +0,0 @@
[
{
"fileName" : "rgba_f16.png",
"fuzziness" : 1,
"description" : "Minimum fuzziness value to pass the test on all architectures."
}
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -1,9 +0,0 @@
[
{
"fileName" : "rgb-gimp.png",
"resolution" : {
"dotsPerMeterX" : 3937,
"dotsPerMeterY" : 3937
}
}
]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

View File

@@ -1,11 +1,5 @@
[ [
{ {
"fileName" : "orientation_all.png", "fileName" : "orientation_all.png"
"metadata" : [
{
"key" : "Software" ,
"value" : "GEGL"
}
]
} }
] ]

Binary file not shown.

View File

@@ -1,59 +0,0 @@
[
{
"fileName" : "metadata.png",
"metadata" : [
{
"key" : "ModificationDate",
"value" : "2025-02-26T16:52:06Z"
},
{
"key" : "Software" ,
"value" : "LIFE Pro 2.18.10 (Linux)"
},
{
"key" : "Altitude",
"value" : "34"
},
{
"key" : "Author",
"value" : "KDE Project"
},
{
"key" : "Copyright",
"value" : "@2025 KDE Project"
},
{
"key" : "Description",
"value" : "TV broadcast test image."
},
{
"key" : "Latitude",
"value" : "44.6478"
},
{
"key" : "LensManufacturer",
"value" : "KDE Glasses"
},
{
"key" : "LensModel",
"value" : "A1234"
},
{
"key" : "Longitude",
"value" : "10.9254"
},
{
"key" : "Manufacturer",
"value" : "KFramework"
},
{
"key" : "Model",
"value" : "KImageFormats"
}
],
"resolution" : {
"dotsPerMeterX" : 11811,
"dotsPerMeterY" : 5905
}
}
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

View File

@@ -1,11 +0,0 @@
[
{
"minQtVersion" : "6.8.0",
"fileName" : "testcard_cmyk.tif"
},
{
"maxQtVersion" : "6.7.99",
"unsupportedFormat" : true,
"comment" : "Qt versions lower than 6.8 do not support CMYK format so this test should be skipped."
}
]

Binary file not shown.

View File

@@ -1,11 +0,0 @@
[
{
"minQtVersion" : "6.8.0",
"fileName" : "testcard_cmyk16.tif"
},
{
"maxQtVersion" : "6.7.99",
"unsupportedFormat" : true,
"comment" : "Qt versions lower than 6.8 do not support CMYK format so this test should be skipped."
}
]

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

Some files were not shown because too many files have changed in this diff Show More