Commit Graph

8871 Commits

Author SHA1 Message Date
Jehan c109a35c25 plug-ins: fix PDB data identifier to be canonical.
This is the bug which triggered me to do previous commit because the
error message was talking about a procedure name. Now the error message
is right, but let's not have an error at all! ;-)
2020-10-30 11:02:20 +01:00
Jehan d48dae7181 plug-ins: implement file-heif proc list in init_procedures() instead…
… of query_procedures().
Since our procedure list is now fully dynamic with runtime check, it's
much better to run it at every startup. Basically if some has updated
libheif with new encoders/decoders, we want GIMP to be aware at it at
next startup even if the plug-in has not been updated.
2020-10-26 17:53:00 +01:00
Jacob Boerema f336f86f60 plug-ins: use g_message instead of g_printerr when there is data loss.
After discussion with Jehan we concluded that it is better to report
these data loss messages to the user using g_message.
2020-10-24 18:33:26 -04:00
Jacob Boerema e4514567f9 plug-ins: don't try to read tiff pages with an invalid directory.
We didn't check whether TIFFSetDirectory succeeded nor did
we check TIFFReadScanline for failure which can cause
unresponsiveness.

We will not try to read a tiff page if setting its directory fails
and we will stop reading a page if reading scanline fails.
2020-10-24 13:52:15 -04:00
Jehan 7462945360 plug-ins: fix a type warning.
Since obj->type_data is also int anyway, multiplying by a double value
is unneeded anyway. So let's just make an integer multiplication.
Fixes the following warning:
> warning: using integer absolute value function ‘abs’ when argument is
> of floating point type ‘double’ [-Wabsolute-value]
2020-10-24 02:58:38 +02:00
Jacob Boerema 7957653e98 plug-ins: fix #3757 Exporting invalid tiffs: Missing required "ImageLength" field.
Because of Exif.Thumbnail.* tags file-tiff-save saved an invalid extra page in
exported tif images. Removing these tags fixed this for me.
2020-10-23 17:39:09 -04:00
Jacob Boerema c10bb098b4 plug-ins: file-tiff-save looks for the wrong exif tags to delete.
The correct tag for sub images is Exif.SubImage instead of
Exif.Image. I also added Exif.Image.InterColorProfile since
that didn't seem to get deleted when saving without
color profile.

Also added a FIXME note since most of this stuff should be
genealized for all gimpmetadata handling.
2020-10-23 12:51:04 -04:00
Jehan c86d909dda plug-ins: fix parameters of Gimp.file_save().
It now requires a list of drawables (even though still mostly useless,
but this comes with the change of multi-selected layers).
2020-10-23 15:20:21 +02:00
Daniel Novomesky 35c0d7dca6 HEIF plug-in: runtime detection of supported formats 2020-10-22 16:46:51 +00:00
Jehan 05bb84ebed Issue #5788: 10/12 bpc in HEIF export does not mean HDR. 2020-10-19 20:47:07 +02:00
Jehan cb2268ab21 meson: separate line for HEIC and AVIF support.
libheif pc files provides variables which are actually older than our
minimum libheif requirement (so it's usable generically) to determinate
if libheif was built for HEIC/AVIF support. This is quite useful as we
had our share of annoyance with missing support of some encoder/decoder
even when libheif requirement was alright.

Also adding image/avif (if relevant decoder is present) to list of
supported mimetypes.
2020-10-19 18:56:13 +02:00
Jehan 02cb754b4a plug-ins: run gimp_displays_flush() in foggify.
Without this call, the display is not properly updated and does not show
the newly added fog layer.
2020-10-18 00:41:22 +02:00
Jacob Boerema fafe9889e0 plug-ins: Let the user know if we fail to save image metadata in file-jpeg. 2020-10-15 15:12:58 -04:00
Daniel Novomesky 64bfa57eec Improved HEIF plug-in
User can select color subsampling/pixel format
(YUV444, YUV420, RGB)
User can select encoder speed (Slow, Balanced, Fast)
Lossless option delivers visually lossless output
2020-10-15 17:38:24 +02:00
Jehan ecbc38f9e9 plug-ins, extension: goat-exercises becomes a GIMP extension.
This is an extension containing a few demo plug-ins. This is good to
demonstrate the extension format. It will also allow to disable these
plug-ins (if at some point, one doesn't want to show these demo
plug-ins anymore).

And finally it deals with the fact that our plug-in code is stupid, as
it just tries to find the first executable with the same name (minus
extension) as the plug-in folder. This doesn't go well on Windows, where
the permission system is non-existent. So our code just ends up trying
to run the first file with a similar name in a plug-in folder. As the C
goat-exercise contains both an exe and the C source (and the system
probably returns files in alphabetic order), GIMP under Windows tries to
run the C source instead of the executable (this obviously doesn't go
well).
We could try to do more complex logics, like not aborting if the first
file run fails and try the next one in the plug-in folder. Or maybe just
rename the C file to another name. But any of these is just in the end
the proof that our plug-in discovery right now is just bogus. The
extension system is explicit, not based on randomly trying out files.
Plug-ins entry points are explicitly listed in the metadata manifest.
2020-10-09 15:30:54 +02:00
Jacob Boerema 02bad34a41 Issue #5735: incorrect condition because of missing parenthesis.
Also taking the opportunity to change the minimum size since I
apparently counted it wrong. The size always seems to be 46
starting from psp file-version 4 up to and including the current
version 13.
2020-10-08 13:54:24 -04:00
Jehan 66dae000f9 Issue #5734: fix typos in if() test. 2020-10-08 01:36:34 +02:00
Jehan 5ec3293fee plug-ins: change export dialog title when exporting as AVIF.
Even though "Export Image as HEIF" is not technically wrong (AVIF is AV1
encoding inside HEIF container), it is better to be more accurate.

Moreover as Daniel Novomesky was explaining in a MR, nowadays when we
say "HEIF", we usually mean "HEIC", whereas you'd use the explicit
"AVIF" naming for HEIF/AV1 images. This seems confirmed by Wikipedia
which says that HEIC is the "implied default codec for HEIF".

So let's just make the AVIF vs HEIF distinction here (I could have used
AVIF vs. HEIC which is even more explicit but I decided to keep the
less-specific yet more used HEIF naming).
2020-10-04 17:41:58 +02:00
Sebastian Rasmussen 9727a38977 plug-ins: When exporting BMP with color space info, always include color masks.
This fixes issue #4155.
2020-09-27 09:57:24 +00:00
Liam Quin fe340c822a plug-ins: The plugin can leak the "tif" file descriptor as written...
... and also doesn't write out all the data, if it does a "goto out" for
any reason. A leaked file descriptor can prevent a file from being
renamed or deleted on Windows.
See also #3740.

Reviewer note (Jehan): this may not be the main issue as reporters were
not writing about export failure. So there is probably another case even
when the plug-in successfully wrote the TIFF image.
2020-09-27 01:07:24 +02:00
Rico Tzschichholz 9c90ab44fe MR !343: using GimpUi prefix in Vala plug-ins too. 2020-09-26 22:11:53 +02:00
Jehan 2e73e30afd libgimp: 'gimp_ui' as priority prefix for GimpUi introspected module.
Since meson 0.43.0 (below our current requirement), 'symbol_prefix'
argument of gnome.generate_gir() allows an ordered list. If I prepend
'gimp_ui', it makes any gimp_ui_*() function to not start with 'ui_'.

In particular, GimpUi.ui_init() becomes GimpUi.init() which is much less
redundant.
2020-09-26 22:11:53 +02:00
Jehan 67e2e1b5bb app, libgimp, plug-ins: move Orientation metadata handling into core.
Orientation is now handled by core code, just next to profile conversion
handling.

One of the first consequence is that we don't need to have a non-GUI
version gimp_image_metadata_load_finish_batch() in libgimp, next to a
GUI version of the gimp_image_metadata_load_finish() function in
libgimpui. This makes for simpler API.
Also a plug-in which wishes to get access to the rotation dialog
provided by GIMP without loading ligimpui/GTK+ (for whatever reason)
will still have the feature.

The main advantage is that the "Don't ask me again" feature is now
handled by a settings in `Preferences > Image Import & Export` as the
"Metadata rotation policy". Until now it was saved as a global parasite,
which made it virtually non-editable once you checked it once (no easy
way to edit parasites except by scripts). So say you refused the
rotation once while checking "Don't ask again", and GIMP will forever
discard the rotation metadata without giving you a sane way to change
your mind. Of course, I could have passed the settings to plug-ins
through the PDB, but I find it a lot better to simply handle such
settings core-side.

The dialog code is basically the same as an app/dialogs/ as it was in
libgimp, with the minor improvement that it now takes the scale ratio
into account (basically the maximum thumbnail size will be bigger on
higher density displays).

Only downside of the move to the core is that this rotation dialog is
raised only when you open an image from the core, not as a PDB call. So
a plug-in which makes say a "file-jpeg-load" PDB call, even in
INTERACTIVE run mode, won't have rotation processed. Note that this was
already the same for embedded color profile conversion. This can be
wanted or not. Anyway some additional libgimp calls might be of interest
to explicitly call the core dialogs.
2020-09-24 12:43:41 +02:00
Jehan 0ec5ee4394 plug-ins: get rid of pygimp!
It's done, all Python plug-ins have been either ported to the new API +
Python 3, or they have been discarded (and moved to gimp-data-extras for
whoever wants to salvage them).
Let's get rid of the outdated pygimp directory (whose code has not been
built in the master branch for years now anyway)! Woohoo!
2020-09-21 18:17:18 +02:00
Jehan 2271b5bbdb Issue #4368: remove 2 more outdated Python plug-ins.
shadow_bevel.py and sphere.py are unfinished and have been in the
"Unstable" only builds for years. This is probably not worth porting
them. Let's just delete them.

I have actually move these (as well clothify and whirlpinch removed
yesterday) to the gimp-data-extras repository so if anyone wants to
revive them, and port them to GIMP 3, they can start off from there.
2020-09-21 17:14:51 +02:00
Jehan e154cd220d plug-ins: delete Python whirlpinch and clothify without porting them.
Following Elad Shahar advice (cf. #4368), let's delete whirlpinch.py and
clothify.py.

The rational is that whirlpinch.py does the same thing as the existing
"plug-in-whirl-pinch" which is itself a compat plug-in to
"gegl:whirl-pinch" operation. Also the Python file has an explicit
command saying it is exactly the same algorithm, yet with no preview and
slower. Finally it was not even installed on stable build. It doesn't
look like there is any reason to keep it (it was probably a demo/test
Python plug-in).

As for clothify.py, a quick look at the short code shows it is exactly
the same algorithm as clothify.scm, with the same arguments and
installed on the same `Filters > Artistic` menu (except that the Python
version is not installed on stable builds).
So let's just keep the script-fu version as it has been the used version
until now, and there is no deprecation going on in one side or another.
So let's keep what already works.
2020-09-21 01:44:51 +02:00
Jehan a455c72929 plug-ins: update previous commit to API changes.
Since the patch was initially contributed, some parts of the
introspection changed. First all GUI-related code is in a GimpUi module
now.
Also Gimp.get_pdb().run_procedure() is now using a list instead of a
GimpValueArray.
2020-09-21 00:52:30 +02:00
Elad Shahar 12b4d9b097 Port histogram-export plugin to python 3 2020-09-21 00:38:29 +02:00
Elad Shahar 33085b5182 plug-ins: Port python-eval.py plugin to python 3.
To test that this works, run gimp in batch mode:

% gimp2.99 -i -b -

And then type: (python-fu-eval "print (2)") .
2020-09-21 00:30:41 +02:00
Elad Shahar a07576b219 Port benchmark-foreground-extract.py to python 3.
Note by reviewer (Jehan): merging this port as it was in GIMP 2.10
anyway, but is this even still needed code? This plug-in is not even
available on stable release, it looks like for-development only
benchmark, and I'm not sure if it's relevant anymore, especially in our
GEGL-fueled new world.

Please anyone who knows a bit more on the history of this plug-in and
the evolution of our gimp_drawable_foreground_extract() algorithm, feel
free to weigh in and tell us what this was for exactly and if it's still
relevant.
2020-09-21 00:13:35 +02:00
Elad Shahar cc2f064d8d plug-ins: Port palette-sort to Python 3
This is a basic port without any UI.
Invoking the plugin will just sort the entire palette based on
default parameters.
The original plugin had several broken options, which I tried to fix.
2020-09-20 23:58:02 +02:00
Niels De Graef 43d0f0fbd2 gimppdb: Allow more easy bindable API
Plug-ins that work from different bindings probably want to use their
own list-type to specify arguments, rather than working with a more
cumbersome `GimpValueArray`.

This new API should make it less verbose. For example:

```
args = Gimp.ValueArray.new(5)
args.insert(0, GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE))
args.insert(1, GObject.Value(Gimp.Image, image))
args.insert(2, GObject.Value(Gimp.Drawable, mask))
args.insert(3, GObject.Value(GObject.TYPE_INT, int(time.time())))
args.insert(4, GObject.Value(GObject.TYPE_DOUBLE, turbulence))
Gimp.get_pdb().run_procedure('plug-in-plasma', args)
```

becomes

```
Gimp.get_pdb().run_procedure('plug-in-plasma', [
    GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
    GObject.Value(Gimp.Image, image),
    GObject.Value(Gimp.Drawable, mask),
    GObject.Value(GObject.TYPE_INT, int(time.time())),
    GObject.Value(GObject.TYPE_DOUBLE, turbulence),
])
```
2020-09-20 11:36:01 +00:00
space pudim 22bedfc376 Fix #4560 - file-xpm saving unused transparency
The XPM export plugin was saving the color `None` (transparency) to the
exported image palette for all images with an alpha channel, even if the
color was not used on any pixel.

Since it's nice to have `None` as the first color on the palette, mapped
to character ' ', and it could be too wasteful to scan all pixels twice,
the approach taken was to just undo it's premature insertion.

(cherry picked from commit 0a9bb2839e)
2020-09-20 02:18:50 +02:00
Jehan 0fc8821932 plug-ins: fix missing "plug-in-colormap-swap" procedure.
Existing code was returning only 1 out of 2 expected procedure names.

See !241 for the originally proposed patch by Rafał Mikrut (@qarmin).
Unfortunately the proposed patch also had another bug and was always
returning an empty list instead, and the contributor is unresponsive. So
let's just redo the patch and be done with it.

Also using g_list_prepend() instead of g_list_append() as it's usually
more efficient (to be fair here, for a size-2 list, it doesn't matter
much but it's good practice anyway) and order doesn't matter.

Thanks Rafał Mikrut for noticing the original bug!
2020-09-19 19:27:26 +02:00
Félix Piédallu 783f7cae55 Re-enable Twain plugin on Windows for Meson build 2020-09-19 12:07:14 +00:00
Jacob Boerema 9e3508cc23 plug-ins: silence some warnings in twain plug-in. 2020-09-18 17:51:55 -04:00
Jacob Boerema d0b1c143b6 plug-ins: fix #3854 by porting twain to the new plugin framework.
Removed the WinMain specific stuff for the plug-in and determine
hInstance in twainMain which made porting a lot easier.

The _DEBUG enabled functions I have mostly left alone and
should be revised at a later time.
2020-09-18 17:51:55 -04:00
Jehan b3bed72d84 plug-ins: default export bit depth for 16 or 32 bpc images should be 12.
The proposed defaults for export should be the less destructive
possible. So for any 16 or 32 bpc GIMP images, since our HEIF plug-in
only supports up to 12 bpc, this should be what we export to.
2020-09-18 15:32:55 +02:00
Daniel Novomesky 76db57e738 Metadata (Exif, XMP) export in HEIF plug-in
Exif metadata export is built only with GExiv2 0.12.2+ because gexiv2_metadata_get_exif_data is used.
2020-09-17 13:48:03 +02:00
Daniel Novomesky 7f95abc4ef Make strings translateable in HEIF/AVIF export dialog 2020-09-12 22:28:03 +02:00
Jacob Boerema bf66a07d20 plug-ins: add support for indexed images in psp reader. 2020-09-11 23:44:57 -04:00
Jacob Boerema 2054f9f163 plug-ins: add support for grayscale images in psp reader. 2020-09-11 23:44:57 -04:00
Jacob Boerema 7863d668e0 plug-ins: add support for 16 bit integer images in psp reader. 2020-09-11 23:44:57 -04:00
Jacob Boerema 84f06e976a plug-ins: show descriptive layer type name for psp layers we can't convert. 2020-09-11 23:44:57 -04:00
Jacob Boerema d7abb774a9 plug-ins: add defines for psp reader to include new things up to psp file version 8.
This also fixes the incorrect existing define for a mask layer.
2020-09-11 23:44:56 -04:00
Jacob Boerema 0a8f5b99f5 plug-ins: replace a few occurrences of g_message with g_set_error in psp reader. 2020-09-11 23:44:56 -04:00
Daniel Novomesky 0fce1b042b Fix compilation with old libheif 1.3.2
High bit depth import and export enabled only for >= libheif 1.8.0
2020-09-08 10:25:16 +00:00
Elad Shahar 7d1e108b90 plug-ins: spyrogimp - fix type of new layer to include alpha channel 2020-09-01 11:44:11 +02:00
Jacob Boerema 19b261f3c6 plug-ins: add most likely blend modes for certain psp blend modes.
This adds a blend mode for all known psp blend modes that were not
converted yet except for adjust.
I couldn't find any information about adjust and it's value of
255 suggests that it is not a normal blend mode.
2020-08-31 12:28:12 +00:00
Jacob Boerema b968a93ab2 plug-ins: fix reading of psp tubes when psp file version >= 4. 2020-08-31 11:10:15 +00:00