Commit Graph

87 Commits

Author SHA1 Message Date
Alx Sa c92cf7e8f2 plug-ins: Convert file_*_save to file_*_export
Resolves #10932

Since GIMP distinguishes between saving
XCF and exporting image like PNG,
we should change the PDB to show
export rather than save in the function
calls.
2024-04-16 16:07:10 +00:00
Daniel Novomeský d326e1350e
plug-ins: clean-up HEIF plug-in
Plug-in now requires libheif >= 1.15.1, so many preprocessor
directives like LIBHEIF_HAVE_VERSION(1,13,0) are no longer needed.
2024-02-05 13:28:13 +01:00
Daniel Novomeský 8bb34ac596 plug-ins: HEJ2 format loading
This image format is also called as JPEG-2000 in HEIF,
it is supported in recent versions of libheif.
Specification: https://www.itu.int/rec/T-REC-T.815-202106-I/en
2023-11-20 20:16:01 +01:00
Daniel Novomeský 183cb49b1e plug-ins: load metadata via libheif and disable rotation dialog 2023-11-06 16:03:28 +01:00
Jehan bf8ee69570 plug-ins: fix some broken macros with a massive search-and-replace.
If we leave a space between the macro name and opening parenthese for argument
lists, the args are not considered macro args (which will be discovered when
using it). I experienced this issue while testing code on some plug-in
yesterday, so thought I might as well fix all these broken macros for casting to
the specific GimpPlugIn subclass, so that we won't have a next time.
2023-10-18 18:29:37 +02:00
Jehan 9e2a7e8759 libgimp, plug-ins: rename gimp_load_procedure_new2() as gimp_load_procedure_new().
All C load procedures are now moved to the new API.
2023-10-01 21:02:32 +02:00
Jehan 136aca3c34 plug-ins: port all remaining C load procedures to gimp_load_procedure_new2(). 2023-10-01 21:02:29 +02:00
Jehan fcc810d7d3 libgimp, plug-ins: rename to gimp_save_procedure_new().
Also the mimetype is already set by gimp_file_procedure_set_mime_types() so
transform the mimetype argument into an export_metadata argument.
2023-10-01 20:52:02 +02:00
Jehan 9ed8f00e5b plug-ins: port most plug-ins to gimp_save_procedure_new2(). 2023-10-01 20:52:02 +02:00
Jehan 231ca0c505 Issue #9994: do not call g_file_info_get_is_hidden() (and others) directly.
This is not the main reason for the specific output in #9994. These ones are
more probably because of similar usage in GTK (which updated its own calls to
g_file_info_get_is_hidden|backup() in version 3.24.38). But we should likely
also update the various calls we have to use the generic
g_file_info_get_attribute_*() variants.

To be fair, it is unclear to me when we can be sure that an attribute is set.
For instance, when we call g_file_enumerate_children() or g_file_query_info()
with specific attributes, docs say that it is still possible for these
attributes to not be set. So I assume it means we should never use direct
accessor functions.

The only exception is that I didn't remove usage of g_file_info_get_name(),
since its docs says:

> * Gets a display name for a file. This is guaranteed to always be set.

Even though it also says just after:

> * It is an error to call this if the #GFileInfo does not contain
> * %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.

Which is very contradictory. But assuming that this error warning was
over-zealous documentation, I kept the direct accessors since they are supposed
to be slightly more optimized (still according to in-code documentation) so
let's priorize them when we know they are set for sure.
2023-09-19 15:34:48 +02:00
Jacob Boerema b37f0a3182 libgimp, plug-ins: remove obsolete XmpStructs 2023-05-20 12:39:29 -04:00
Daniel Novomeský 2e6e5f0321 plug-ins: Port file-heif to GimpProcedureDialog 2023-03-22 20:05:27 +00: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
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
Daniel Novomeský a61299ddb1 plug-ins: fix builing with libheif 1.13.0+ 2022-09-03 19:19:30 +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
Daniel Novomeský 7452c4bc6e plug-ins: ensure that metadata correspond to real image size 2022-06-16 16:46:31 +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
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
Daniel Novomeský f61f389233 plug-ins: remove save-bit-depth heuristics in HEIF plug-in 2022-02-14 11:37:14 +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 Novomesky 7e549246d8 plug-ins: fix memory leak in HEIF import/export 2021-10-28 19:39:51 +00:00
Daniel Novomesky 75fabb07e3 plug-ins: prefer AOM encoder for AVIF export
libheif uses rav1e encoder by default to encode AVIF. However,
performance of AOM encoder got improved significantly, so
I think it is wiser to give preference to AOM, when both
AOM and Rav1e encoders are available.
Name of the used encoder is printed during export,
It can be: aom, rav1e, x265
2021-10-25 12:34:53 +00:00
Daniel Novomesky c4e5c185cc HEIF plug-in: fix typo in comment 2021-10-06 14:35:54 +02:00
Daniel Novomesky dd5cb5cef1 Crash workaround for HEIF plug-in 2021-10-03 15:11:25 +00:00
Daniel Novomesky 6488a5e480 Disable automatic metadata handling for HEIF plug-in
The plug-in saves metadata together with exported image.
We ensure that GIMP won’t try to save metadata to
already exported file second time.
2021-04-07 16:26:16 +00:00
Jehan ca8bc2bc1d app, libgimp, pdb, plug-ins: more functions moved to get|set().
The gimp_drawable_type() is an issue though as gimp_drawable_get_type()
is already defined as a common GObject API.
Though I'm actually wondering if GimpImageType is well called. Rather
than Type, shouldn't we go with ColorModel?

sed -i 's/\<gimp_drawable_bpp\>/gimp_drawable_get_bpp/g' "$@"
sed -i 's/\<gimp_drawable_width\>/gimp_drawable_get_width/g' "$@"
sed -i 's/\<gimp_drawable_height\>/gimp_drawable_get_height/g' "$@"
sed -i 's/\<gimp_drawable_offsets\>/gimp_drawable_get_offsets/g' "$@"
2021-04-06 14:34:31 +02:00
Daniel Novomesky 6ca6a8d239 HEIF plug-in: ensure max quality for lossless encoding
There is a possible bug in libheif. Lossless setting is not working
when AVIF is saved via rav1e encoder.
This is a workaround of the problem.
2021-01-18 10:54:09 +00:00
Daniel Novomesky 76810d28dd Updated HEIF plug-in
Realtime parameter is set for AOM encoder
when Fast encoding speed is selected by user.
Ability to set pixel format (YUV444, RGB)
is enabled for >= libheif 1.10
to avoid issues in older versions.
2020-12-16 19:35:24 +00:00
Jehan c94325c670 plug-ins: s/g_get_num_processors/gimp_get_num_processors/ in file-heif. 2020-12-11 18:29:12 +01:00
Jehan 2ea5dec56e libgimpwidgets: improved gimp_prop_scale_entry_new(), new function…
… gimp_label_spin_set_digits() and deleted gimp_prop_opacity_entry_new()

- The "digits" argument for the number of decimal places in
  gimp_prop_scale_entry_new() is now mostly useless since GimpLabelSpin
  (hence GimpScaleEntry too) got a nice estimation algorithm of sensible
  values.
- Add gimp_label_spin_set_digits() function to manually set the digits
  property when we don't like the estimated value.
- Also add a new "factor" argument to gimp_prop_scale_entry_new(). Its
  role is to allow a GimpScaleEntry showing a factored range, typically
  a [0, 100] range for some types of [0, 1] properties.
- Remove gimp_prop_opacity_entry_new() which was basically a
  special-case of gimp_prop_scale_entry_new() and which can now be
  easily reproduced by simply set factor=100.0.
- Update all usage of gimp_prop_scale_entry_new() in app/ and plug-ins/
  with updated arguments. It is interesting to note that all existing
  usage were either integers (digits=1) or when double, the estimated
  decimal places are the same as the ones which were manually set (hence
  showing the generic estimation is not too bad). So the new function
  gimp_label_spin_set_digits() was not even needed once in current code.
2020-11-25 02:32:22 +01:00
Jehan d95f417719 app, libgimpwidgets, modules, plug-ins: code changes after GimpScaleEntry…
… reclassing as GimpLabelSpin subclass.
2020-11-05 18:06:52 +01:00
Jehan 0f05825a29 app, libgimpwidgets, plug-ins: default increments for GimpScaleEntry.
Instead of setting always manually the step and page increments when
creating a GimpScaleEntry, let's just generate some common cases
automatically. Indeed the increments are rarely something you want to
care about. The algorithm used is:
- For a range under 1.0, use a hundredth and a tenth (typically a [0,
  1.0] range will step-increment of 0.01 and page-increment of 0.1).
- For small ranges (under 40), step-increment by 1, page-increment by 2.
- For bigger ranges, step-increment by 1, page-increment by 10.

For use cases when you absolutely want specific increment values, I add
the gimp_scale_entry_set_increments() function. It is much better to
have a small and understandable constructor call followed by
configuration calls (only when needed) rather than a constructor with a
crazy amount of parameters. Hence gimp_scale_entry_new() went from 17
arguments (absolutely unreadable calls) to now 5.
2020-10-30 12:33:46 +01:00
Jehan d81b151e79 app, plug-ins: use the updated gimp_prop_scale_entry_new() API. 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
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
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 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
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 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
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
Jehan 97dc1bf9c6 plug-ins: fix wrong return type warning.
save_image() returns a boolean not a pointer.
2020-08-31 12:52:23 +02:00
Daniel Novomesky 01e1587ec1 Updated HEIF plug-in
AVIF import and export (need libheif >= 1.8.0)
High bit (10/12) import and export
Auto pre-select suggested output bit depth in save_dialog
NCLX color profile import (link with lcms)
Metadata import (link with gexiv2)
Plugin will not return GIMP_PDB_SUCCESS in case of failure to import file.
2020-08-26 10:39:58 +00:00
Jehan d3139e0f7c app: support saving/exporting with multi-selection.
This commit just changes our saving API (i.e. the GimpSaveProcedure
class) to take an array of drawables as argument instead of a single
drawable.

It actually doesn't matter much for exporting as the whole API seems
more or less bogus there and all formats plug-ins mostly care only
whether they will merge/flatten all visible layers (the selected ones
don't really matter) or if the format supports layers of some sort. It
may be worth later strengthening a bit this whole logics, and maybe
allow partial exports for instance.

As for saving, it was not even looking at the passed GimpDrawable either
and was simply re-querying the active layer anyway.
Note that I don't implement the multi-selection saving in XCF yet in
this commit. I only updated the API. The reason is that the current
commit won't be backportable to gimp-2-10 because it is an API break. On
the other hand, the code to save multi-selection can still be backported
even though the save() API will only pass a single drawable (as I said
anyway, this argument was mostly bogus until now, hence it doesn't
matter much for 2.10 logics).
2020-05-17 18:32:16 +02:00
Michael Natterer b5f10b6eda plug-ins: port file-heif and file-webp to the new export stuff 2019-10-09 23:50:14 +02:00
Michael Natterer 9cb62f5f9a libgimp: move "image" and "run_mode" from gimp_procedure_config_end_run()
and remember them internally between begin_run() and end_run().
Simplifies plug-in code even more.

Move the begin_run() before gimp_export_image() block in all export
plug-ins.
2019-09-26 00:44:52 +02:00