Commit Graph

9331 Commits

Author SHA1 Message Date
Jacob Boerema 981979bb39 plug-ins: improve security in flame plug-in
- Use g_malloc* functions instead of malloc, so we don't continue on
failed allocations unless we test for NULL.
- Make sure we don't iterate past the known number of control points (ncps).
- Safely allocate, initialize and free points. Since points seems to be
used uninitialized, we use g_malloc0 to set everything to 0.
2022-11-08 16:57:04 -05:00
Jacob Boerema 89c83ef4c7 plug-ins: fix crash when reading corrupt flame settings file
Thanks to a report by Stefan Cornelius, we became aware that the flame
plug-in does no checking for correct input when loading a pre-saved
settings file.

I reworked the parser to read one or more values based on the type of
token, making sure we also don't read past the end of our token buffer.

All int values have a min and max value set. If any unexpected input is
encountered, we will give a warning.
2022-10-31 14:22:44 -04:00
Jacob Boerema 536c7cbc4b plug-ins: fix missing input buffer length checking in flame
The flame plug-in can read stored settings from a file. The expected
input is that a ; signifies the end of input.

However, with user input we cannot depend on this to be true, so we need
to make sure that we do not read past the end of our input buffer.
To do so, we add a length check.
2022-10-31 14:00:54 -04:00
Jacob Boerema 193596397e plug-ins: fix failure to load flame saved settings from file
We were using the plug-in name with underscores, which is incorrect.
Since nobody ever complained about this, this doesn't seem to be used
very often.

We will use the const that defines the plug-in name instead.
2022-10-31 13:57:14 -04:00
Alx Sa dca12039ea plug-ins: fix #8127 Option to load reduced TIFFs
Adds a toggle to let users load TIFF pages with FILETYPE_REDUCEDIMAGE
tags. The specs do not state that these are always thumbnails, and they 
may have other uses. We assume that if only one page with this metadata
exists then it is a thumbnail; otherwise, the toggle option is 
enabled on load.
2022-10-26 20:34:30 +00:00
Jehan 255cab6b43 plug-ins: fix a crash for closing a FILE twice.
Fixes:

> free(): double free detected in tcache 2

The file is closed also after resource_load() runs. Anyway it's better to free
resource on the same level they were created, so I remove the fclose inside the
function.
2022-10-26 00:23:18 +02:00
Alx Sa 08fedaa55a plug-ins: Add initial ICNS export support
This adds the ability to export to the most "compatible" modern ICNS
format for a particular layer.
2022-10-24 23:46:17 +00:00
Alx Sa 00232e1787 plug-ins: Add support for loading .icns files
This ports ICNS loading code from Brion Vibber's 2004 plug-in.
It extends support for ICNS files that contain PNG or JP2 format icons.
2022-10-16 02:20:51 +00:00
lloyd konneker 7708c3fec3 Issue #8744: refactor overdependence on gimpui.h
To reduce compiling due to changes in libgimpui.
2022-10-15 15:17:08 +00:00
Jehan 2080abf0a3 Issue #8734: Python-fu misses sys.stdout.flush.
Just add a no-op flush() as I think it's actually unneeded in the context of a
GtkTextView GUI. At least it doesn't cause issues with copy-pasted code or when
using external libraries using the sys.stdout.flush() interface.
2022-10-12 23:40:04 +02:00
Jehan e4e87d65ca plug-ins: fix the new unit editor (!655).
- Don't forget to run gimp_ui_init() to get GIMP's styling in plug-ins.
- Process the "key-press-event" signal so that Escape key closes the window (as
  it used to before the MR commit).
- Expand vertically the tree view, otherwise resizing the window leaves a lot of
  ugly empty space, even though the tree view is still shown incomplete with a
  scrollbar.
- Fix the Help button (which was doing nothing).
- Use full words for the "Refresh" and "Help" buttons, rather than icons. Text
  is usually prefered for UI discoverability/understandability, unless there is
  a space issue (i.e. too many icons for all of them to be words).
- Add a "OK" button too, and reorder the buttons similarly to how we usually
  order them.
- Minor coding style fixes (alignments…).
2022-10-11 22:11:16 +00:00
Niels De Graef 567d7beb11 plug-ins: Remove GtkAction from unit editor
Migrate to `GAction` and while we're at it, clean up the plug-in by
using `G_DECLARE_FINAL_TYPE()`.
2022-10-11 22:11:16 +00:00
Alx Sa ffbee51776 plug-ins: Fix odd length for .ani metadata
.ani files require metadata fields to be an even length. If the data
length is odd, an extra 0x00 is added for padding.
This patch updates the export and import code to comply with this
requirement.
2022-10-05 19:01:14 +00:00
Daniel Novomeský eac694905f plug-ins: metadata import/export for JPEG XL format
Changes require libjxl 0.7.0
2022-10-05 14:15:26 +00:00
Alx Sa 697b41dc45 plug-ins: Export PSD with paths
Ports PSD path export from file-tiff-save.c so that paths are carried
over in PSD project files as well.
2022-10-02 14:44:46 +00:00
Jehan 892b62ec36 app, libgimp, pdb, plug-ins: new GimpTextLayer class in libgimp.
Now text layers are proper types, which means that the binding API will also be
nicer (e.g. `txt_layer.set_text('hello world')` in Python).

This commit also adds the param specs allowing to create plug-in procedures with
text layer parameters.

Finally it fixes the few calls in file-pdf-save (apparently the only plug-in
using specific text layer API right now) with explicit type conversion.
2022-09-30 20:55:51 +02:00
Alx Sa 4ddb71c8ac plug-ins: Export PSD as CMYK file
Adds an option to export as CMYK (mutually exclusive with the existing
Duotone export option). Header information (mode and number of channels)
are set, and the data itself is converted via Babl.
Layer channels are also hardcoded to 4, since GIMP currently doesn't
support CMYK channels.
2022-09-29 17:27:03 +00:00
Daniel Novomeský 213aa77fc9 plug-ins: RGB AVIF compatibility with Safari on iOS 16.0
Write both ICC and NCLX boxes for RGB AVIF to make sure that
all browsers render the AVIF images in same manner.
Use heif_init/heif_deinit in libheif 1.13.0+
2022-09-19 14:01:11 +02:00
Jehan 2be2c43c9c plug-ins: new "root-layers-only" argument to file-pdf-save.
Something I wanted to implement for a long time and today I finally took
the time after I had one more annoying case where I had to merge all
groups for exporting then undo for saving!

Now this won't be needed anymore as the plug-in will allow to export
only as pages any first-level layers (groups included, so you could
gather your page compositions in root layer groups). For me, it's the
only way I use this when making/editing PDFs with GIMP, but maybe some
people would still want GIMP to crawl into groups and subgroups and
export layers individually. That's why I make it an option, defaulting
at TRUE.
2022-09-10 22:56:01 +02:00
Jehan e3ce70c5e8 plug-ins: port "file-pdf-save" to GimpProcedureDialog.
Note that I didn't port "file-pdf-save-multi" at this point, though I
did move to using GimpProcedureConfig instead of GimpValueArray
everywhere.

In any case, that's a lot of code removal and simplification already,
though some part of this plug-in is still a bit ugly.

We also get proper config storing between sessions now.

As for metadata, it unfortunately doesn't look like Exiv2 has PDF
support, so I didn't add metadata settings.
2022-09-10 22:23:03 +02:00
Hanabishi 76728fee01 Fix 'gimp-script-fu-interpreter' version
It supposed to use api version instead of app version. And seems like the symlink is excessive, it can't be run by user anyway.
2022-09-05 05:33:32 +05:00
Daniel Novomeský a61299ddb1 plug-ins: fix builing with libheif 1.13.0+ 2022-09-03 19:19:30 +00:00
Hanabishi 358ba0991f Cleanup meson symlinks
More elegant solution to avoid platform-dependent executable extension detection
2022-08-31 13:10:13 +00:00
Jehan ca230cb770 meson: fix warnings of deprecated features.
Now that we bumped our meson requirement, meson is complaining about
several features now deprecated even in the minimum required meson
version:

s/meson.source_root/meson.project_source_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.

s/meson.build_root/meson.project_build_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.build_root. use meson.project_build_root() or meson.global_build_root() instead.

Fixing using path() on xdg_email and python ExternalProgram variables:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead

s/get_pkgconfig_variable *(\([^)]*\))/get_variable(pkgconfig: \1)/ to
fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
2022-08-31 01:29:37 +02:00
Jehan 76df38399c Issue #8537: GIMP 2.99 tarball fails to configure with Meson. 2022-08-31 00:06:31 +02:00
Jacob Boerema 85134478c7 plug-ins: fix #8553 GIMP 2.99.12 Cannot Open WebP Files
GIMP tried to open webp files as ani (animated cursor) files. The reason
for this is that for ani we had set the file magic as the first 4 bytes
should be RIFF.

However, RIFF is a container format, used by many different file formats,
among which is also webp.
This means that checking for RIFF is not specific enough.

Based on the info on http://fileformats.archiveteam.org/wiki/ANI
we will check the 4 bytes starting at offset 8 for ACON, which is
apparently the identifying part for animated icons.
2022-08-30 15:33:12 -04:00
Jacob Boerema 268b063c00 plug-ins: fix #8548 export to mng not working
Due to a typo in the config property "default-delay", loading of that
option and the ones after it, failed.

Because of this, default-chunks had an invalid value, which made our
export fail. After correcting the typo the export succeeds.
2022-08-29 12:14:54 -04:00
Jehan 9ce27be989 meson: improve/fix previous commit from MR !725.
- Setting an exec_dir variable is an error. As meson docs says, if
  relative, it is installed relatively to prefix anyway: "If this is a
  relative path, it is assumed to be relative to the prefix."
  On the other hand, it would make problems if someone tried to set an
  absolute bindir.
  Moreover it is a lot clearer now. When we want to install in the
  binary directory unconditionally, then get_option('bindir') is the
  meson way, hence the way to go.
- On the other hand, the `gimp-debug-tool` is installed either in bindir
  for Windows or macOS and libexecdir for all other platforms, at least
  that's how it's set in the autotools build. So let's keep both builds
  consistent.
- Make a hopefully clearer description for enable-default-bin option.
  Let's clarify this is just about creating unversionning links pointing
  to versionned files.
- Adding an item in the "Optional Features" part of the summary listing
  during meson configure, for better discovery.

For the ".exe" extension on Windows, I wished we had an $(EXEEXT)
equivalent on meson rather than trying to set it ourselves (are there
other platforms where we must set a different extension?). But I could
not find any.
2022-08-29 15:43:25 +02:00
Hanabishi 879f7b48de Issue #8546: Meson options fixes
- Implement `enable-console-bin` meson option
- Fix wrong `enable-default-bin` behavior in docs
- Implement `enable-default-bin` meson option
2022-08-29 13:41:08 +00:00
Jacob Boerema fac6b2f3f1 plug-ins: improve formatting and comments related to resolution export ...
for PSD's
2022-08-24 14:19:46 -04:00
Jacob Boerema 24886f91b1 plug-ins: fix #8508 Print exporting to PSD seems to export as cm ...
and import as inches

When GIMP's display unit was mm, our PSD export converted the X and Y
resolution as if a conversion from mm to inch was needed.

However, PSD's resolution is always measured in pixels per inch, so a
conversion is never necessary.
Removing the conversion, resolves the issue.
2022-08-24 14:19:46 -04:00
Jacob Boerema 0ad54f863a plug-ins: fix #8467 "incorrect value RichTIFFIPTC" when loading TIFF ...
created by Adobe Lightroom 5.1

Adobe products are known to write incorrect RichTIFFIPTC tags in TIFF
images.

Since libtiff correctly detects and handles this there is no real need
for end users to be warned. So instead of a warning we will only output
a message to stderr.
2022-08-23 17:27:18 -04:00
Jacob Boerema ced071a8ee plug-ins: check for invalid resolution when loading TIFF image
This is essentially the same check as done in gimp_image_set_resolution,
but doing it here means we can load the image instead of throwing an
error.

We still need to get replacement xres and yres values, because these are
used to compute layer_offset_x_pixel and layer_offset_y_pixel.
2022-08-23 17:27:18 -04:00
Jacob Boerema 18d466df7f plug-ins: fix GIMP becoming unresponsive due to corrupt image
Image m2-d0f86ab189cbe900ec389ca6d7464713.tif from the imagetestsuite
is a fuzzed image with an invalid very high number for the channel count.

This causes GIMP to become unresponsive for a very long time. Possibly
trying to allocate memory for all channels or another cause related to
the high number of channels.

Let's go for a more "reasonable" limit of 99 channels like we also do
for Photoshop images and show a message when we find an image with more
channels.
2022-08-23 17:27:17 -04:00
Jacob Boerema 853e9d5cb4 plug-ins: fix crash when loading multi page TIFF images in non interactive mode
When loading a TIFF image using a script/plug-in in non interactive mode,
we did not initialize the list of pages, causing a crash when trying to
access it.

So, always initialize this list when non interactive.
2022-08-23 17:27:17 -04:00
Jacob Boerema ac5a6e56b7 plug-ins: fix TIFF warnings about unknown tags not filtered out anymore
Due to a change in the format string in libtiff, warnings about unknown
fields were not filtered out anymore.

Adjust our filtering of warning messages so we catch this again since
end-users don't need to worry about this and we don't need the
possible extra issues.
2022-08-23 17:27:17 -04:00
Alx Sa a3fb3ca110 plug-ins: Enable export of original Duotone data
Optionally includes the previously saved 
Duotone color space data on PSD export.
New load dialogue alerts user if duotone data was imported.
New export dialogue appears if the image is still grayscale and
the parasite exists.
If selected, the mode is set to PSD_DUOTONE in the header and
the original duotone data is written in the color space section.
2022-08-19 19:19:20 +00:00
Jehan dfb7d2543a Issue #8505: WEBP, be more informative with error.
Add the info about max dimension of WebP with WEBP_MAX_DIMENSION macro.

There is also a test about (picture->width / 4 > INT_MAX / 4), resp.
height, but this should anyway never happen as the C spec says the
smaller range for int is [-32767, 32767], which is an order bigger than
the current WEBP_MAX_DIMENSION (16383).
So we are probably fine assuming all VP8_ENC_ERROR_BAD_DIMENSION errors
will happen because of WEBP_MAX_DIMENSION.
2022-08-19 14:10:15 +02:00
Alx Sa bf53e420af Issue #1973: Add toggle to choose PNG bit depth behavior 2022-08-17 18:05:13 +00:00
Jehan 31df4c2bf1 Issue #8498: Quirky text to translate in gradients-save-as-css.py.
Just duplicate the blurb into the help string. I'll leave it to someone
else to write a dedicated, longer help text if needed.

Also fixing the call s/Gimp.init/GimpUi.init/.
2022-08-16 21:18:51 +02:00
Jacob Boerema 969b71f78d plug-ins: add support for extra layer mask
According to the specs the extra mask (which they call real user supplied
layer mask) is used "when both a user mask and a vector mask are present".

I haven't seen an example that has the extra mask, so not sure which of
the masks would appear first.

For now assuming that the extra mask will be first. The advantage of
adding this here now, is that we won't try to add a mask channel as a
normal channel.
2022-08-15 14:32:54 -04:00
Alx Sa e28c076622 plug-ins: Use image intent APIs
This updates the JPEG and TIFF CMYK exports to use the image's
simulation rendering intent, rather than always
assuming relative colorimetric
2022-08-14 01:49:56 +00:00
Alx Sa aa51b9e19e plug-ins: Add .ani file import/export 2022-08-08 18:31:45 +00:00
Alx Sa ff1766be08 plug-ins: Fix Color XHTML export and GUI crash
Fixes some syntax and makes the plug-in aware of multi-layer selection,
so that the dialog actually appears when exporting as .html.
2022-08-06 15:10:41 +00:00
lloyd konneker 36521f5db2 Fix so that ScriptFu test scripts are not localized. 2022-08-06 14:37:56 +00:00
lloyd konneker ceddb0d369 Fix #8465 2022-08-06 10:02:17 -04:00
Jacob Boerema 5fbd06629d plug-ins: fix #8411 crash when attempting to open PSD
Apparently some layers in PSD files can have extra channels which we
did not account for when computing destination offsets, causing crashes.

So let's make sure we don't include the "extra" channels when computing
the offsets by introducing base_channels. We also move the alpha channel
in the spot of the first extra channel (even though it seems, based on
the one example we have, that the extra channel might be the same as
the alpha channel).
2022-08-03 18:10:32 -04:00
lloyd konneker 031601a92a Fix 8452, crashing scripts.
Bugs in earlier enhancements re GFile, GEnum.
2022-08-03 15:51:15 -04:00
lloyd konneker 974f694cd2 ScriptFu: scripts use v3 API for multilayer gimp_image_get_selected_drawables etc.
Commit a6aba929 deleted the old functions.

Misc drive-by fixes for gtk_adjustment step not < pages

Issue #8155 discusses alternative fixes, convenience functions for compatibility in ScriptFu.
There is one compat function defined already in ScriptFu, temporarily: gimp-image-get-active-drawable
which was written so that testing clothify-v3.scm could proceed.
2022-08-03 12:48:07 +00:00
lloyd konneker 12c0c18036 ScriptFu: script-fu-register-filter for GimpImageProcedure.
Resolves #8382

Also v2 scripts infer and set sensitivity to drawables

Add two test plugins clothify-v3.scm and test-sphere-v3.scm.
Temporary, to be removed when 3.0 ships.

Some refactoring (extracting methods, moving functions to new files).

Some drive-by fixes to script-fu-arg.c revealed by using GimpProcedureDialog.
2022-08-02 07:45:35 +00:00