Commit Graph

444 Commits

Author SHA1 Message Date
56c8bc7323 Add checks on the seek return value 2025-09-09 22:20:34 +02:00
08e178f098 Fix Null-dereference READ 2025-09-09 21:15:19 +02:00
6881e3111b HDR: Limits the header to the first 128 lines
The HDR header is a set of text information spread across a few lines. 
According to the specifications I have, the parameters seem to be a total of 7 / 8 but there could be more. This patch limits the header to 128 lines of maximum 1024 bytes.

Closes #40
2025-09-09 13:59:14 +00:00
463da81fad IFF: support for PCHG chunk
Highlights:
- Adds support for a new palette changer chunk. Some test cases attached to #38 .
- Fixes the reading of ILBMs with the mask (test case: [cyclone.iff](/uploads/d8734d2155fd0d21f7b003b37e0d1259/cyclone.iff)).
- Adds support for HAM5 encoding.
- Adds more test cases created using [HAM Converter](http://mrsebe.bplaced.net/blog/wordpress/).
- Adds support for Atari STE RAST chunk outside FORM one (test case: [fish.iff](/uploads/c461cf4b6a1423cec60fbce645d9fd07/fish.iff)).

NOTE: I contacted Sebastiano Vigna, the author of the PCHG chunk specifications, and he provided me with:
- Some images to test the code (but I can't include them in the test cases).
- Permission to use [his code](https://vigna.di.unimi.it/amiga/PCHGLib.zip) without restrictions: Huffman decompression was achieved by converting `FastDecomp.a` via AI.

Closes #38
2025-09-08 15:39:50 +00:00
8036b1d032 Fix assert when read corrupted floats 2025-09-08 11:01:06 +02:00
eae41980b2 dds: Fix assert when reading broken data
oss-fuzz testcase 6027629841154048
2025-09-06 22:39:16 +00:00
3bf2281610 GIT_SILENT: Use Qt CamelCase includes 2025-09-04 08:32:52 +02:00
59089855fa Unified maximum pixel value for large image plugins 2025-08-30 09:17:58 +02:00
5a067130af Removed the conversion of the entire image to a compatible format when saving from the PCX, PIC, and RGB plugins.
For example, the PCX plugin converts all RGB images to RGB(A)32. So if you try to save a 1 GiB RGB888 image, it will be converted to RGB32 image so, you need additional 1.25GiB of ram. The conversion now occurs line by line, significantly saving memory.
2025-08-30 09:17:40 +02:00
9c6c0c01ae TGA: Support for TGA specification 2.0
Adds TGA 2.0 compliance:
- Support for Extension Area, Developer Area and Footer (metadata support)
- Support for 15-bit and 16-bit per pixel images (both RGB and Indexed)
- Full support for rotation on reading (we cannot use Qt transformations because only a subset is part of the TGA specification)
- When writing you can choose the supported version (subType)
- Improved writing speed (approximately 10 times) and removed whole image conversions (significant memory savings)

It pass the [TrueVision TGA 2.0 conformance suite](https://github.com/zigimg/test-suite/tree/master/fixtures/tga).

Test changes:
- Read test: added ability to skip a specific test on sequential devices (via JSON behavior file)
- Write test: added the ability to set the subType when writing (via JSON properties file)

Closes #37
2025-08-23 09:20:09 +00:00
f933cbe12d Fix possible buffer overflow on corrupted images 2025-08-22 08:08:17 +02:00
ebc366b3c5 TGA: memory optimizations and native grayscale support
- Removed temporary buffer of uncompressed image size when reading (loads images using half the memory)
- Added native support for Grayscale images (they are no longer converted to RGB(A) 32 when reading/writing)
- Fixes wrong X channel value on RGBX32 images (CCBUG: 499584)

It should also reduce loading times for corrupted images.

Closes #33
2025-08-20 21:53:00 +00:00
f63b082c85 IFF: add support for a different palette per line 2025-08-12 08:28:31 +02:00
68cc915132 IFF: Fix possible undefined-shift 2025-08-09 11:46:05 +02:00
e912a4ac9b RAW: Error out on malformed files
Internally, LibRaw often doesn't check the return values of various functions. It's not uncommon to find things like:

fseek(ifp, oAtom, SEEK_SET);
szAtom = get4();
... (more read operations without checking the result)

This means is up to us to error our properly when something went wrong. We do that by keeping an error counter and calling IOERROR once we've reached enough errors. IOERROR will throw an exception that will be internally caught by libraw itself.
2025-08-07 20:39:55 +00:00
480ea8dba0 IFF: add support for RGBN/RGB8 image data and CAT chunk
Add the following features:
- RGB8 image data support (test case added)
- RGBN image data support ([Clouds.iff](/uploads/9db869350f74421bf1813fa7d4332f4f/Clouds.iff))
- CAT chunk support: you can have more than one image for file (test case added)
- Image transformation support via EXIF data

[RGBN/RGB8](https://wiki.amigaos.net/wiki/RGBN_and_RGB8_IFF_Image_Data) files are used in Impulse's Turbo Silver and Imagine.

Closes #34
2025-08-07 20:17:09 +00:00
37e3c65a05 ILBM 64-bit extension support 2025-08-04 13:47:00 +02:00
4b44f8474f Fix oss-fuzz compilation error 2025-08-04 13:46:16 +02:00
c2a1d4b401 IFF: Fix halfbride detection, 1-bitplane colors and PBM line size calculation. It also ignore ZBuffer flag on Maya images (like Photoshop does) amd adds CMYK palette support. 2025-08-01 15:29:52 +02:00
fd864e6f55 IFF: add support for uncompressed ACBM type 2025-07-24 07:37:58 +02:00
1d69f6af57 IFF: add mime types and extensions 2025-07-17 07:32:26 +02:00
083680eb77 chunks.cpp - send info and warning messages to the iff logging category
For example:
`IFFChunk::innerFromDevice: unkwnown chunk "\x89PNG"`

becomes:
`kf.imageformats.plugins.iff: IFFChunk::innerFromDevice: unknown chunk "\x89PNG"`

bonus: we can filter out such messages if we want using QT_LOGGING_RULES

also note the spelling fix
2025-07-16 11:00:54 -04:00
0a9f9fe106 IFF: support for Ham8, HalfBride, Pbm and ILBM 32-bits modes 2025-07-15 07:38:19 +02:00
21b3b890ec tga: Be less strict about palette
There's images in the wild that claim to not have a palette
but still have one.
2025-07-09 13:17:20 +02:00
aef4bd7e1c Fix unused param in MicroExif::toByteArray() 2025-07-07 08:17:36 +02:00
ea1983a7d1 IFF: Fix possible stack overflow 2025-07-05 09:59:06 +00:00
f6c718a789 TGA: add indexed write support
Indexed images are saved as uncompressed TGA with color map.

Closes #30
2025-07-03 07:36:33 +02:00
4f2f2425d3 IFF: read only support to Interchange Format Files
Read-only support for most common Interchange Format Files (IFF). Supports IFF saved by Photoshop for the Amiga and Maya platform and HAM6 coded files.

Closes #29
2025-07-01 21:59:03 +00:00
e6357c22f7 tga: Use Format_Indexed8 for indexed formats and support 32-bit BGRA colormap 2025-06-26 16:00:11 +02:00
e3aefd2aa1 JXR: Restore device position after reading options 2025-05-14 02:50:03 +02:00
850068c1dc JXR: fix compilation error on 32-bit systems 2025-04-22 08:01:02 +02:00
6bf38ea638 Improved EXIF V3 compatibility (2)
This patch improve the string read/write in case of non ASCII encoding.
- When reading, checks for UTF-8 text even on ASCII data type. If it fails, Latin1 converter is used.
- When writing using V3 specs, a better check is done to identify 7-bit ASCII text.

Related to MR !358
2025-04-21 11:29:13 +00:00
2adca7c0ca jxr: Use qsizetype for image size variables
Fixes type mismatch on 32-bit architectures.

/builddir/build/BUILD/kf6-kimageformats-6.13.0-build/kimageformats-6.13.0/src/imageformats/jxr.cpp: In member function ‘virtual bool JXRHandler::read(QImage*)’:
/builddir/build/BUILD/kf6-kimageformats-6.13.0-build/kimageformats-6.13.0/src/imageformats/jxr.cpp:994:88: error: no matching function for call to ‘min(qint64&, qsizetype)’
  994 |                 std::memcpy(img.scanLine(y), ba.data() + convStrideSize * y, (std::min)(convStrideSize, img.bytesPerLine()));
      |                                                                              ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-04-21 10:07:00 +02:00
dd69fdaea9 lib prefix on Android
Qt's original qtimageformats plug-ins use lib prefix too,
without the lib prefix, the image plug-ins don't work on Android.
2025-04-19 14:16:18 +00:00
ae62ea3dfc Improved EXIF V3 compatibility
EXIF specs V3 added the UTF-8 data type. The MicroExif class now allows serializations to choose whether to support the V2 or V3 format. To maximize compatibility with old readers, even when V3 is set, the ASCII data type is used if possible.

The JXR plugin, based on TIFF V6 container, does not allow to use the V3 format (it does not recognize the UTF-8 data type) and therefore V2 has been forced. For all other plugins using MicroExif, it is now possible to save, e.g., descriptions in Japanese.

Please note that this patch is also a bugfix: when saving, version 3 was set but the strings were always saved as ASCII.
2025-04-18 13:53:12 +00:00
7c7fa73020 Remove conditions for no longer supported Qt versions 2025-04-08 18:46:13 +02:00
6f588c6fd3 Add missing include mocs 2025-04-03 07:34:17 +02:00
4026f41890 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.
2025-03-23 22:31:23 +00:00
9bee29cc01 heif: enable saving of hej2 format 2025-03-16 18:37:48 +01:00
6821c29819 heif: disable AVCI decoder for libheif before 1.19.6 2025-03-12 13:26:42 +01:00
afa8ed1a5d heif: enable reading images with native 16 bit depth 2025-03-10 19:42:34 +01:00
245c835d92 Use of heif_context_add_XMP_metadata instead
heif_context_add_XMP_metadata2
2025-03-09 10:44:18 +01:00
b28baa4a1e sct: qRound with param bigger than max int is undefined
oss-fuzz/399667098
2025-03-04 06:33:52 +00:00
5d2540c135 sct: Use height instead of width when calculating dotsPerMeterY 2025-03-04 06:29:58 +00:00
25cc8bc262 MicroExif: search for the TIFF signature 2025-03-03 09:17:56 +01:00
7742537f8c MicroExif: API improvements and minor bugfixes 2025-03-02 13:34:02 +00:00
d3386bbf50 Fix compilation error 2025-03-02 13:49:25 +01:00
e77986c7e0 Added support for resolution and EXIF/XMP metadata to HEIF 2025-03-02 08:03:28 +00:00
c0261f4926 JXR: Added rotation (transformation) support
- Full rotation support on load and save.
- Improve also Windows compatibility by converting RGB32 to BGR32 on saving

Images saved with orientation are displayed correctly by Windows Explorer (which natively supports JXR files):

![_BC374A2E-7970-4B72-87BD-68DD3D8FB7AA_](/uploads/2268aa3066d82a4f97d026a64f2b70c2/_BC374A2E-7970-4B72-87BD-68DD3D8FB7AA_.png){width=597 height=259}
2025-02-25 21:37:17 +00:00
e5cf9caac5 JXR: added support to EXIF metadata
Improved metadata support via EXIF ​​metadata. Since JXR is based on a TIFF container, EXIF ​​data is read directly from the file so it always works (even with versions of libjxr that don't have the metadata reading API).

It also solves the following issues:
- Incorrect date format on saved JXR files (was saved in ISO format instead of `yyyy:MM:dd HH:mm:ss`).
- Incorrect date type setting in EXIF ​​data: the `DateTime` tag should be updated on every save (verified by GIMP and Photoshop). Our `CreationDate` metadata is the equivalent of the EXIF ​​`DateTimeOriginal` tag.

Closes #22
2025-02-23 00:38:27 +00:00