Commit graph

10660 commits

Author SHA1 Message Date
Alx Sa
beb0d85224 plug-ins: Fix unused variable warning in file-xpm
In file-xpm, use_x_api is only used when
GDK_WINDOWING_X11 is defined. However, it was
included as a general variable so it threw an unused variable
warning when compiled on other systems.
This patch moves the variable declaration inside the first
#ifdef GDK_WINDOWING_X11 block of the parse_colors ()
function.
2026-04-08 20:52:35 +00:00
Alx Sa
86740b51e8 plug-ins: Add Windows WIA scanner plug-in
We dropped 32bit Windows support in
GIMP 3.2.2, which also removed the
32bit-only TWAIN scanner plug-in.

This patch adds a new plug-in that uses
the 64bit compatible WIA API for scanning.
It should restore the support for scanning on
Windows.
2026-04-08 17:20:06 +00:00
Gabriele Barbero
691785113a plug-ins: validate fcTL frame dimensions...
...against IHDR bounds in APNG loader

The pixel buffer is allocated using base image dimensions from the IHDR
chunk, but row write offsets were computed using the per-frame dimensions
from the fcTL chunk with no bounds check. A crafted APNG file with
fcTL.width > IHDR.width or fcTL.height > IHDR.height would cause
out-of-bounds writes into the heap on every row after row 0.

Reject fcTL frames whose dimensions or offsets extend beyond the base
image dimensions before proceeding with decoding.
2026-04-08 11:47:05 +02:00
Jehan
941bfcf918 plug-ins: remove gimp_quit() calls from the Script-Fu server.
And exit gracefully with error messages to display when any of the
critical errors which may occur does (e.g. network errors when creating
a socket).
2026-04-07 19:25:35 +02:00
Jehan
cf6871763c plug-ins: remove all gimp_quit() calls from PSD export code.
Now instead of just unexpectedly ending the plug-in process, let's
gracefully return with a GIMP_PDB_EXECUTION_ERROR and proper error
message, when any of the stream-writing function fails.
2026-04-07 18:22:43 +02:00
Jehan
73440b1627 plug-ins: get rid of various gimp_quit().
I am going to deprecate this function. We should stop just killing
plug-ins randomly when things are bugged. Instead we should still try
and return cleanly (with an error status and message).
2026-04-07 18:22:43 +02:00
Jehan
7dc8fefbfd app, libgimp, pdb, plug-ins: new gimp_resources_loaded() function.
And use the function in script-fu. While we want wrong resource names to
trigger WARNINGs in Script-Fu scripts and plug-ins (because these can be
considered as a bug), we don't want it to happen when the resource is
not loaded on purpose (mostly it means that we run GIMP with --no-data
or --no-fonts). This was happening in our own builds when running GIMP
through the in-build-gimp.py script and that was always very annoying.

Now in such a case, we will only output an INFO message on stderr (it's
still a good idea to warn about this, because if we imagined someone was
running a script non-interactively, which called one of these
procedures, they may have relied on the default value of some arguments.
Therefore they'd want to know about such a behavior change).
2026-04-06 16:29:40 +02:00
Jehan
1107d0f7af app, pdb, plug-ins: improve error feedback for gimp_temp_file().
It is not a fix yet for #14681 but would provide nicer and earlier error
when a call to gimp_temp_file() fails, which may happen in some cases.
E.g. if the temp directory doesn't exist and we fail to create it.

As a test, if I delete /tmp/gimp/3.2/ and give root ownership to
/tmp/gimp/, now the error when opening our gimp-splash.xcf.xz is:

GIMP-Error: Opening '/path/to/gimp/gimp-data/images/gimp-splash.xcf.xz' failed: Error creating directory /tmp/gimp/3.2: Permission denied
2026-04-04 23:05:26 +02:00
Jehan
fd9484a8b8 plug-ins: better error message for file-compressor for specific issues.
This is a further improvement, for the specific case which appeared on
issue #16160. Basically here for the specific case when we have
permission issues, or other similar issues where we fail to either load
the input image, or export to the temporary file, we would get more
explicit error messages. And this would also show in the stderr output
of the in-build-gimp.py script.

In particular, when reproducing #16160 permission issue, the build logs
now contain this error:

GIMP-Error: Opening '/path/to/gimp/gimp-data/images/gimp-splash.xcf.xz' failed: Error creating temporary file '/tmp/gimp/3.2/gimp-temp-1719540.xcf': Permission denied

This should better help diagnose similar issues in the future.
2026-04-04 17:21:45 +02:00
Alx Sa
d88cd4cb7a plug-ins: Improve color detection in file-pdf-export
Resolves #14583
If the user chooses to vectorize PDF layers with single colors,
get_layer_color () is run to use histograms to determine if they
are indeed a single color. gimp_drawable_histogram () is used to
get the RGB values as averages. This function returns values in the
0...255 range for 8-bit images and 0.0...1.0 range for all the
other precisions.

However, we did not properly normalize the values, resulting in
blown-out white layers when exporting 8-bit images. This patch
checks if the image is 8-bit and divides all values by 255.0f in
that case.

It also checks if the image is in linear precision or not, as
gegl_color_set_rgba () assumes the color values are linear. If not,
gegl_color_set_pixel () is used instead. Finally, the color mode
checks are made a bit more robust in preparation for future color
modes like CMYK.
2026-04-04 12:38:36 +00:00
Bruno Lopes
9aef11022a plug-ins: Use _fileno on Windows 2026-04-03 11:09:54 -03:00
Bruno Lopes
9926795610 plug-ins: Include <memory> when on MSVC 2026-04-03 08:29:52 -03:00
Bruno Lopes
06aa66428d plug-ins: Add HAVE_SYS_TIME_H check on file-heif
This fixes a build error on MSVC
2026-04-03 08:12:08 -03:00
Alx Sa
55256210f8 plug-ins: Fix algorithm check for PAA import
Resolves #16151
The original implementation mixed up the variable that
needed to be used for boundary checks - it should be
"estimated_size" and not "flags". This patch fixes the issue
to prevent a buffer overflow.
2026-04-02 14:02:28 +00:00
Alx Sa
bfec7079f0 plug-ins: Prevent attack via APNG transparent chunk
Resolves #16150
Per Bronson Yen, it's possible to create a transparent chunk
that's larger than 256 index values. In that case, the trans[]
array will overflow since we initialize it to 256 indexes.
This patch adds a check to make sure the iterator used for the
transparency for loop does not exceed the array size even if
the chunk size does.
2026-04-02 05:34:45 +00:00
Bruno Lopes
1dd77b6fdf plug-ins: No need to clang-specific pragma
This partially reverts 94f77bd2
2026-04-01 09:47:56 -03:00
Bruno Lopes
eaa472158c plug-ins: Silence deprecation warning about rsvg_handle_set_size_callback 2026-04-01 08:04:56 -03:00
Bruno Lopes
d025b02823 plug-ins: Use localtime_s on Windows to fix CRT_INSECURE_DEPRECATE warns 2026-04-01 07:38:12 -03:00
Bruno Lopes
f4969c2f80 plug-ins: Use fopen_s on Windows to fix CRT_INSECURE_DEPRECATE warns 2026-04-01 07:16:32 -03:00
Bruno Lopes
f14f9516e2 plug-ins: Fix some problematic Windows functions
The macro should be enough but
on these source files it does not work.
2026-03-31 21:44:51 -03:00
Bruno Lopes
dae02feed3 plug-ins: Use Glib date-time functions 2026-03-31 21:44:51 -03:00
Bruno Lopes
4643f7898f plug-ins: More casting fixes 2026-03-31 21:44:51 -03:00
Bruno Lopes
3807b2f311 app, plug-ins: More sscanf_s on Windows 2026-03-31 21:44:51 -03:00
Bruno Lopes
e97e3d0e35 plug-ins: Forgot a macro 2026-03-31 18:58:47 -03:00
Bruno Lopes
d254c5684c app, libgimp*, plug-ins: Use strtok_s on Windows to fix CRT_INSECURE_DEPRECATE 2026-03-31 16:27:25 -03:00
Bruno Lopes
ed3611efa6 app, libgimp*, plug-ins: Use strncpy_s on Windows to fix CRT_INSECURE_DEPRECATE 2026-03-31 13:31:33 -03:00
Bruno Lopes
84c7274c70 plug-ins: Use fscanf_s on Windows to fix CRT_INSECURE_DEPRECATE warnings 2026-03-31 13:31:33 -03:00
Bruno Lopes
a146c4ae56 plug-ins: Do not redefine math macros on MSVC 2026-03-30 22:32:01 -03:00
Bruno Lopes
77682518b9 app, plug-ins: Use strcpy_s on Windows to fix CRT_INSECURE_DEPRECATE warnings 2026-03-30 22:32:01 -03:00
Bruno Lopes
2066844166 app, lib*, plug-ins: Use sscanf_s on Windows to fix CRT_INSECURE_DEPRECATE warns 2026-03-30 22:31:57 -03:00
Bruno Lopes
c19ed5ca98 plug-ins: Cast g_string_append_c argument to gchar on file-tiff
Silences an Apple Clang warning
2026-03-30 16:09:13 -03:00
Bruno Lopes
94f77bd256 plug-ins: Silence 'register' storage class specifier warning on Clang too 2026-03-29 21:07:00 -03:00
Bruno Lopes
8c0ce0cd64 plug-ins: Fix many type conversions on file-psd
As per Apple Clang warnings.
2026-03-29 18:31:52 -03:00
Bruno Lopes
af1dac3c51 app, plug-ins: Comment unused stuff on macOS
This fixes Apple Clang warnings about:

- idx
- count_large
- count_nan
- n
- iteration
- original_id
- real_pos
2026-03-29 17:19:42 -03:00
Bruno Lopes
f4f1baf5ef app, libgimp, libgimpbase, libgimpwidgets, plug-ins: Add macro to unused code
This fixes Apple Clang warnings about:

- xdiff
- ydiff
- gimp_ui_get_foreign_window
- locale_parser_parse
- use_app_menu
- gimp_unique_dbus*
- transient_set
- gimp_get_foreign_window
- support
2026-03-29 17:19:42 -03:00
Bruno Lopes
0834c7c954 app, plug-ins: Use GINT_TO_POINTER / GPOINTER_TO_INT for portability
Doing traditional explicit conversion (casting) causes warnings.
See: https://docs.gtk.org/glib/conversion-macros.html
2026-03-28 19:51:25 -03:00
Bruno Lopes
41c9d8ce9c plug-ins: Initialize raw_len32 2026-03-28 19:51:25 -03:00
Bruno Lopes
c8c420aa18 app, plug-ins: Comment pixel, total, flags and count unused variables 2026-03-28 19:51:25 -03:00
Alx Sa
2f7b49dfea plug-ins: Change TIM texture indexed conversion
There are reports that clang-based compilers create
a TIM plug-in that crashes when exporting. This seems
related to the method used to convert RGB images to
indexed when choosing TIM textures with palettes on export.

This patch switches to using gimp-image-convert-indexed
instead, to prevent the format mismatch crash on initial export.
2026-03-28 05:56:29 +00:00
Bruno Lopes
1437c84d07 plug-ins: Fix meson warning about missing check: kwarg 2026-03-27 09:53:03 -03:00
Frank Teklote
061a7eada2 file-psd: fix ordering of loaded Photoshop paths
Previously, paths from Photoshop TIFF files were appended via
gimp_image_insert_path(..., -1), which caused the displayed order to be
reversed. This change preserves the original ordering while keeping the
'Working Path' as the last element.
2026-03-27 11:57:50 +00:00
Alx Sa
f52ae69532 plug-ins: Small code style updates to prior commit 2026-03-25 03:29:55 +00:00
Frank Teklote
0de2a56176 file-psd: scan 'ImageSourceData' for 'Layr' block before parsing layers
When loading layer metadata from TIFF 'ImageSourceData' Tag, don't assume
'Layr' is the first 8BIM block. Iterate over 8BIM/MIB8 blocks, skip non
'Layr' blocks, and rewind 4 bytes before calling read_layer_block() so it
can read the length field as expected. Limit mask_layer_len to the
selected block (including padding).
2026-03-24 23:52:50 +00:00
Alx Sa
3f17f528d1 plug-ins: Load more multichannel PSD channels
Multichannel PSD images reuse their first channel as the
main grayscale "layer". Our PSD plug-in did not take this
into account, resulting in the channels being off-by-one and
mislabeled.

This patch prevents chn_a[0].data from being freed after
it is used to load the layer, and then resets the counts so that
it is reused as the first imported channel.
2026-03-24 20:58:29 +00:00
Alx Sa
680ebede22 plug-ins: Read full channel data for PSP selection
968cf06a only loaded the rectangle area that the
selection was contained in, rather than the actual
channel data. This patch extended the code to
also read in the PSP_CHANNEL_BLOCK data, add
it to the selection GeglBuffer, and then shift it over
into the correct location.
2026-03-23 15:07:33 +00:00
Alx Sa
51f1de8844 plug-ins: Add bounds checks to JIF loading
Resolves #16076
As reported by chamal, it is possible to craft a
Jeff's Image Format image with header values that
are larger than the file size. This can lead to buffer
overflows when loading the data. This patch adds
bounding checks based on the size of the stream.
2026-03-21 17:33:39 +00:00
Alx Sa
ccb3cc3ae8 plug-ins: Add bounds check for SFW plug-in
Resolves #16075
As noted by chamal, it is possible to cause a buffer overflow
in a crafted SFW file. This patch adds bounds checks to prevent
this from occurring.
2026-03-21 15:57:01 +00:00
Alx Sa
7612363d8c plug-ins: Clean up PVR import
Resolves #16058

Per mzfr's observations, this patch adds more
safeguards to PVR import. Memory for data and pixels
is allocated and checked rather than using arrays.
Twiddled patterns are increased to 2048 and we
verify the dimensions are in that range before trying
to access. If users share an image that is larger than
that, we can increase this limit further.
2026-03-20 23:33:19 +00:00
Alx Sa
3264a67112 plug-ins: Clean up ICNS file loading
Resolves #16056
Per mzfr, we should check if the cursor exceeds the
icon total size in icns_slurp () (per OSX icons) as we
do already in icns_decompress ().

Additionally, we were not deleting the temp_image created
to load each icon, and in fact we were making an unnecessary
blank temp_image before receiving the one from the PNG &
JPEG2000 procedures. This patch fixes both problems.
2026-03-20 14:10:15 +00:00
Alx Sa
bb3bf0ae5b plug-ins: Allocate memory in PAA plug-in
Per mzfr, we should dynamically allocate memory
for the PAA plug-in pixel data rather than rely on the image
being small enough for an array to store its information.
2026-03-20 12:24:47 +00:00