Commit Graph

9591 Commits

Author SHA1 Message Date
Alx Sa 7b5f241591 plug-ins: Add compatibility notice to PSD export
Users have noted that legacy layer modes have better compatibility
when exporting PSDs and reopening them in Photoshop.
This patch adds a notice with that information to the PSD export GUI.
2023-03-25 18:04:42 +00:00
Jacob Boerema 6871a0cfc4 plug-ins: more improvements in file-gif-load
- Use a pre-defined MAXDATABLOCKSIZE for all the buffers filled with
GetDataBlock that is known to be large enough.
- When reading comments ensure that it always ends with a NULL.
- Ensure that the right/bottom frame dimensions are also within range.
2023-03-25 13:37:54 -04:00
Jacob Boerema d86f6a2d6f plug-ins: improve error messages in file-gif-load
Inspired by issue #9195 I went over how we handled error messages when
loading GIF images.
- I replaced some cases with g_set_error and added an error parameter to
ReadImage.
- Introduced function read_error that uses g_set_error when image == NULL,
or else g_message.
- Enabled translations for the messages.
- Synchronized the error messages used to reduce the amount of work for
translators.
- Changed the error code returned internally in a few places, to be better
able to distinguish between encountering and end_code (-2) and possible
corruption errors (-1).
- Moved allocating dest down to not need freeing it in case of error.
- Allow to show partial results in case of errors.
2023-03-25 13:37:54 -04:00
Alx Sa 0dc98936a0 plug-ins: Prevent buffer overflow in ANI metadata
The IART and INAM metadata fields were stored in gchar arrays,
which have a limit of G_MAXSHORT indexes.
However, you can have strings larger than that in the format.
To prevent overflows, they were changed to gchar*. f_read ()'s result
is also checked, and an error is set if it returns 0.
The frame count variable is also now reset per icon block to prevent
overflow as well.
2023-03-24 18:43:13 +00:00
Alx Sa e7695c2b57 plug-ins: Port file-tga widgets to use...
...GimpDialogProcedure functions rather than gimp_prop_* directly.
2023-03-23 02:45:55 +00:00
Daniel Novomeský 2e6e5f0321 plug-ins: Port file-heif to GimpProcedureDialog 2023-03-22 20:05:27 +00:00
Alx Sa cc04035a54 plug-ins: Port file-sunras widgets to use...
...GimpDialogProcedure functions rather than gimp_prop_* directly.
2023-03-21 18:54:15 +00:00
Alx Sa 0bc38d9df2 plug-ins: Make WebP preset names translatable
Resolves #9252
2023-03-21 00:48:25 +00:00
Alx Sa c034c383c3 plug-ins: Port wavelet decompose in to...
...GimpProcedureConfig.
This ports the main dialogue to use GimpProcedureConfig.
2023-03-20 11:50:25 +00:00
Alx Sa bcce4607c5 plug-ins: Port hot-plug-in to GimpProcedureConfig
This ports the main dialogue to use GimpProcedureConfig.
2023-03-18 19:27:00 +00:00
Alx Sa bbccf2656a plug-ins: Port align-layers to GimpProcedureConfig
This ports the main dialogue to use GimpProcedureConfig.
It also adds the GUI-only options to the procedure itself, so that you
can call them via scripts.

Additionally, the layer warning was fixed and 
mnemonics were added to the
property titles.
2023-03-16 00:15:14 -04:00
Alx Sa 0ce773da76 plug-ins: Fix potential crash in PSD CMYK export
@Wormnest notified me of issues with CMYK profiles overwriting existing
ones, and potentially access a dereferenced profile.
This patch adds an additional condition check, and clears out the
profile in addition to dereferencing it.
2023-03-15 00:30:11 +00:00
Alx Sa 6d02eb4505 plug-ins: Recognize https:// in ImageMap plug-in
This adds "https://" as a valid website prefix in the ImageMap URL edit
field, in addition to http://.
It also restores the prefix change that 2.10 had when you switched URL
types. It also fixes code formatting in affected areas.
2023-03-11 21:53:12 +00:00
Anders Jonsson 949c6d43c3 plugins: Remove extra word, spacing 2023-03-04 07:13:52 +01:00
Alx Sa 1d45fc0808 plug-ins: Show unsupported PSD features in GUI
Adds a new PSDSupport struct to keep track of what unsupported features
a PSD contains.
It is then used to conditionally display a compatibility notice
via a GUI.
2023-03-03 02:34:32 +00:00
Alx Sa dbaea2ac50 core: Fix CSS palette import regex
GIMP expects CSS palettes to end with a ";" when importing. However,
GIMP exports CSS lines without ";". This means GIMP can't reopen its
own exported CSS palettes.
The ";" was removed from the regex since CSS2 does not require
the last line to end with a ";". However, CSS3 and above
require ending all lines with a ";", so it is added to the
export script.
2023-02-28 16:00:03 +00:00
Alx Sa 3df39dee91 plug-ins: Re-add toggle behavior from GAction port
When porting IFS-Compose and GFig to GAction, I originally created
all icons as GtkToolButtons. However, the toggle buttons no longer 
appeared "pressed in" when selected.

This is fixed by creating those as GtkToggleToolButtons instead.
A lingering UIManager object was removed from IFS Compose as well.
2023-02-24 03:25:08 +00:00
Alx Sa 5102355ac9 plug-ins: Port ImageMap to GAction/GMenuModel
Additionally, the ImageMap-specific icons weren't showing up due to the
filenames not matching the references strings ("imap-polygon" but
the filename was "imagemap-polygon.png"). This patch fixes that by
renaming the strings to match file name.
Partial code style fixes were made as well; a lot more are needed.
2023-02-16 04:16:11 +00:00
Jacob Boerema 5ef77e6e8e plug-ins: disable magics detection for Windows CUR and ICO files
The magics used for detection for CUR and ICO are not very unique and
interfere with the detection of certain types of TGA images.
Since these TGA images are regularly used, it seems better to only base
CUR and ICO detection on the extension, just as we do with TGA version 1
files.

See also issue #7912
2023-02-14 15:16:15 -05:00
Jacob Boerema 5f9415a641 plug-ins: fix #9067 TGA files saved by Krita can't be opened
Krita had a bug where it incorrectly saved 4 for the alpha bits instead of
8. We will allow 4 and convert that to 8 to be able to read the incorrect
TGA images.

The likelyhood of real TGA images with 4 alphabits seems pretty low, so it
should not interfere with real images that have this set. We were not
supporting that anyway.
2023-02-14 15:16:15 -05:00
Jehan 4f1d0fb53b plug-ins: get rid of various gimp_image_set_file() calls.
- This is unneeded in all import procedures. See previous commit. Note though
  that this is not because of a change in previous commit. This was already
  useless previously. The file set with this PDB function was overridden by the
  core anyway (i.e. even before the previous commits).
  In app/file/file-import.c:file_import_image(), the imported file is correctly
  set (so there is no need to set it from plug-in, which anyway libgimp's
  gimp_image_set_file() was not doing) and the XCF file is reset to NULL
  (rendering the call to gimp_image_set_file() in a GimpLoadProcedure useless).
- Similarly, this is a useless call in export procedures because
  app/file/file-save.c:file_save() overrides such call too. I could only see one
  such case for JPEG export, which was quite useless.
- Finally in other types of plug-ins, setting a non-XCF file extension was
  interfering with the save feature (similarly to commit e6e73e14c7). I only
  fixed the screenshot implementations doing such a thing.
- I left a few usages which will have to be looked at more in details later.
2023-02-13 22:54:16 +01:00
Jehan e6e73e14c7 Issue #8581: forward-porting file-name fix from `gimp-2-10` branch.
This is a port of commit 57ee6e13ab to the main dev branch.
2023-02-13 22:54:01 +01:00
Jehan 851ddad2ee plug-ins: add back the prompt when "clearing" the Python console.
This code is taken from Massimo's comment in #1786 and MR !834. It doesn't fix
a crash as this was already handled in !404, yet the missing prompt after
hitting "clear" was clearly not consistent with how one expect a clear feature
to work.

At least now, we've got a prompt back immediately after clearing.
2023-02-13 13:17:30 +01:00
Jehan c369827725 plug-ins: load PDF without filling the background to white.
Some PDF have transparency on purpose. Filling with white, without any question,
is counter-productive and prevents from working on such PDF files.

Note that we could add an option with a checkbox, leaving one to decide whether
to fill the background or not. But it feels over-engineering the issue. The PDF
is transparent, so that's what we load, and that's it. If one wants to add a
background, it's easy to add a layer at the bottom of the stack (and they can
make it any color they want, not just white), after loading the file.
2023-02-10 19:51:45 +01:00
Alx Sa 8b2262530b plug-ins: Make PDF background color fill optional
This adds a checkbox to single and multi-page PDF export to not fill
transparency with the background color 
(which currently happens automatically)
2023-02-10 18:35:14 +00:00
Jehan fb1f16d4b8 plug-ins: fix a crash in tiff_io_error().
I had a TIFF file which would crash while triggering an error, inside g_logv()
code (and according to the stacktrace, even probably inside some lower level
printf implementation code).

The reason was that I already processed the variable list with
g_strdup_vprintf() and printf didn't like this va_list being reused, then
segfaulted with some "Cannot access memory at address" error.

The alternate fix was to first copy the va_list in the first use with
va_copy()/G_VA_COPY, yet since we already processed the format data, I thought
it was useless to do this. Let's just directly use the formatted string.
2023-02-10 19:28:19 +01:00
Alx Sa 38c031e01d plug-ins: Port GFig to GAction/GMenuModel
Because of how many actions can change the sensitivity of "undo" options
most of the plug-in files had to be edited to pass GimpGfig to them.
2023-02-04 23:16:24 -05:00
Alx Sa 0628db1506 plug-ins: Fix possible crash on ifs-compose load
The build variable in GimpIfs struct is now initialized to NULL to
prevent build issues when finalized.
2023-02-02 14:27:34 -05:00
Alx Sa 78d2e8819b plug-ins: Port IFS Fractal GUI to GAction
Converts the pop-up menu and toolbar. Also replaces deprecated
gtk_arrow_new () with similar GtkImage of an arrow.
2023-02-01 20:26:53 +00:00
Alx Sa c7bef41a1e plug-ins: Add export support for PAM files
Exports the following PAM formats: 
GRAYSCALE, GRAYSCALE_ALPHA, RGB, RGB_ALPHA.
As with import, the main difference is the header and transparency.
Raw PPM export code is reused for the actual data.
2023-01-29 22:09:05 -05:00
Alx Sa af904ec55d plug-ins: Add import support for PAM files
PAM files are essentially PPM files with a different header format and
alpha/16 bit support.
Jörg Walter's 2.2 code was updated and implemented to read the revised
header format. The existing PPM loading code works with PAM files.
2023-01-29 18:01:48 +00:00
Jehan a0e95f6f35 plug-ins: G_APPLICATION_DEFAULT_FLAGS exists since GLib 2.74.
Our current minimum requirement is 2.70.0.
2023-01-29 15:02:11 +01:00
Alx Sa a4f2b06547 plug-ins: Remove GIMP_PROC_ARG_UCHAR parameters
Replaces them with GIMP_PROC_ARG_INT, which will be necessary for a
future INDEXED mode with greater than 256 colors.
2023-01-28 16:19:50 +00:00
Alx Sa 5ac2027285 plug-ins: Port colormap-remap to GAction
Modeled after the animation-play port in 691e0c02
2023-01-28 10:17:33 -05:00
Jehan c1aa1b7b3d plug-ins: fix freeing NULL object.
When the plug-in is queried initially for plug-in setup, then freed, the builder
object is not created.
2023-01-27 14:18:20 +01:00
Jehan bd94175c9a plug-ins: coding-style fixes.
While studying this code as base for the previous commit, I noticed various
coding style issues.
2023-01-27 01:48:33 +01:00
Jehan 691e0c0272 plug-in: port animation-play to GAction.
Largely inspired by commit dddb23c6. This also gave me a good overview of the
various missing features in GAction (compared to GtkAction) and how we'll have
to implement this in GIMP core. I now have a very clear path of what remains to
be done.
2023-01-27 01:48:33 +01:00
Jehan 6fb882ac5a Issue #5440: removed broken "Predator" script.
It relied on the now non-existing max-rgb plug-in, which was removed in commit
dd89f4a3d5. After some thoughts and discussions, the Predator script is fun, but
clearly not a mandatorily "needed" one here, which is why — instead of
re-integrating max-rgb —, I have decided to also remove Predator.

Both these script/plug-in are not totally dead. They were moved to the
gimp-data-extras repository and even ported to GIMP 3.0 API. They can be an
interesting use case for a fun extension to be installable through our future
extension platform. To be continued.
2023-01-24 19:22:26 +01:00
Luca Bacci e360cef004 screenshot-win32-magnification-api.h: Fix coding style 2023-01-24 14:48:44 +00:00
Luca Bacci ed1e4236ba Use GetModuleHandleW ()
Also fix an unwanted ref-count increment on a module HANDLE
2023-01-24 14:48:44 +00:00
Luca Bacci f7be0cf68e Use LoadLibraryW () 2023-01-24 14:48:44 +00:00
Luca Bacci c98ffb7e0e Replace uses of plain fopen () with GLib's g_fopen ()
On Windows fopen () is limited to the current codepage,
GLib's g_fopen () instead accepts full UTF-8 by calling
_wfopen () internally (or a similar wide-char CRT routine).
2023-01-24 14:48:44 +00:00
Jehan 2e30a92c0a Issue #8524: add or change some missing or duplicate mnemonics. 2023-01-23 23:38:51 +01:00
Alx Sa d087c1a84e plug-ins: Port Save as CSS GUI from 2.10
This plug-in has a partial GUI (a FileChooser dialog is launched).
However, you could only save the active gradient rather than choosing
any of them like the 2.10 version of this plug-in.
This patch ports the original UI so you can choose both the gradient
and file in interactive mode.
2023-01-14 21:14:45 +00:00
Alx Sa 506b324112 plug-ins: Show GUI for Palette to Gradient
Also shows GUI for Palette to Repeating Gradient function
2023-01-14 21:14:45 +00:00
Jehan c9b1ce8fa9 plug-ins: make test-dialog runnable even with no image.
It's a test plug-in which doesn't actually need an image to work, so it's
annoying that it currently requires one (making testing more cumbersome).

Also cleaning up a bit the coding style.
2023-01-14 20:17:57 +01:00
Jehan f99bdcd008 plug-ins: use generated widget for GimpPalette arg.
Also make the start checks a bit more robust to broken core code by
double-checking that the palette is valid from the start, even though getting an
invalid palette should normally not happen anymore (at least I fixed one such
case with a palette with a NULL id in my previous commit; but it looks like our
core code is not perfectly robust and we should push the code to extensive
testing).

Note that the generated widget is currently ugly (no label and terrible UX), but
this is meant to improve soon.
2023-01-14 19:27:08 +01:00
lloyd konneker e00f2d7f50 Fix plugins to use new GimpResource. 2023-01-14 17:43:26 +01:00
lloyd konneker d59a7af38c libgimp: API refactor GUI for GimpResource
Simplifies chooser widgets (e.g. GimpBrushSelect) by eliminating attributes (e.g. opacity) of chosen resource.
See #8745, but this commit fixes that by first refactoring the code.

Refactors GUI widgets (e.g. GimpBrushSelectButton and GimpBrushSelect etc.)

Refactor by "Extract class" GimpResourceSelectButton from GimpBrushSelectButton etc.
This moves common code into an inherited class (formerly called GimpSelectButton)
but the subclasses still exist.
The subclasses mainly just do drawing now.

Refactor by "Extract module" GimpResourceSelect from GimpBrushSelect etc.
Moves common code into one file, generic at runtime on type of GimpResource,
that is, the new code dispatches on type i.e. switch statements.
In the future, when core is changed some of that can be deleted.
The files gimpbrushselect.[c,h] etc. are deleted.
The module adapts the API from core to the API of callbacks to libgimp.

Note that core is running the resource chooser (select) widgets remotely.
Core is still calling back over the wire via PDB with more attributes
than necessary.
The new design gets the attributes from the resource themselves,
instead of receiving them from core callback.
The libgimp side adapts by discarding unneeded attributes.
In the future, core (running choosers for plugins) can be simplified also.

Fix gimp_prop_chooser_brush_new same as other resources.

Finish changes, and clean style.

Annotations
2023-01-14 16:38:40 +00:00
lloyd konneker d720375e97 2.99 libgimp: add GimpResource, GimpBrush, GimpPropWidgetBrush
So procedures can declare args and GimpProcedureDialog show chooser
widgets

Fix so is no error dialog on id_is_valid for resources

Palette.pdb changes and testing

Memory mgt changes

Gradient pdb

Font and Pattern tests

Test  brush, palette

Cleanup, remove generator

Rebase, edit docs, install test-dialog.py

Whitespace, and fix failed distcheck

Fix some clang-format, fix fail distcheck

Fix distcheck

Cleanup from review Jehan
2023-01-14 12:58:05 +00:00
Alx Sa 8dcc397498 plug-ins: Show Palette Sort GUI
Recreates GUI so this plug-in matches the
2.10 version.
2023-01-11 16:13:17 +00:00
Alx Sa 74b32f7c86 build: Add support for OpenMP dependency
Enables general support for OpenMP.
Currently, only the DDS plug-in utilizes it.
2023-01-09 16:41:06 +00:00
Lukas Oberhuber 15c34716cf gimphelplocale: MacOS can get http and https
(cherry picked from commit cad9feed71)
2023-01-08 23:55:22 +00:00
Alx Sa fc202818dd plug-ins: Add support for PSD clipping paths
Adds import and export support for clipping paths in PSD files.
On import, path name and flatness value are saved in parasites.
Prior settings are loaded in the GUI on export.
2022-12-30 16:33:37 +00:00
Alx Sa ec60d376a5 plug-ins: Create struct for PSD save options
Allows more save options to be added without changing
the method signatures.
2022-12-30 16:33:37 +00:00
Richard Szibele f470691e06 ScriptFu: Add byte support.
Add a new type 'byte' to be able to handle binary data while still
retaining the utf8 char and string behavior.

Internally the file and string port and character handling have
been reworked to use the new byte-centric functions.

Also adds a new test script (test9) that tests byte, char and
utf8 string handling.
2022-12-27 16:48:13 +00:00
Alx Sa d1746e464c plug-in: Initial support for CMYK/A JPEGXL export
Adds option to export JPEG XL images in CMYK/A format.
Key and Alpha data is saved in extra channels, and the
simulation profile is saved as well.
Per the specification developers, the format does not
support 'naive' CMYK conversion, so a profile is required
for export. The option will be disabled if not set.
2022-12-14 21:43:38 +00:00
Alx Sa b04f45f354 plug-in: Initial support for CMYK/A JPEGXL import
Checks if file has an extra key channel for CMYK. If so, it is combined
with the image's CMY image to create a CMYK buffer for import.
Color profile is stored as image simulation profile.
If alpha channel is present, it is now loaded as well for CMKYA images.
2022-12-14 21:43:38 +00:00
Alx Sa 01afc271ce plug-ins: Don't show invalid icons twice on export
This adds a check to make sure icon is valid when displaying
the icons in order, to prevent duplicates showing there and in the
invalid list at the bottom
2022-11-16 14:54:11 -05:00
Jehan fc050914ab app, menus, plug-ins: move some advanced paste actions into submenu.
There are so many paste options and I feel that the "Paste into Selection*"
actions are advanved enough that they can go into submenus. So I move them into
"Paste as". The other reason is that I'm going to add 2 more options!

I hesitated to rename the "Paste as" submenu but we couldn't find a good naming
(except just "Paste" but it's redundant with the default action and "Paste…" but
this usually implies a dialog, not a submenu).

Last but not least, I renamed the various paste actions to contain the word
"Paste" in it. E.g. s/New Image/Paste as New Image/. The old naming made sense
when action labels were only displayed in menus. But nowadays they can be shown
in other more independant context, such as the action search (and just
displaying "New Image" in there is very misleading).
2022-11-12 22:34:36 +01:00
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
Jehan 8feddf9cd5 plug-ins: store a CMYK profile as soft-proof profile in the right place.
Fixing !646. The call to gimp_image_set_simulation_profile() was only
happening for merged PSD mode (either explicit call or when
special-cases such as no layers).

This is the right place to store the CMYK profile in all cases.
2022-07-21 14:34:31 +02:00
Nikc 22986b6912 plug-ins: Use babl to load CMYK .PSD files
Removes gimp_color_transform_process_pixels () calls
when a CMYK profile is present, and uses babl_format_with_space ()
instead for all cases. Additionally, possible errors are now recorded
during the conversion process.
If attached, the image's CMYK profile is stored in GimpImage
afterwards.
2022-07-21 11:47:41 +00:00
Alx Sa 388a5a3b4c plug-ins: Fix crash in histogram-export
As noted by @Ofnuts, histogram-export still expected to receive
a single layer from GIMP. The parameters have been updated to
reflect receiving multiple layers/drawables, and the active layer
is selected. The parameter was left in case multi-layer support
is added in the future.
2022-07-20 12:51:03 +00:00
Jehan 2a85dd08a9 plug-ins: replace gimp_image_get_active_drawable() by newer function…
… gimp_image_get_selected_drawables().
2022-07-19 22:52:06 +02:00
Alx Sa 0f323d0279 plug-ins: Use CMYK profile stored in GimpImage
CMYK profile is now stored in GimpImage on load 
(rather than being discarded) and it's used for export rather than
the default simulation profile stored in Preferences
2022-07-19 19:26:45 +00:00
Jehan 240dc12912 Issue #8385: problem importing SVG containing huge data.
libxml has a XML_PARSE_HUGE parsing option, which can be turned on with
the RSVG_HANDLE_FLAG_UNLIMITED option in librsvg.
We cannot just set this option by default because it is a security
hazard as a maliciously malformed SVG could use this to consume too much
memory.

Instead, let's just propose the option interactively when we fail to
create a rsvg handle. Unfortunately right now we can't single out this
specific error because librsvg actually returns an unrelated (false
positive created by the huge data) error. So we just propose the option
for any kind of handle creation failure.

Furthermore, the option is only available on interactive plug-in calls
so far. In particular, the PDB API doesn't have an option allowing a
script writer to run "file-svg-load" with the huge data option.

As for the thumbnail API, it is never meant to be used interactively and
not really as a common script function, so it won't have the huge data
option either.
2022-07-19 18:29:28 +02:00
Alx Sa 984586f623 plug-ins: Store CMYK profile in image on TIFF load
Now that images can contain their simulation profile,
we can use gimp_image_set_simulation_profile() to retain
the CMYK profile when a TIFF image is loaded.
It will then be accessible in GIMP's Image menu.
2022-07-17 17:12:45 +00:00
Jehan 12c7501552 plug-ins: fix small memory leak from MR !627. 2022-07-17 19:08:37 +02:00
Nikc 714b74568b plugins: fix #356 Add export option for CMYK TIFFs
Adds support for saving 8 and 16 BIT CMYK/A TIFF files using the
image's simulation profile. If no profile or a non-CMYK profile
is set for the simulation profile, naive conversion is used instead.
2022-07-17 16:09:22 +00:00
Niels De Graef 526a28de3f plug-ins: Make sure we initalize GimpVector4
This fixes a warning about the variable being used uninitialized.
2022-07-08 09:50:25 +02:00
Jehan 32501f502b plug-ins: fix generated common plug-in files and file-wbmp localization.
The Makefile.am was apparently updated by hand in !662.

Also fixing plug-in label and doc localization, since this changed
recently and must now be localized directly on plug-in side.
2022-07-07 21:27:39 +02:00
ktoyle d1fac7bfa9 plug-ins: Create wbmp plug-in
Added plug-in that would let the Gimp program to read WBPM image files.

See #2508 and !662.
2022-07-07 19:23:35 +00:00
Jehan ca1a0e3650 plug-ins: gimp-plug-in-domain-register PDB procedure doesn't exist…
… any longer.

It's not deprecated in favor of a new name, it just doesn't exist as it
was removed in commit 81b569cb8c.
2022-07-06 16:14:03 +02:00
lloyd konneker c2b13d6f91 ScriptFu: register args with proper GParamSpecs
Resolves #8328

Except existing GimpParamSpecs seem inadequate to specify less generic widget kinds.
2022-07-05 19:17:52 +00:00
Jehan df074bfe09 plug-ins: label and documentation of plug-ins localized plug-in side.
This is the consequence of previous commit. Plug-ins' label and
documentation are now localized before sending these data to GIMP core.
In other words, we replace N_() macros with basic gettext calls.
2022-07-05 12:23:51 +02:00
lloyd konneker fadae20618 ScriptFu: Extract informal class SFArg from script-fu-script.c
Why: puts most methods for SFArg (a struct) in one place, for ease of maintenance.
Prepares to fix issue 8328.  Prepares to make SF use GimpProcedureDialog.

Mostly moving code, with no intended change in functionality,
except fixed an property.nick for an arg is now what a script author provided,
instead of generated.

All internal to libscriptfu.  No changes to the exported API or to i18n.

Lightly tested, since more substantive changes coming for issue 8328.
ScriptFu>Test>Sphere is the test case.
2022-07-04 08:28:19 +00:00
lloyd konneker ea81ae747d ScriptFu: delete unneeded #define G_LOG_DOMAIN
It clutters the compile log.
Compile flag -DG_LOG_DOMAIN="scriptfu" now does this.
2022-06-30 13:44:07 -04:00
lloyd konneker d5a83429b4 ScriptFu: Add script-fu-interpreter akin to other interpreters
Why:
1) users can install .scm scripts to plug-ins dir
2) Crashing scripts do not crash extension-script-fu

Scripts (.scm files) have a shebang and are executable
and in a same-named subdir of plugin dir.

Interpreter/scripts create PDB procs of type PLUGIN unlike extension-script-fu
which creates PDB procs of type TEMPORARY, owned by extension-script-fu.

Unlike other interpreters, the interpreter is-a plugin outright,
not by virtue of the script subclassing GimpPlugin and using GI.

More details in /plug-ins/script-fu/interpreter/README
2022-06-30 13:39:45 +00:00
Jehan 69f6f5748a plug-ins: use list() variants in bindings.
Cf. previous commit.
2022-06-27 22:30:42 +02:00
Jehan e3cc34fc6d plug-ins: add "planar-configuration" argument to "file-raw-load".
Instead of having a single "Planar RGB" format in the list, let's add
this as a generic parameter. Not only does it make the feature
symmetrical to "file-raw-save", but it also bring the ability to all
multi-channel formats. So now, we can load RGB, RGBA, GRAYA, whatever
the bit depth and the data type stored in planar configuration.
2022-06-22 22:25:18 +02:00
Jehan 559d686d07 plug-ins: break "pixel-format" arg with 2 new args: "data-type" and…
… "endianness".

The list of formats being a single list was actually interesting
UI-wise, in the case where you aren't sure of the data layout (but say
you know at least the dimensions), you can easily and quickly scroll
through the combo list (e.g. with keyboard arrows).

But when you knew your data, it was a pain to use. And as a general
rule, so many choices in a list is not the best interface.

I broke the option into 3 options, and in particular adding a
"data-type" which would tell what type of values are stored (integer,
signed or unsigned, or float) and an "endianness" to tell the byte
order. The idea behind is that these don't change the layout of
components and their size. It means that we can still do the
scrolling-randomly-through-formats trick in some fashion because we
might likely be able to detect shapes when we get at the right layout,
even though we are still set to use the wrong data type and/or the wrong
endianness.
2022-06-22 20:09:10 +02:00
Jehan 657d37a8fe plug-ins: adding RGBA and grayscale float variants + grayscale-alpha…
… loading support as raw data.

Barely any new code (and actually a bit chunk of removed code) as we are
using generic code paths now.

"file-raw-load" procedure now supports all possible formats which can be
exported by the "file-raw-save" procedure (and more).

Only thing remaining now is looking how to simplify the GUI because this
overlong Pixel format combo box is quite a pain.
2022-06-22 19:05:34 +02:00
Jehan e3c7791acc plug-ins: adding support for RGB 16 and 32-bit float raw data.
Since we can now export these, let's add import support.

I copied the function halfp2singles() from babl code (as-is, without
formatting according to our coding style on purpose as we might just
want to switch this again later on).
2022-06-21 19:07:17 +02:00
Jehan 2ffb7c12d1 plug-ins: now adding support for 16 and 32-bit RGBA raw data.
Quite easy now that we have generic code paths.
2022-06-21 01:49:09 +02:00
Jehan b953acd2b9 plug-ins: add support for RGB 16 and 32-bit raw data.
I add the Little and Big Endian variants, but not the signed one for
now, because I am unsure how common it is. We have signed grayscale
variants, but it might be specific use cases there.

While adding these new loading support, I factorize the code when
possible by making all full-bytes RGB/Grayscale code more generic and
using the same code paths. In particular, raw_load_gray_8_plus() is now
removed as raw_load_standard() will handle all full-bytes use cases
where the input and output formats have the same components in same
order.

Also RAW_RGB and RAW_RGBA are renamed to RAW_RGB_8BPP and RAW_RGBA_8BPP
respectively.
2022-06-21 01:37:39 +02:00
Jehan 55790d7bb2 plug-ins: support more cases of grayscale raw data.
- rename raw_load_gray16() into raw_load_gray_8_plus() and make it
  handle all full-byte grayscale data. Move 8-bit grayscale data to use
  this function as well.
- As a consequence of the previous point, we can also easily support
  32-bit grayscale images (little/big endian, signed/unsigned).
- Make preview image code more generic as well.

Also I improve a bit code from previous commit in raw_load_rgb565(). The
allocated and read code didn't need to be the size of the full line
stride. Just the tile rectangle width was enough.
2022-06-20 21:53:19 +02:00
Jehan ba582253df plug-ins: raw_load_rgb565() ported to GEGL iterators.
Rather than allocating 2 huge data buffers of the whole image size (one
in RGB565 and one in RGB-u8), just iterate through the file only
creating one single small temporary data buffer for single input line in
tiles returned by the iterator. This will be much better,
memory-efficiency wise.
2022-06-20 14:39:09 +02:00
Jehan e9876a8b7f plug-ins: rename "color-representation" to "pixel-format".
This initial name was really ugly. I think talking of pixel format or
color format is much more common, at least around GIMP codebase.
2022-06-20 14:39:09 +02:00
lloyd konneker 07ceb5a086 ScriptFu: extract PDB proc script-fu-server from plugin script-fu
Create new plugin file script-fu-server-plugin.c
with code extracted from script-fu.c, which is an omnibus plugin
implementing PDB proc extension-script-fu and other PDB procs.

Why:

1. extension-script-fu is smaller and doesn't doesn't link to socket libraries.
   (GIMP always starts extension-script-fu and it stays running.)

2. packagers/admins can omit script-fu-server executable from an installation,
   if they think letting users serve net ports is not secure.

3. crashing script-fu-server does not crash extension-script-fu,
   which requires restart of GIMP

The changes are mostly a simple refactor, extracting code.
No functional change apparent to users.
Low risk of introduced bugs.
Extremely few users use script-fu-server anyway.
Added some logging.
While at it, use G_DECLARE_FINAL_TYPE
2022-06-19 19:18:39 +00:00
Jehan 4e3edb5121 plug-ins: fix some warnings.
Should have paid more attention. I left 2 warnings in the file:

> plug-ins/common/file-raw-data.c:1949:22: warning: variable ‘procedure’ set but not used [-Wunused-but-set-variable]

> plug-ins/common/file-raw-data.c:1970:48: warning: ‘bpp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
2022-06-19 20:26:45 +02:00
Jehan a554349e52 plug-ins: dynamically lower width/height with impossible values.
Even though the scale entries have maximum values based on the file
size, it's still too big for many formats (multi-byte ones) when
thinking in terms of pixels.

Moreover if growing the offset or any dimension, comes a point where the
other dimension needs to shrink. So let's compute max pixels and update
other values depending on this.

Note that it's still quite easy to crash the dialog with big dimensions,
triggering X Window System errors about unsufficient resources in
GimpPreviewArea code. This will have to be handled accordingly.
2022-06-19 01:17:39 +02:00
Jehan 5b22cef644 plug-ins: do not unref anymore int stores given to…
… gimp_procedure_dialog_get_int_combo().

See previous commit.
2022-06-17 17:59:54 +02:00
Jehan 38f0535847 plug-ins: port file-raw load procedure to GimpProcedureDialog API.
- Add various relevant arguments to "file-raw-load" PDB call: width,
  height, offset, color-representation, palette-offset palette-type and
  palette-file. This will make the procedure actually usable for
  scripts.
- Use procedure config so that we get configuration storage as all other
  ported plug-ins.
- Update the source to use passed-in config object with these new
  arguments rather than global variables.
- The load dialog now uses the GimpProcedureDialog which means a lot
  simpler and nicer to read/debug code (we don't need all the code for
  argument syncing).

- "file-hgt-load" code now uses a HgtSampleSpacing enum, which makes
  code nicer to read, with semantic constant names.
- Do not show the dialog anymore for HGT load when sample spacing
  detection worked correctly. Indeed, offset and profile selection were
  making sense for random raw data, not for HGT file which we know how
  to process.
- Improve detection logic for sample spacing: in interactive mode, we
  always try and detect and show the dialog when spacing detection
  failed; in non-interactive mode, we only detect when "sample-spacing"
  argument is explicitly set to HGT_SRTM_AUTO_DETECT.

- The argument "image-type" of "file-raw-save" PDB call is renamed to
  "planar-configuration" to sync with the natural language label. Also
  it now uses a separate RawPlanarConfiguration enum rather than using
  specific values of the RawType enum (which made that the possible
  values were 0 or 6, which was a weird API in GIMP 2.10).

The plug-in still cannot load all possibly exportable formats (after
commit 01e0675f67) and I'm still wondering about whether
"color-representation" argument in the load call should not be broken
down into several arguments (it has both advantages and disadvantages).
This will be handled in further commits. For this first step, I needed
to clean the load code.
2022-06-17 17:18:12 +02:00
Daniel Novomeský 7452c4bc6e plug-ins: ensure that metadata correspond to real image size 2022-06-16 16:46:31 +02:00
Jehan 73868afe15 plug-ins: fix script-fu build in meson.
Fixes:

> plug-ins/script-fu/meson.build:44:0: ERROR: Bad source of type 'SharedLibrary' in target 'script-fu'.
2022-06-15 21:18:37 +02:00
Jehan 319ccb1d81 Issue #7091: Exporting 16-bit precision images to raw *.data.
Another part for the fix: now that it is possible to export any of the
color model and bit depth supported by GIMP core, we should make the
dialog settings clearer. In particular, don't just always show "RGB"
structure sample.

If an alpha channel is present, also show RGBA samples, and if it's a
grayscale image, show "Y" or "YA" samples. Actually when it's a
non-alpha grayscale, just make the option insensitive as planar and
contiguous will be the same thing.
2022-06-15 21:18:37 +02:00
Jehan 01e0675f67 Issue #7091: Exporting 16-bit precision images to raw *.data.
Just use the image format as-is. The only problem now is that we don't
support all formats for loading in file-raw yet.
2022-06-15 21:18:37 +02:00
Jehan 97d0337f92 plug-ins: partly port file-raw-data to newer dialog generation API.
Only port the export dialog so far. We'll see later for the load dialog.
This uses the new gimp_procedure_dialog_get_int_radio().

While doing this, I also better name "Image type" to "Planar
configuration", which is how DICOM standard and TIFF call the same
option. Within this settings, "Standard" is renamed "Contiguous" as a
more correct naming than a very vague "standard".

Similarly I rename "Palette type" to "Palette's configuration".

This is a first step to make RAW export clearer in the path of fixing
issue #7091.
2022-06-15 21:18:37 +02:00
lloyd konneker 5cc3becf16 ScriptFu: build shared libgimp-scriptfu-3.0.so separate from executable script-fu
Changes are mostly to the dir structures and build system for ScriptFu.
Some changes to the outer plugin source to call the library.

Why: so that other executables (future gimp-scheme-interpreter,
or a future separated script-fu-server) can exist in separate directories,
and share the library in memory (when built shared.)

Whether the library is built shared and installed on its own
(versus static and not installed)
is a compile time option (both automake LibTool and meson abstract it away)
The default is shared and installed, say as libgimp-scriptfu-3.0.so.

Installed alongside other shared libraries (e.g. wherever libgimp is installed)
to simplify packaging.

A preliminary refactoring which helps enable MR gimp!647
2022-06-11 08:58:30 -04:00
Jehan 1c5491b69e plug-ins: override set_i18n() for file-glob.
I forgot this one, which simply can have its localization disabled. As I
understand, it's mostly for script writer so was never localized. Maybe
it could still be interesting to localize the procedure name and docs,
but for now let's leave it how it always was.
2022-06-08 20:59:09 +02:00
Jacob Boerema 2e4b9bcba7 plug-ins: fix not converting 8 bps grayscale MINISWHITE TIFF
We only set tiff_mode for images with bps < 8, but we also use it for
8 bps grayscale images to detect if MINISWHITE needs to be converted.

So, let's always set tiff_mode for PALETTE, MINISBLACK and MINISWHITE.
2022-06-08 14:34:03 -04:00
Jacob Boerema 94de89febf plug-ins: fix #1790 Artifacts when opening tif images ...
generated by matlabs blocproc function

Based on the suggested solution by Massimo, we should not compute the
remaining pixels per line but only at the end of the whole block, be it
tile or scanline.

I have not been able to find bw or palette examples that use load_separate
instead of load_contiguous, so that case is not tested. But, it also
doesn't make much sense to have planar when you have just one plane.
2022-06-08 13:23:16 -04:00
Jacob Boerema 3e6237030c plug-ins: fix #6766 TIFF B/W image opened as grayscale and not index map
In a previous commit 1, 2 and 4-bit B/W images were converted to grayscale.
However, it seems that there is more of a use case for these images to be
handled as indexed, even though technically they can be considered
grayscale.
Also, the only way to export these images again in the same format, is to
have them as indexed.

So, let's change this back, so that these kind of images will be opened
as indexed. With a reminder that in the future we could add an option
at loading time where the user can choose whether they prefer it to be
loaded as indexed or grayscale.

We use grayscale mappings, that we moved in the previous commit, to
add a palette to these grayscale images.
2022-06-08 13:23:16 -04:00
Jacob Boerema 11ef2e4432 plug-ins: move static variables for grayscale mapping to the top
In preparation of using some of them earlier, we move the variables
used for grayscale mapping of 1, 2 and 4-bit per pixel images to the
top of file-tiff-load.
2022-06-08 13:23:16 -04:00
Nikc 93b9876405 plug-ins: fix #1106 Add CMYK/A loading for TIFFs
Adds support for loading 8 and 16 bit CMYK/A TIFF files with
attached color profiles.
2022-06-05 17:49:54 -04:00
Jehan b8d1046aa9 plug-ins: fix file-jp2-load build.
I guess I missed this one as I was not building it locally.
Fixes:

> In file included from ../plug-ins/common/file-jp2-load.c:86:
> ../plug-ins/common/file-jp2-load.c: In function ‘jp2_class_init’:
> ../libgimp/stdplugins-intl.h:42:22: error: ‘set_i18n’ undeclared (first use in this function)
2022-06-05 02:32:38 +02:00
Jehan 18c37f7084 plug-ins, libgimp: override set_i18n() for all our core plug-ins.
Hence avoiding the stderr messages. These are going to be localized with
centrally installed catalogs "gimp*-std-plugins", "gimp*-script-fu" and
"gimp*-python".

We now handle core plug-in localizations differently and in particular,
with kind of a reverse logic:

- We don't consider "gimp*-std-plugins" to be the default catalog
  anymore. It made sense in the old world where we would consider the
  core plug-ins to be the most important and numerous ones. But we want
  to push a world where people are even more encouraged to develop their
  own plug-ins. These won't use the standard catalog anymore (because
  there are nearly no reasons that the strings are the same, it's only a
  confusing logic). So let's explicitly set the standard catalogs with
  DEFINE_STD_SET_I18N macro (which maps to a different catalog for
  script-fu plug-ins).
- Doing something similar for Python plug-ins which have again their own
  catalog.
- Getting rid of the INIT_I18N macro since now all the locale domain
  binding is done automatically by libgimp when using the set_i18n()
  method infrastructure.
2022-06-05 01:57:02 +02:00
Jehan 208d415a1a plug-ins: properly localize core Python plug-ins.
- Set the "gimp30-python" Gettext domain and bind it to the proper
  locale directory as installed by GIMP.
- Localize various strings with gettext.
- Remove calls to self.set_translation_domain() in
  do_query_procedures(). This is technically wrong right now but I am
  going to get rid of the menu item localization for plug-ins done by
  the core.
2022-06-04 14:52:14 +02:00
Jacob Boerema b6d5707816 plug-ins: fix possible overflow in computation
FLI/FLC width x height is 16-bit unsigned, so theoretically it could
overflow a 32-bit signed int.
We fix this by making it a 64-bit signed int.
2022-06-03 12:52:17 -04:00
Jacob Boerema 862c54ec94 plug-ins: fix resource leak
In case of a certain error condition we forgot to free our resources.
This would only happen if we had a corrupt FLI/FLC image.
2022-06-03 12:48:19 -04:00
Jacob Boerema 6a8299d989 plug-ins: simplify adding tags to store in metadata-viewer
We were using parameter iter in metadata_dialog_add_tag and
metadata_dialog_add_translated_tag.

However, iter is only ever set inside metadata_dialog_add_tag by calling
gtk_list_store_append. So, there is no need to pass this parameter around.

For this reason, let's remove parameter iter from the above two functions
and replace with a local variable.
2022-06-02 21:45:27 -04:00
Kevin Cozens 38e4d5490b Eliminated possible compiler warning. From r130 of TinyScheme in SourceForge. 2022-05-31 19:31:05 -04:00
Kevin Cozens 0af582f309 Allow only one exponent in numbers. From r129 of TinyScheme in SourceForge. 2022-05-31 19:31:05 -04:00
Kevin Cozens 4772f57827 Use trunc() from C99. From revision 128 of TinyScheme in SourceForge. 2022-05-31 19:31:05 -04:00
Kevin Cozens afca1926f1 Use x and y at top of opexe_2 to save repeating some car() and cadr() calls.
From SVN version 127 of offical version of TinyScheme.
2022-05-31 19:31:05 -04:00
Kevin Cozens 511ada844e Syncing TinyScheme with the 1.42 version in the SourceForge repository.
This picks up changes applied in SVN revisions 120 and 124 which
both clean up compiler warnings.
2022-05-31 19:31:05 -04:00
Kevin Cozens 73e5ef394f R5RS compliance fix. Return proper type for remainder and modulo.
Also fixed quotient to only take two arguments. Applied minor
optimization in execution of quotient, remainder, and modulo.
From revision 122 of the TinyScheme repository in SourceForge.
2022-05-31 19:31:05 -04:00
Kevin Cozens 53b7a0935e String-ref, string-set!, vector-ref, and vector-set! index must be integer.
R5RS compliance fix. From bug #42 reported in the SourgeForge bug tracker.
2022-05-31 19:31:04 -04:00
Kevin Cozens e0b6a9cab2 Syncing TinyScheme with the 1.42 version in the SourceForge repository.
This picks up changes applied in SVN revisions 100, 103, 106, and 113.
The TinyScheme version number has been updated.
2022-05-31 19:31:04 -04:00
lloyd konneker a3b242b2c5 ScriptFu: Break mutual includes between script-fu-server and scheme-wrapper
Instead, make outer script-fu-server register callbacks with inner scheme-wrapper.

Why? the inner scheme-wrapper should not know about the outer script-fu-server.
The change will allow a future, smaller scriptfu shared library,
that does not contain networking code.
We want a scriptfu library shared by separate script-fu-server,
future gimp-scheme-interpreter (!647), and script-fu executables.

This change does not alter observable functioning of the script-fu-server.
Except that I also changing the logging by script-fu-server,
so that I could test the changes.
I put a test plan in the comments.
2022-05-29 08:48:17 -04:00
Jacob Boerema e268d38fb1 plug-ins: remove unnecessary Windows specific code in tinyscheme
Removal of the snprintf define was also part of the UCRT Windows patch
in MINGW. Although it builds fine without this change, there is no need
anymore to redefine snprintf. In addition, I seem to remember that
_snprintf had a shortcoming.

So let's remove the Windows specific code, since it works fine without it.
2022-05-17 17:23:06 -04:00
Jacob Boerema ef817dc452 plug-ins: fix Windows build in UCRT environment
The UCRT environment is a successor to the MINGW environment on Windows
with a more modern C runtime library.
Building under UCRT we get this error:
../../gimp/plug-ins/file-raw/file-darktable.c:420:7: error:
 function '__p__environ' is initialized like a variable"

To fix this we use the relevant part of patch 6 from:
https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-gimp
2022-05-17 17:23:06 -04:00
Nikc 42cbaff322 Issue #4492: Add "Flip image", save visible layers feature to DDS 2022-05-16 18:56:16 +00:00
Jacob Boerema 3644b9010a plug-ins: fix #1351 Raw Data Import Creates Blank/White Image...
when Offset and Dimensions Bigger than File Size.

If we didn't read the exact amount of bytes, the whole image would be
filled with white.

Let's change this, so we read as much bytes as we can, and fill the rest
with white.
2022-05-16 14:00:17 -04:00
Jacob Boerema 980e604880 plug-ins: fix reading of FLI files where the filesize is off-by-on 2022-05-16 11:22:14 -04:00
Jacob Boerema ca8eee1755 plug-ins: improve error handling of FLI export
Added GError parameters to all static file write functions, check for
failed writing and return an error if that is the case.

Additionally, at end of file make sure the last dummy byte is written to
make chunks an even size.
2022-05-16 11:22:14 -04:00
Nikc fccc13b782 Issue #4: Enable loading transparent .EPS files 2022-05-16 14:31:50 +00:00
Jehan 8d61c4211f plug-ins: replace gimp_checks_get_shades() by gimp_checks_get_colors().
The animation playback now follows user preferences for checkboard
rendering.
Also fixing a small bug there, as the GIMP_CHECK_SIZE_SMALL_CHECKS was
the wrong type (it needed a check type, not a check size parameter).
2022-05-14 17:43:39 +02:00
Jehan 1787492710 plug-ins: tile-small should respect the user-set transparency rendering.
Right now, the various Gimp*Preview classes have code initializing their
transparency colors correctly. Some plug-ins, such as tile-small are
directly using a GimpPreviewArea and need to be initialized directly by
the plug-in.

I also realized that several plug-ins (such as gradient-flare) are
rendering their own alpha checkboard, despite using a GimpPreviewArea
(maybe was it code from a time before this class had support for alpha
checkboard rendering?). So this would have to be improved later.
2022-05-14 16:31:58 +02:00
Jacob Boerema 7a2dd01a3a plug-ins: fix wrong return types forgotten in previous commit 2022-05-11 18:37:55 -04:00
Jacob Boerema dd7c067715 plug-ins: further improvements in error handling in FLI/FLC loading
- Changed all static read functions to have a GError parameter, use a
  parameter for the value read, and return a gboolean that will be FALSE
  when reading from file failed.
- Check the return values of all read functions and set GError when
  needed.
- Added more error checking, like comparing real filesize with what the
  header tells us, check for valid speed and number of frames.
- Added some gdebug statements for easier debugging.
- Don't assume that all FLI/FLC writers followed the specs and wrote an
  even number of bytes per chunk.
- Skip "frames" that do not have the FRAME type (in most cases this is
  a PREFIX chunk).
2022-05-11 16:28:58 -04:00
Jacob Boerema 317e0ca21e plug-ins: update public FLI functions to add a GError and return gboolean
Improvements to the FLI loading and exporting plug-in:
- I added a GError parameter to all public read/write functions.
- All public functions now return a gboolean result to show if they
succeeded or failed. Before most functions were void. For the non void
returns (the two fli_write_color functions) I added a gboolean
parameter.
- Do cleanup if we fail to read a frame. If at least one frame was read
successfully, we will keep the incomplete image/animation.
- Change name of layer to include the delay in ms.
2022-05-11 16:28:58 -04:00
Jehan 45a99ae270 plug-ins: make the BigTIFF warning translatable. 2022-05-09 19:56:46 +02:00
lloyd konneker 5e9c92c5de plug-ins: fix script-fu-font-map error receiving GStrv
Why: MR !389 changed the signature of PDB procedures to return GStrv instead of (int, GimpStringArray)
This changes handling of results from a call to such a changed signature, in a Scheme script.

The symptom was a cryptic TinyScheme "Error: car: argument 1 must be : pair"

Most changed procedures are named like "-list".
I did a cursory grep to look for other instances.

Updated porting guide doc.
2022-05-07 19:14:42 +00:00
Jacob Boerema b072a42bb7 plug-ins: silence warnings about missing mnemonics in file-fli-save
Also remove the unneeded setting of labeled text.
2022-05-07 14:19:30 -04:00
Jacob Boerema d143a2d55f plug-ins: fix #5315 Opening FLI with one frame fails
Fix as suggested by Lloyd Konneker.
Even though a one frame animation isn't really an animation, there is no
reason why we can't or shouldn't load it.
2022-05-07 14:19:30 -04:00
Jacob Boerema 5ecf46ccef plug-ins: cleanup of fli plug-in, use glib types and change ulong to guint32
The unsigned long type in this plug-in is always used for reading/writing
32-bit unsigned integers, so let's change it to guin32 to not get
confused.
Changed unsigned short to gushort, unsigned char to guchar.
2022-05-07 14:19:30 -04:00
lloyd konneker 1846f91305 Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.

This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.

This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.

The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.

As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 20:44:33 +00:00
lloyd konneker 5e1dd03c52 plug-ins: fix PDB proc script-fu-selection-to-pattern
Why: this commit fixes PATTERN using code that commit 708f3228  fixed for BRUSH.

Importance:
There doesn't seem to be any issues it resolves.
No code in the GIMP repo seems to call this procedure.
I don't know whether third party plug-ins rely on this procedure.
Anyway, fix it so a brute force test works.
2022-05-05 13:10:48 +00:00
lloyd konneker a1f0757ee7 Fix #8091 ScriptFu scripts use v3 API for drawables in calls to file procedures
This change is part of multilayer select feature of v3.

Only fixes ScriptFu plugins, not Python or C.
Only fixes calls to file load/save procedures and other plugins already multilayer capable.
Any future PDB procedures changed to have multilayer signature will require changes to all callers.

The new code is verbose: "drawable" => "1 (vector drawable)"
Issue 5919 proposes a change to the PDB that would make this less verbose:
"drawable" => (vector drawable)" (without the number of drawables)

Tested that changed procedures will interpret without syntax errors, on one path.
Did not test each changed procedure for functional correctness.
2022-05-03 16:17:44 +00:00
Jacob Boerema eb2d99be3d plug-ins: support loading DDS with two 16-bit channels.
We have some examples of DDS images that have two 16-bit channels that
we could not load.

This commit adds checks to see if we need 16-bit channels, and conversion
of the input to a correct 16-bit red, green, blue or alpha channel.
2022-05-02 17:24:56 -04:00
Jacob Boerema 045c3d3208 plug-ins: fix crash in DDS loader when one of the masks is zero. 2022-05-02 17:24:56 -04:00
Jacob Boerema d914580336 plug-ins: support loading more 16-bit, single channel DDS images
Single channel 16-bit DDS images can use other channels than red, so
let's support all masks with a value of 0xffff.
2022-05-02 17:24:56 -04:00
Jacob Boerema 868a6f1d4a plug-ins: compute DDS variables earlier and support 16-bit masks
To be able to use certain variables we use in our DDS loader earlier,
we move the computation of these variables up.
We also add checks to see if the mask needs to be for 8 or 16-bit, since
there are DDS images with 16 bits per sample.
2022-05-02 17:24:56 -04:00
lloyd konneker 513d331ae2 Fix #6842 by deleting second of two strings passed for filenames, in scripts 2022-04-30 11:53:02 +00:00
Jacob Boerema 0e462440cc plug-ins: fix #3964 Incorrect position when printing
This was a long standing issue where the image was not printed at the
position as selected in our print preview.

The problem being that we do not take into account the dpi of the print
context we are printing to, but instead always assumed 72.
This is the fix that was suggested by Massimo.
2022-04-29 12:59:59 -04:00
Jehan b904d67af7 plug-ins: localize file-png-save parameters.
Small text tweaks done too:
- Some question marks removed to be more consistent in the tooltip
  style.
- The "save-transparent" only applies to *completely* transparent pixels
  (not partially transparent).
2022-04-26 23:35:41 +02:00
Jehan b5fbe84b09 plug-ins: localize file-webp parameters' titles/docs.
Also changing "RGB->YUV" by using a real Unicode rightward arrow encoded
in UTF-8 since GTK functions (such as `gtk_widget_set_tooltip_text()`)
explicitly uses UTF-8 encoded strings as argument. This renders much
more nicely than an ASCII-made arrow.
2022-04-26 19:09:04 +02:00
Jehan ada64be8cd plug-ins: new "use-sharp-yuv" param only relevant when non "lossless".
Cf. question to libwebp devs and also grepping the code directly:
https://bugs.chromium.org/p/webp/issues/detail?id=567#c6
2022-04-26 17:18:40 +02:00
Nikc df402522ef Plug-ins: Add "Use Sharp YUV" for webp export 2022-04-26 12:46:33 +00:00
Jacob Boerema cd4401fee4 plug-ins: fix integer overflow in print-draw-page.c
As mentioned by Massimo in issue #6618, part of the problem there is an
integer overflow when using large size images when computing the offset
in pixels.

Let's fix our part of the problem by casting to guint64.
Besides that, also use casts to correctly compute progress for very
large images.
2022-04-25 14:21:18 -04:00
Jehan f200594d1c plug-ins: support CMYK import/export for JPEG.
We already had import support through littleCMS. We now use fully
babl/GEGL which makes our code more straightforward and identical,
whichever the input format.

The export support is totally new. It comes with a checkbox to propose
selecting CMYK export and a label displaying the CMYK profile which will
be used.

Now this whole implementation has a few drawbacks so far, but it will be
a good first sample for future CMYK-related improvements to come:

* The export profile I am using is what we call the "simulation
  profile" from the GimpColorConfig. This corresponds to the default
  "Soft-proofing" profile as set in Preferences. In particular, this is
  not the actual soft-proofing profile for this image which might have
  been changed through the View menu because this information is
  currently and unfortunately unavailable to plug-ins. It is not the
  "Preferred CMYK Profile" either, as set in Preferences.
  TODOS:
  - We really need to straighten the soft-proof profile core concept by
    storing it in the image and making it visible to plug-in.
  - Another interesting improvement could be to create a
    GimpColorProfile procedure argument which would be mapped to a color
    profile chooser widget, allowing people to choose profiles in
    plug-ins. For an export plug-in in particular, it could allow to
    select a profile different from the soft-proof one at export time.
* When we export, if no profile is choosen, babl will use a naive
  profile. It would be nice to store this naive profile into the JPEG if
  the "Save color profile" option is checked (same as we store a generic
  sRGB profile when no RGB profile is set).
* When we import, we just import the image as sRGB. Since CMYK gamuts
  are not necessarily within sRGB (some part of the spectrum is usually
  well within, but other well outside), other than the basic conversion
  accuracy issue, we may lose colors. It would be much nicer to be able
  to select an output RGB profile. Optionally if we could create a RGB
  color space which is made to contain the whole input CMYK profile
  color space, without explicit choice step, it would be nice too.
* I am using babl's "cmyk" format, not the expected "CMYK" format.
  "cmyk" is meant to be an inverted CMYK where 0.0 is full ink coverage
  and 1.0 none. Nevertheless when loading the resulting JPEG in other
  software (editors or viewers alike), the normal CMYK would always
  display inverted colors and the inverted cmyk would look fine.
  Finally I found a docs from libjpeg-turbo library, explaining that
  Photoshop was wrongly inverting CMYK color data while it should not.
  This text dates back from 1994, looking at the commit date which
  introduced this paragraph. In the 28 years since then, could this
  color inversion have become the de-facto standard for JPEG because one
  of the main editor would just output all its JPEG files this way?
  See: dfc63d42ee/libjpeg.txt (L1425-L1438)
2022-04-17 23:14:20 +02:00
Jehan c1d2f35b73 app, plug-ins: redirect plug-in-script-fu-eval to text console in…
… plug-in code.

In particular, we should not hardcode this in core code anymore. The
behavior is otherwise exactly the same, except that we made the core
code generic as it should be.
2022-04-17 14:25:44 +02:00
Jehan de1d71bb3f app, libgimp, pdb, plug-ins: batch CLI options now interpreter aware.
The CLI options now know which procedures are batch procedures or not.
First it means that it won't just randomly try any procedure name one
may pass and will properly output an error if you pass a non-existing
interpreter procedure.

Secondly, there is no default interpreter anymore (unless only one
interpreter exists). If you don't set an interpreter procedure with
--batch-interpreter or if you pass a wrong one, it will output the list
of available batch procedure, thus helping you understanding how to use
the --batch option.
2022-04-16 23:28:05 +02:00
Jehan 0555a6815e plug-ins: port plug-in-script-fu-eval to GimpBatchProcedure. 2022-04-16 18:50:29 +02:00
Jehan 752cbd1377 plug-ins: port python-fu-eval to GimpBatchProcedure. 2022-04-16 18:50:29 +02:00
Jehan 1c730ce141 meson, plug-ins: further fix the no-pkg-config test for libmng.
As suggested by jeremyd2019 and Biswa96 of MSYS2 project, defining the
MNG_USE_DLL macro would trigger libmng header code to fix the calling
convention. This way, even the old detection code now works with Windows
32-bit.

The reason why we still stick to this old detection code is that the
pkg-config is likely not everywhere (e.g. in Debian package libmng-dev,
there is no `.pc` file). So the pkg-config test is good but we still
definitely need to keep our fallback more old-school test for this
dependency.

See this comment in particular:
https://github.com/msys2/MINGW-packages/issues/11136#issuecomment-1084627263

Note: I am unsure yet how to apply the same trick on the autotools test
because AC_CHECK_LIB() would allow us to tweak the cflags to define a
macro, but we also need to include libmng.h header, otherwise the
calling convention tweak is not run. It doesn't look to be feasible with
the autoconf macro, or at least I haven't found how yet.
2022-04-01 18:11:55 +02:00
Nikc 14fd817b24 Fixes issues with fade-out breaking the script
(cherry picked from commit 09eccc9989)
2022-03-30 20:53:06 +02:00
Axel Viala 0098422425 Fix warn -Warray-parameter gflare_read_gradient_name gflare_write_gradient_name 2022-03-29 16:33:58 +00:00
Axel Viala f0c8adc505 Fix warning in jigsaw.c -Warray-parameter
warning: argument 6 of type ‘gint[2]’ {aka ‘int[2]’} with mismatched bound [-Warray-parameter=]
 1629 |                          gint      py[2],
      |                          ~~~~~~~~~~^~~~~
2022-03-29 16:33:58 +00:00
lloyd konneker dd828f94cc Fix #6839 by deleting call to gimp-context-set-transform-recursion 2022-03-25 18:05:26 +00:00
Jehan 784f166815 plug-ins: clean up the patch !519 as per review.
Some coding style fixes, also one warning fix, and a lot of shuffling
around to reorganize the code. Basically removing the prototype listing
at the file start is a big error. This file is huge and without a
minimum of organization, it's a huge mess to understand what's what.

Basically a class file must always start by the class_init(), then the
init(), then the various object methods (constructed() or finalize() if
any, etc.), and possibly other parent classes' implementations. These
are the entry points, it's normal to start here (not from leaf
functions!).
Then we get the public functions which are other entry points (calls
from other parts of the code). And only after, private functions such as
signal or action callbacks, and utilities at the very end.

This requires a well organized prototype listing, which works as a menu,
and prevents the implementation order to depend on call order (this gets
us completely random order and imply usually that top functions are the
less important ones, such as utilities, just how it was before this
commit).

Anyway I'm not sure why I spent time on this because we deprecated this
plug-in, but if we still want to push nice updates (like MR !519), we
should at least do it well and clean. Also it's a good first example for
plug-in rewrite in modern no-GtkAction code.
2022-03-25 14:55:25 +01:00
Niels De Graef dddb23c6e5 help-browser: Rewrite without GtkAction
The initial attempt of this commit was to remove the `GtkAction` usage,
but grew a bit wider than that. The following happened:

* The dialog became a proper GObject, rather than being a big chunk of
  static variables that were hopefully initialized before you used them.
* The dialog now uses `GAction`s to implement actions, and converted
  some signal handlers to actions as well.
* The plug-in run procedure now uses `GtkApplication`. This is one hand
  necessary to be able to set accelerators for actions, but on the other
  hand is more future-proof, as GTK4 removes `gtk_main()`
2022-03-25 11:49:39 +00:00
Jehan 42a5326545 Issue #6886: fix loading PNG images with linear profile or gAMA chunk.
Our main issue is that GIMP does not accept indexed images with linear
backend. MR !460 was an attempt to fix this, but some weird pixel data
conversions were happening so the result was very wrong.

We could try to investigate this and add support for linear RGB palette
colors, but it's unclear how necessary it is (i.e. is there any indexed
image format for which we'd want this? PNG is not one such format as
will be explained below), especially that palette are u8 only right now
and linear RGB u8 is not the best idea anyway.

In cases reported in #6886 though, our code would say the input is
linear mostly because it had a 1.0 gAMA chunk (or we could have a case
with a linear profile too). But then we don't need to set such data as
being in linear RGB. Just set it as non-linear RGB (R'G'B') with the
associated linear profile and that's it.
Setting a linear backend to an imported PNG would only be useful if PNG
had some flag explicitly asking for this, bypassing any profile TRC. But
as far as I can see in its spec, there is no such thing.
2022-03-24 22:31:17 +01:00
Jehan 9926c90055 plug-ins: always set an error domain.
The code can be 0, but not the domain. Let's use G_FILE_ERROR as all
these errors are about problematic file contents.

Fixing these warnings:

> g_error_new_valist: runtime check failed: (domain != 0)
2022-03-24 14:24:51 +01:00
sonia habtiche 3dfb3647d4 Initialize variables that are not initialized to silence warnings.
Committer's (Jehan) note: with clang version 12.0.0 on macOS Big Sur,
it seems that warnings such as the following are outputted:

> plug-ins/file-psd/psd-load.c:447:32: warning: variable 'block_len' is uninitialized when used here [-Wuninitialized]
>   block_len = GUINT32_FROM_BE (block_len);

> plug-ins/file-psd/psd-load.c:2312:34: note: initialize the variable 'comp_mode' to silence this warning
>   guint16               comp_mode;
2022-03-23 23:08:59 +00:00
Jacob Boerema cb47a72055 Fix: unable to open online help
Recently it was not possibly in master to open online help (F1).

This is also mentioned in issue #7915. However, on macOS there are likely
also other problems, which is why I'm hesitant to close that issue with
this fix.

(help.exe:57964): LibGimpBase-CRITICAL **: 15:24:38.792:
gimp_value_array_index: assertion 'index < value_array->n_values' failed

(help.exe:57964): GLib-GObject-CRITICAL **: 15:24:38.792: g_value_get_boxed:
assertion 'G_VALUE_HOLDS_BOXED (value)' failed

This was most likely caused by 8eb7f6df9e

Changing this to use args 0 and 1 instead of 1 and 2 fixes the problem.
2022-03-23 15:40:28 -04:00
NikcDC ba1896fd53 Issue #5648: Allow users to set the number of GIF loops 2022-03-21 14:54:57 +00:00
Daniel Novomeský 884611955a plug-ins: refactor metadata saving in HEIF/AVIF plugin
The plug-in now use gimp_image_metadata_save_filter API
2022-03-16 16:29:17 +01:00
Jehan e88dc5bed0 plug-ins: wrap the warning label to something smaller.
As raised on social networks, the big label grows the horizontal size of
the dialog. Make the label wrappable and give it a smaller wanted size
(otherwise, just making it wrappable is not enough and the dialog is
still too big when first appearing, because of how GTK handles such
widgets :-/).
2022-03-11 18:01:29 +01:00
Jehan 76b15eac18 plug-ins: don't set the BigTIFF checkbox insensitive on second try.
Actually I realized that using BigTIFF is not the only valid alternative
here. We can also try to use a better compression algorithm (or any if
"None" were selected) and try again to export as ClassicTIFF.

So don't check the option ourselves and don't set it insensitive. Let
one choose fully what they prefer to do.
2022-03-11 15:42:19 +01:00
Jehan 6e71478cd4 plug-ins: propose exporting as BigTIFF once if TIFF export fails…
… because we reached max TIFF size.

We detect the specific TIFF error (by string comparison so it's a bit
weak IMO yet it doesn't seem like libtiff provides anything better;
let's trust they don't change their error strings), then we reopen the
export dialog, pre-checking the BigTIFF checkbox newly created (and
making it insensitive). We still fail with error if an error happens the
second time (even for the same error).
2022-03-11 15:18:39 +01:00
Jehan 871796a126 Issue #7956: Add full BigTiff open/export support to GIMP.
Recent libtiff supports loading BigTiff automatically so we didn't have
anything to do there (as long as a recent libtiff was used). For
creating a BigTIFF though, we simply needed to add a "8" flag to
TIFFOpen/TIFFClientOpen when creating a new image (i.e. using "w8"
mode) as explained here in the "Implementation Strategy" section:
http://www.simplesystems.org/libtiff/BigTIFFProposal.html

What this commit does:

- Explicitly bump our libtiff requirement to version 4.0.0 or higher
  (which is where BigTiff support appeared).
  libtiff 4.0.0 was apparently released on 2011-12-22 and is available
  on all current distributions, so it's probably not a problem.
- Switch to detect libtiff with a pkg-config test (added in libtiff
  commit faf5f3eb before 4.0.0 release, so it's fine) instead of
  function checks.
  (Note: meson was already detecting for libtiff-4 with pkg-config,
  which was obviously wrong since it should have mimicked autotools, but
  well… then changes were minimal on meson)
- Add a new "bigtiff" boolean argument to the "file-tiff-save" PDB
  procedure, FALSE by default. I set this as the first argument as I
  figure that choosing the format you want is quite a major choice.
  Unless I misunderstood something, since BigTIFF is really designed to
  be an evolution of TIFF with a "minimum change strategy", i.e. mostly
  using 64-bit instead of 32-bit offsets, everything which is possible
  in TIFF will be in BigTIFF (and oppositely as well, except of course
  having huge files) so there is no need to have 2 separate procedures.
- Adding this new argument to the GUI dialog as a checkbox.
- Tweak the load and export procedures' documentation strings to make
  clear we support both TIFF and BigTIFF.
  Note: interestingly there doesn't seem to be a separate mimetype for
  BigTIFF so nothing to update on this side.
- Tweak the procedure labels too to mention BigTIFF. Since BigTIFF is
  still a different format (though very closely resembling) from TIFF,
  unlike some others which are just extensions embedded in a TIFF file
  (like GeoTIFF we recently added), I figure it deserves to be
  explicitly cited.
2022-03-11 11:31:53 +01:00
Jacob Boerema 477302fdab plug-ins: replace deprecated gexiv2 functions in metadata-viewer
Since we increased our minimum version of gexiv2 to 0.12.3, several
functions used in the metadata-viewer plug-in have been deprecated.

Replace these functions with the "try_" versions, which include an
error parameter. If this returns non NULL then we print the error
message to the console.
2022-03-09 11:30:56 -05:00
Jehan 657911ce48 plug-ins: using a GimpSpinScale instead of a GimpScaleEntry in…
… various plug-ins.
2022-02-19 02:26:11 +01:00
Jehan 65077a605f plug-ins: update foggigy after changes in GimpProcedureDialog.
The default for color properties (GimpRGB) is now to be editable. So
let's remove the formerly specific call for this.

Also fixing a clashing mnemonics ('c' both for '_Color' and '_Cancel').
2022-02-17 23:13:43 +01:00
Daniel Novomeský f61f389233 plug-ins: remove save-bit-depth heuristics in HEIF plug-in 2022-02-14 11:37:14 +00:00
Daniel Novomeský cbbae3a907 plug-ins: fix procedure parameter in file-jpegxl-save 2022-02-14 09:48:19 +01:00
Jehan d14b1d0523 plug-ins: change export dialog format name for Windows Cursors. 2022-02-12 13:54:20 +01:00
Jehan ce236b843e plug-ins: rename "write-color-space-info" arg into "write-color-space".
Let's sync with the proposal in !571 after discussing with Jacob. The
shorter naming is fine and the '-info' suffix feels a bit redundant
anyway. Also since this arg never even existed in GIMP 2.10 (until !571
which is soon to be merged), there is really not even a historical
reason.
2022-02-12 01:43:48 +01:00
Jehan 3e1c914358 plug-ins: fix file-gih.
"sel" argument was wrongly numbered.
2022-02-12 00:07:53 +00:00
Jehan a9e443fe4a plug-ins: fixing "file-glob" with the new GStrv return value.
Tested with:

> c = Gimp.get_pdb().lookup_procedure('file-glob').create_config()
> c.set_property('pattern', '/home/jehan/*.png')
> r = Gimp.get_pdb().run_procedure_config('file-glob', c)
> r.index(1)
2022-02-12 00:07:53 +00:00
Niels De Graef 8eb7f6df9e Remove GimpStringArray in favor of GStrv
GLib has a specific type of NULL-terminated string arrays:
`G_TYPE_STRV`, which is the `GType` of `char**` aka `GStrv`.

By using this type, we can avoid having a `GimpStringArray` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GStrv`, we allow other languages to pass on string lists as they are
used to, while the bindings will make sure to do the right thing.

In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with string arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).

Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
2022-02-12 00:07:53 +00:00
Jehan b301dbee78 Issue #526: Import/Export Windows cursor files (.CUR).
MR !565 was only a partial implementation as it was assuming all cursors
had the same hot spot coordinates in the file, which is false more often
than not (since usually it's several sizes for the same image, hence
coordinates move). I should have realized this before merging.
With this new commit, we actually loads the hot spot coordinates per
cursor, stores them as per-layer parasites, then exports with per-cursor
coordinates.

Also it makes the procedure API use int32 array (should be int16 but we
removed the support, now I think it may have been a mistake) which shows
the ugliness of our array support once again with additional size args
per array (even if it's the same size). Also I realize that our support
of arrays with config object is not good. This is also something we'll
have to look at.
2022-02-10 18:44:44 +01:00
Jehan d131c6a363 plug-ins: fix magics for .cur and .ico. 2022-02-10 13:27:24 +01:00
Nikc a22fd4f43a Issue #526 - Add Import/Export for Windows .CUR files 2022-02-10 12:09:40 +00:00
Jehan d25b7301d6 plug-ins: fix the ORA thumbnail load procedure.
- Fix return value in error case: s/GObject.Error/GLib.Error/ and anyway
  in this form, the error should be a string. Using the easier form
  procedure.new_return_values() instead.
- "file-png-load" uses a GFile now (like all load procedures).
2022-02-09 22:56:42 +01:00
Jehan 387d97437d plug-ins: use the new function Gimp.context_enable_dynamics(). 2022-02-04 14:04:46 +01:00
Nikc 6a16779365 Issue #6683: Set turbulence max-value to 7 per GEGL specs (Port) 2022-02-02 18:26:00 +00:00
Anders Jonsson 55aa462faa plug-ins: add translation context for tag values 2022-02-02 17:29:48 +00:00
Nikc 94c7f80282 Issue #4009: enables option to capture cursor in screenshot (Windows) 2022-01-19 01:28:47 +00:00
Jacob Boerema e51ca66ee5 plug-ins: fix #7524 DICOM File is broken
This is the same issue as with IM000001.dcm mentioned in issue #313.

There are two problems: incorrect endian conversion for 16 bits per pixel,
and not handling photometric interpretation "MONOCHROME1", which means
minimum value is white instead of black.

The endian conversion was fixed as suggested in issue #313.
For "MONOCHROME1" we added a variable bw_inverted and we invert the pixel
value if that variable is true.
2022-01-18 16:30:28 -05:00
Jacob Boerema 059599fc78 plug-ins: fix #6871 indexed tga file cannot be saved
Exporting an image to TGA fails with a crash when it's an indexed image
with alpha channel. We were not taking into account that even though
the output is 1 byte per pixel, the input should allocate memory for
2 bytes per pixel (1 color index and 1 alpha channel).
2022-01-18 15:00:22 -05:00
Daniel Novomeský 7e85e8f9a2 plug-ins: new speed levels possible for JXL export
JPEG XL plug-in can use very fast export settings:
thunder and the fastest lightning.
Compression slider is disabled for lossless
2022-01-08 23:21:36 +00:00
Daniel Novomeský 6da9a71aed plug-ins: adjust selection of precision during JXL import
There is no change for lossless images, where import precision
is directly related to bits_per_sample.
However, according JXL developers, for lossy images
(which generally use XYB color space), decoded data are not tightly
bound to bits_per_sample from header, import in 32bit
float precision can be used for better import quality
(libjxl works internally in 32bit float precision).
2022-01-04 12:28:54 +00:00
Daniel Novomeský 9bc971a466 plug-ins: use newer gexiv2 0.12.2 API in HEIF export 2022-01-03 15:33:39 +00:00
Daniel Novomeský 6acb5fde3e configure, meson: bump libjxl dependency to 0.6.1
JPEG XL plug-in always imported all JXL images
in 32-bit float precision in the past.
Now it also supports direct import in 8-bit
and 16-bit integer precision too.
2022-01-01 17:40:52 +01:00
Jehan 7dda738e8b plug-ins: update more script-fu scripts.
(gimp-image-get|set-active-layer) now ported into calls to
(gimp-image-get|set-selected-layers).
2021-12-23 12:55:11 +01:00
Jehan 708f3228d9 plug-ins: fix select-to-brush script.
The following calls needed to be updated:
gimp-image-set-selected-layers, gimp-edit-copy, gimp-edit-paste and
file-gbr-save.
2021-12-23 12:55:11 +01:00
Jehan 9dd6c1c467 plug-ins: fix lava script-fu script.
It was calling plug-in-gradmap with old single-layer API hence failing.
Also replacing all calls to (gimp-image-set-active-layer) and
(gimp-image-get-active-layer) in this file with
(gimp-image-set-selected-layers) and (gimp-image-get-selected-layers)
respectively.
2021-12-23 12:55:11 +01:00