Commit Graph

9324 Commits

Author SHA1 Message Date
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
Jehan a982809c5f configure, meson, plug-ins: unmaintain WebkitGTK-depending plug-ins.
This is an official way to declare these plug-ins as now
unmaintained/deprecated.
Relevant plug-ins are:

1) help-browser (Displaying the docs): nowadays every desktop machine
   has a browser. Let's just use whatever is the person's default
   browser.
2) web-page (Web screenshot): it looks to me like every browser has this
   feature by default now (I use it all the time in Firefox to get a
   full-page screenshot, never in GIMP), even on mobile, I am told. It's
   nice to have it in GIMP too, but not like absolutely necessary.

On the other hand:

1. It's a hell to build, with a lot of issues. We have regular issues on
   our Flatpak-s. We don't manage to build it on our CI (only locally
   apparently). Also it takes a crazy amount of time (like 90% of CI
   build-time would be webkit).
2. From what I gather, new versions don't work on Windows anymore. Even
   MSYS2 seems to have dropped the ball and don't try anymore.
   Basically we would have a feature disparity from GIMP 3.0 (most
   platform but Windows). We don't know when it will be resolved (if
   ever) as it's been like this for years.

Now why we are keeping the code around instead of just removing
everything is that the topic tree in the help browser is useful and
comfortable to use. Ideally we should get some equivalent to help
browsing the help efficiently in the web docs as well (so basically
menus, web search and alike?). So I am told to keep the code around at
least for now to see if we can figure something out or improve the
situation.
Except for this point, we can consider the WebkitGTK plug-ins as
deprecated from GIMP 3.0 on.
2021-12-22 18:59:07 +01:00
Jehan ef9c483771 plug-ins: remove KDE screenshot portal in favor of Freedesktop portal.
On recent KDE, the screenshot plug-in fails with an authorization error,
unless we add a desktop file with a special KDE-only desktop entry to
give the permission, which seems a bit over-the-top (if we were to add a
desktop file for every plug-in, and with dedicated entries to every
desktop environment out there, it's never-ending). Of course, we are not
against either, but nobody has contributed a patch doing this in the
last year anyway.

Also Méven (KDE dev) was telling us that KDE recommends to use the
Freedesktop portal nowadays. So maybe let's just move on from the
KDE-specific portal, just as we did recently for the GNOME portal too.
This should hopefully take care of all permission issues and in the same
time simplifies the code.

Note that the Freedesktop API might miss some of the features (this was
one of the reason we were avoiding putting it as priority implementation
until now, to avoid feature regression), but the more we go, the less we
have a choice. It's either this or always fighting against the current.
2021-12-17 20:14:18 +01:00
Jacob Boerema 7b7d616358 plug-ins: fix #5305 Lighting Effects crashes when I use a channel as Bumpmap
When a channel is selected as bumpmap, the bump_format can be different
than it was before. However, we always kept the first bump_format, which
could be RGB, in which case trying to use it with a channel caused a
crash in GIMP.

To fix this we always update the bump_format if bumpmap is enabled.
2021-12-17 12:06:18 -05:00
Jehan e8a31ba4f2 plug-ins: in file-gegl, use the accurate load/save GEGL operation…
… rather than generic "gegl:load" and "gegl:save".

In particular, it means using "gegl:rgbe-load|save" for RGBE images and
"gegl:exr-save" for EXR exporting.

Without this, we could encounter weird run cases where for instance, we
would detect a RGBE image through the file magic number in GIMP,
redirect the load to file-gegl, but "gegl:load" only relies on file
extension. So if the file extension was not ".hdr", "gegl:load" could
redirect to a different handler operation meant for another format,
hence break proper loading. If no extension was matched, it could even
redirect to a fallback handler, such as Image Magick.

This breaks loading or saving images which we would be otherwise able to
load/save. And it could also have some security implications. So let's
fix this by setting the accurate operations to use for each specific
file formats we want to support through the file-gegl plug-in.
2021-12-17 17:19:34 +01:00
Jehan d5164072e0 plug-ins: fix Radiance RGBE magic number.
Note that the full magic should be "#?RADIANCE". Not sure why we only
use the first 2 characters. Do some software create these RGBE files
with just "#?" and we want to be able to read these? No other image
format use these 2 characters as the start of their own magic numbers?

Anyway let's keep like this for now. We'll see. If it makes a problem,
we might update to more accurate magic later.
2021-12-17 17:02:36 +01:00
Jacob Boerema e51d5d480d plug-ins: add extra layer groups when loading PSD images with clipping layers
Together with the previous commit this mostly fixes #5438.

PhotoShop handles clipping layers in a different way than GIMP. The only
way to have it look the same is by adding extra layer groups.
PSD layers that have clipping set, combined with the first non clipping
layer below it are grouped together in a new layer group.
Doing this results in the same image as the PSD merged image unless there
are other PSD elements in play that we don't handle yet.

See e.g. the NSFW image in the mentioned issue where the purple hair color
is a little darker than the merged image.
2021-12-14 12:27:16 -05:00
Jacob Boerema e7f85f7b3f plug-ins: PSD layers with clipping set need clip to backdrop as composite mode
Certain PSD layers have a flag called clipping set to 1. We were not
handling this flag and had some reports about colors bleeding where
they were not supposed to.
We are going to set GIMP's layer composite_mode to
GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, which is the closest we can get
to PhotoShop's clipping. With this, the colors won't bleed anymore.
This isn't the whole solution since PS apparently stops compositing when
it encounters a layer without clipping set, while GIMP doesn't stop until
it reaches the bottom layer of a group or the image.

This is the first part of a fix for issue #5438.
2021-12-14 12:27:16 -05:00
Jehan c502fb18ce plug-ins: show screenshot options dialog immediately in Freedesktop…
… portal.

Otherwise, it first takes a screenshot and proposes to either share or
tweak the "Options" (in the GNOME shell implementation at least). Doing
the other way around is much more in line with how we had done it until
now with our custom dialogs.
2021-12-14 17:59:25 +01:00
Niels De Graef 62953e6830 screenshot: Remove GNOME Shell implementation
GNOME Shell has started restricting access for it's Screenshot D-Bus API
to internal components only [1] for security reasons. In other words,
this will start failing, so remove it in favor of just using the
freedesktop portal, which should always work.

[1]: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1970
2021-12-14 11:36:40 +00:00
Jacob Boerema dec5ca2219 plug-ins: fix #7566 Import Issues with Indexed .dds Images
This proved to be both an import and export issue.
Our import set expected format as RGB, causing garbled image output.
Our export for indexed images converted to grayscale first, although the
palette was correctly saved. This caused wrong palette indexes on import.

For indexed images, on import, we request the actual indexed format after
creating the layer with gimp_drawable_get_format, which gives us a correct
indexed Babl format.
Also added logic for indexed with alpha, although I have no sample images
to test this.
For indexed images on export we do the same: use gimp_drawable_get_format
to get an actual indexed Babl format.
2021-12-01 15:01:48 -05:00
Daniel Novomesky 6cbac22f45 plug-ins: user can select bit depth in JXL export
JPEG-XL strings are renamed to JPEG XL,
in order to correspond to correct format name.
2021-11-27 18:17:06 +01:00
Jacob Boerema 82b7fa84bd plug-ins: fix loading of 32-bit per channel psd images
Although there was code to load 32-bit per channel psd images. It is
unlikely that it ever worked, because:
- We tried to load them as u32 instead of float.
- While we did some decoding of the zip predictor data, for float values
we also need to restore the byte order from 111222333 to 123123123.
- We did the endian conversion first while it should be done on the
restored values.
With these things fixed I can load the few samples I have.
2021-11-15 17:15:08 -05:00
Emily Gonyer 3afa37cbc6 app, libgimp*, plug-ins: Changed gendered terms to be gender-neutral
Changed a handful of gendered terms to be gender-neutral, and one typo 
of 'he' to 'the' where appropriate.
2021-11-14 11:22:24 +00:00
Jacob Boerema 3425212a3f plug-ins: fix export of multi layer image as psd
Due to starting with the highest index we were referencing layer data
out of bounds.
We need to decrease i with 1 before using it as index into the channel data
for the correct layer.
This caused a crash when exporting multi layer images.
2021-11-11 18:30:25 -05:00
Jacob Boerema 737cc09e7c plug-ins: Use the same define for debugging psd-load and psd-save
psd-save was using a separate define for enabling debugging. Let's just
use the one define from psd.h.
IFDBG -> IFDBG(1)
IF_DEEP_DBG -> IFDBG(3)
Besides changing the define in psd-save we also change all the printf
statements used for debug output to g_debug. This allows us to view/hide
the debug output.
2021-11-11 18:30:25 -05:00
Jacob Boerema 5365d0ad6c plug-ins: fix more resource leaks in case of errors for psd-load.c 2021-11-11 18:30:25 -05:00
Jacob Boerema 18e835e9f6 plug-ins: remove unneeded and uninitialized base_channels. 2021-11-10 22:47:08 -05:00
Jacob Boerema c6243bf295 plug-ins: add support for loading 16-bit per channel CMYK PSD images 2021-11-10 22:41:42 -05:00
Jacob Boerema ef720d6557 plug-ins: fix a few resource leaks in case of errors in psd-load.
The resource leaks only happen when an error occurs, so very rarely,
but to silence static analysis tools, we fix a few of them here.
2021-11-10 13:21:19 -05:00
Jacob Boerema f7e327ca05 plug-ins: improve loading of PSD merged images with alpha channel
Handling of PSD merged images with alpha channel but where merged
transparency is not used is complicated.
We check the alpha_names resource for the presence of 'Transparency'. If
that is present, assume we have an alpha channel.
In case of a CMYKA PSD with layers the merged image actually is RGB with
the first three channels representing RGB and the Alpha in the fifth
channel. In this case we move the alpha data to the forth channel so
we can handle it as RGBA.
2021-11-08 22:37:13 -05:00
Daniel Novomesky 1d1234b744 plug-ins: avoid problematic/marginal JXL compression settings 2021-11-06 15:57:49 +00:00
Tomasz Goliński 64c0478b4c plug-ins: Support PSD files in LAB colorspace 2021-11-03 02:40:32 +00:00
Daniel Novomesky 7e549246d8 plug-ins: fix memory leak in HEIF import/export 2021-10-28 19:39:51 +00:00
Daniel Novomesky bc9a26b32c plug-ins: make string translate-able in JXL export 2021-10-28 19:39:51 +00:00
Jacob Boerema b7518195b5 plug-ins: fix incorrect loading of CMYK PSD images without layers.
PSD images using CMYK as color mode and without layers didn't load
correctly (wrong colors).
When a PSD does not have any layers, CMYK color mode was not converted to
RGB.
Note that PSD color images that do have layers (e.g. CMYK and LAB) store
the merged image as RGB!
To do all this we added a conversion for CMYK PSD with 0 layers and added
code to correctly determine whether an alpha channel exists.
This also fixes the case where loading the merged image of a 16 bit per
channel RGBA psd loads with the alpha channel opaque.
2021-10-27 19:17:05 -04:00
Jacob Boerema 5115021eac plug-ins: fix incorrect CMYK transform for the variant without alpha
Probably due to a copy-paste error the case without alpha was also using
the img->cmyk_transform_alpha instead of img->cmyk_transform.
2021-10-26 18:04:34 -04:00
Daniel Novomesky 080d680b7d plug-ins: JXL lossless implies uses_original_profile 2021-10-26 17:10:54 +00:00
Jacob Boerema b27bf5caa9 plug-ins: fix #7429 Error loading PSD file: Unsupported or invalid layer mask height
Our psd plug-in checks for valid layer mask sizes. Apparently a psd
layer mask where the rendered flag is set can have invalid dimensions
0, 0, 0, -1.
We will skip the sanity checks for rendered layers and at the same time
move the debug statements up to have relevant debug info available even
if our sanity checks stop further processing.
2021-10-26 12:28:03 -04: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
Jacob Boerema 641080c838 plug-ins: fix several issues detected by coverity
Detected issues fixed here:
- Use GString and g_string_append since otherwise we need to add g_free
after every g_strconcat.
- No error checking.
- We need to g_free value_utf.

Not detected by coverity:
- Wrong quotes around utf-8.
- Remove unused includes.
2021-10-24 22:14:13 -04:00
Jacob Boerema e90f041ca5 plug-ins: fix resource leaks detected by coverity
Several resource leaks here were detected by coverity:
- Not freeing value_utf.
- Strings returned by g_strconcat should be g_free'd. To handle the string
concatenations easier we use GString and g_string_append instead.
Also introduce function get_list_elements to reduce the number of
repetetive elements.
While we were at it, also remove unused includes.
2021-10-24 22:01:16 -04:00
Jacob Boerema 6eba73e714 plug-ins: fix #7408 metadata-editor plugin cashing when saving metadata
When writing metadata in the metadata-editor it did not check for empty
values. In combination with gexiv2 0.14.0 (which doesn't check in this
specific case for an empty list of gchar **) and trying to set a non
repeatable Iptc tag (Iptc.Application2.Headline) using
gexiv2_metadata_set_tag_multiple we get a crash.

This fix checks first for a non empty value before trying to save the
metadata tag.
Since the code is very similar also implemented this check for the Xmp
tags in addition to the Iptc and simplified some duplicate code.
2021-10-24 13:38:06 -04:00
Jacob Boerema b070c6fba6 plug-ins: Iptc.Application2.Headline is not a repeatable tag
See issue #7408 where this is causing a crash when using gexiv 0.14.0
in combination with trying to save it as a multiple tag with an empty list.
According to https://exiv2.org/iptc.html the tag Iptc.Application2.Headline
is not repeatable so we will set mode to "single.

In addition to that I added comments to explain the differences in the
meaning of "single" and "multi" between the list of Xmp tags and Iptc tags.
2021-10-24 12:53:37 -04:00
Daniel Novomesky 422d5fec8f plug-ins: handle memory allocation failure in JXL import 2021-10-22 10:52:35 +00:00
Jehan 4dcbafc292 plug-ins: fix static analysis warning.
I had completely forgotten about Coverity Scan but today received an
email with some new scan results. This was one of the warnings that we
had a possible resource leak.

In truth, this is mostly a false positive since gimp_export_image() will
flatten the image. Yet why not be thorough…
2021-10-21 11:59:10 +02:00
Ondřej Míchal 01516591f6 plug-ins: Silence some warnings 2021-10-18 09:32:25 +00:00
Jacob Boerema a77131db3c plug-ins: fix #1111 TGA with indexed colors + alpha channel : not displayed correctly
Just like COLOR targa MAPPED (indexed) images with a size of 32 per
index should also have alphaBits set to 8 or else the images get
loaded incorrectly.
2021-10-15 11:57:23 -04:00
Jacob Boerema a637692533 plug-ins: fix loading of only the merged image of a PSD
Loading of the merged image of a PSD was broken as mentioned by Massimo
in MR !476.
Instead of reverting the commit as suggested, we check first if loading
a merged image is requested. In case of an error we add a debug
message and then remove the error without stopping on it.
2021-10-15 11:52:29 -04:00
Jehan 6905b0bbef Issue #5313: consistent "file-pat-save-internal" procedure with…
… multiple drawables as parameter.

Previous commit 7bb892f3 was "making it work" by making the API
inconsistent and also only using the first drawable, which is making the
logics meaningless.

Instead accept multiple drawables, and export only the selected drawable
(when alone) or the merged-down image containing only the selected
drawables (when many).

Note that in current implementation, this is not useful from GUI calls
because the fully merged image is always exported when run interactively
or with last vals (i.e. from the GUI) because gimp_export_image()
flattens the image. So this change would only work when called
non-interactively from other plug-ins. In such a case, multi-layer
images do no longer return an error and whatever items are selected
would change the export result.

See also #7370 for a discussion about how to handle the selected items
during export (because currently the `drawables` parameter of
GimpSaveProcedure's run function is clearly a mostly bogus parameter).
2021-10-15 00:32:10 +02:00
Jehan d47fc1372d plug-ins: fix file-gih.
We currently cannot call gimp_pdb_run_procedure() for procedures
containing arrays because this C-type doesn't contain the size
information (which is in a second parameter but since the rule is not
hard-coded, our API can't know this).

See issue #7369.
2021-10-14 23:33:28 +02:00
Jacob Boerema e574dbe81c plug-ins: fix warning in file-ps: assignment discards 'const' qualifier 2021-10-12 17:17:52 -04:00
Jehan 54bd8c8763 plug-ins: fix coding style from MR !472.
Normally we'd prefer to have the contributor fix their commits directly,
but we had no responses.
2021-10-12 17:52:57 +02:00
Andrzej Hunt 5828e0a12d gif: don't use strlcpy on non-null terminated string
strlcpy() only copies the specified number of bytes, but it also iterates over
the input string in order to return its length. We only populate the first
6 bytes of buf - the rest is uninitialised - hence strlcpy() will iterate
past the 3 bytes that we're trying to compare, and will only return after
reading an effectively random number of bytes (which could well be beyond
the end of buf). Since we ignore strlcpy()'s return value, program flow
is generally not affected (unless we hit a segfault I guess, which is unlikely
because we do 0-initialize some of our stack variables, meaning strlcpy() is
unlikely to go far). However, this iteration is wasteful, and triggers
complaints from code sanitizers.

Therefore we remove the strlcpy,() and switch to doing a strncmp() on just the
3 bytes that we care about (similar to what is done for the "GIF" check above).
This change has the nice benefit of avoiding an unneeded copy.

An example implementation of strlcpy can be found in glib, here's the line
where it iterates until the first NULL byte:
  f763f2b7cb/glib/gstrfuncs.c (L1484)

See also ASAN output from when this was discovered below:

ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffc776e03d0 at pc 0x7f909b615ba2 bp 0x7ffc776e0370 sp 0x7ffc776e0368
READ of size 1 at 0x7ffc776e03d0 thread T0
    #0 0x7f909b615ba1 in g_strlcpy /home/ahunt/git/glib/_build/../glib/gstrfuncs.c:1484:14
    #1 0x55dc5c in load_image /home/ahunt/git/gimp/plug-ins/common/file-gif-load.c:419:3
    #2 0x561f20 in LLVMFuzzerTestOneInput /home/ahunt/git/gimp/plug-ins/common/file-gif-load_fuzzer.c:79:17
    #3 0x460e44 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
    #4 0x46034a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:505:3
    #5 0x462067 in fuzzer::Fuzzer::MutateAndTestOne() /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:745:19
    #6 0x462bf5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:883:5
    #7 0x450ea6 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
    #8 0x47ae82 in main /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #9 0x7f909a564349 in __libc_start_main (/lib64/libc.so.6+0x24349)
    #10 0x424259 in _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120

Address 0x7ffc776e03d0 is located in stack of thread T0 at offset 48 in frame
    #0 0x55d89f in load_image /home/ahunt/git/gimp/plug-ins/common/file-gif-load.c:375

  This frame has 6 object(s):
    [32, 48) 'buf' (line 378) <== Memory access at offset 48 overflows this variable
    [64, 65) 'c' (line 379)
    [80, 848) 'localColorMap' (line 380)
    [976, 980) 'grayScale' (line 381)
    [992, 996) 'version' (line 385)
    [1008, 1016) 'image' (line 386)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/ahunt/git/glib/_build/../glib/gstrfuncs.c:1484:14 in g_strlcpy
Shadow bytes around the buggy address:
  0x10000eed4020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed4030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed4040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed4050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed4060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10000eed4070: 00 00 00 00 f1 f1 f1 f1 00 00[f2]f2 01 f2 00 00
  0x10000eed4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed4090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed40a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed40b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000eed40c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==15243==ABORTING
2021-10-12 17:52:57 +02:00
Andrzej Hunt c4b4363dfd gif: perform bounds checking for table entries
table is specified to have 2 x (1<<12) entries, this in turn is because table
entries are specified to be smaller than (1<<12). Therefore we need to check
that each entry is within the specified range.

Without this check, it's possible to induce a buffer overflow read, see ASAN
output below. However the value that we read is eventually clamped to a
safe range before being returned, hence this overflow seems pretty useless:

==10977==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000010a21c0 at pc 0x00000056187b bp 0x7ffec915c550 sp 0x7ffec915c548
READ of size 4 at 0x0000010a21c0 thread T0
    #0 0x56187a in LZWReadByte /home/ahunt/git/gimp/plug-ins/common/file-gif-load.c:913:19
    #1 0x55fc4d in ReadImage /home/ahunt/git/gimp/plug-ins/common/file-gif-load.c:1183:15
    #2 0x55e447 in load_image /home/ahunt/git/gimp/plug-ins/common/file-gif-load.c
    #3 0x561ef0 in LLVMFuzzerTestOneInput /home/ahunt/git/gimp/plug-ins/common/file-gif-load_fuzzer.c:79:17
    #4 0x460e44 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
    #5 0x46034a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:505:3
    #6 0x462067 in fuzzer::Fuzzer::MutateAndTestOne() /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:745:19
    #7 0x462bf5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:883:5
    #8 0x450ea6 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
    #9 0x47ae82 in main /home/abuild/rpmbuild/BUILD/llvm-12.0.0.src/build/../projects/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #10 0x7f307beb4349 in __libc_start_main (/lib64/libc.so.6+0x24349)
    #11 0x424259 in _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120

0x0000010a21c0 is located 1088 bytes to the right of global variable 'table' defined in 'file-gif-load.c:794:15' (0x1099d80) of size 32768
SUMMARY: AddressSanitizer: global-buffer-overflow /home/ahunt/git/gimp/plug-ins/common/file-gif-load.c:913:19 in LZWReadByte
Shadow bytes around the buggy address:
  0x00008020c3e0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c3f0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c400: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c410: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c420: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
=>0x00008020c430: f9 f9 f9 f9 f9 f9 f9 f9[f9]f9 f9 f9 f9 f9 f9 f9
  0x00008020c440: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c450: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c460: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c470: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x00008020c480: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==10977==ABORTING

( crash-911d5feb07551dd0313d204db4883838139820f5 )
2021-10-12 17:52:57 +02:00
Jehan 52928e04a5 Issue #7327: Cannot build GIMP3 on MSYS2 using Meson.
This is untested on my side, because the bug only happens on native
builds with meson (our CI has cross-builds with meson and native builds
with autotools and I only do cross-builds locally) but I think/hope it
will work.

Basically we were using .full_path() because these rc files were also
used as input of some configure_file() calls which doesn't like custom
target objects as input (it wants strings or file objects). Yet a bug
in meson didn't like the colon used in native Windows full paths ('C:'
and such) when used in windows.compile_resources(). This has been fixed
by Luca Bacci in: https://github.com/mesonbuild/meson/pull/9368
Yet we just cannot depend on very early meson (or worse dev meson code).

On the other hand, if the input is a custom_tgt object, it uses the
object ID which we give as first parameter of custom_target() so we know
it's appropriately named without colons (such as 'gimp_plugins_rc').
Thus we should not bump into this issue again.

For the few usage in configure_file(), I just add a .full_path() only
when needed at call time.

Last but not least, I replace the bogus `meson --version` call by a
`python3 -c 'exit()'` as advised by Eli Schwartz:
2afa019c70 (note_1284951)

The reason is that it is apparently possible (or will be when some
reimplementation of meson will be done) that the `meson` executable
itself does not exist. On the other hand, `python3` should always be
there, as a mandatory dependency of the build tool.

In order to use an appropriate `python3`, I made the
pythonmod.find_installation() check required in our build (which should
not be a problem since it's a meson requirement as well), even when the
-Dpython option is false (this one depends on other requirements too
anyway, such as version and pygobject). This way I can call this meson
variable of discovered python in my bogus call, instead of calling a
(potentially different) python from PATH environment.
2021-10-12 17:06:18 +02: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
Jehan e61adec232 plug-ins: more g_file_get_path() changed to g_file_peek_path().
Also some g_unlink() changed into g_file_delete().

And a g_file_get_path() followed by g_path_get_basename() changed into
g_file_get_basename() only.
2021-10-01 22:59:53 +02:00
Jehan f131780777 plug-ins: clean up warnings from psd-save.
These warnings only happens on debug output, so it's not huge bugs, yet
it's always better not to have warnings at build time.

Most are printf format type warnings, and one is because of uncomplete
switch() cases.
2021-10-01 19:43:49 +02:00
Jehan 4ae3687c88 plug-ins: more replacement of g_file_get_path() to g_file_peek_path().
While doing this cleanup, I found at least several other string leaks
in: file-compressor, file-gegl, file-pdf-save, file-raw-data, file-xwd,
jpeg-load, psd-save…
So it's quite worth it!

Note: in file-pdf-save, there is a global variable file_name which seems
to be happily leaked without caring (didn't look in details, but looks
so). I didn't fix this one which will require a bit more in-depth logics
care.
2021-10-01 19:37:59 +02:00
Jehan 27dea4f7f7 plug-ins: various g_file_get_path() replaced by g_file_peek_path().
As explained in previous commits, the _peek_ call is advantageous
because:
- It is less bug-prone as we don't have to handle freeing the string. In
  all the cases I changed, I even spotted at least 2 cases where we were
  leaking a string (in file-mng, `temp_file_name` is never freed; and we
  were also leaking in an error case of gfig).
- As a consequence of the previous point: simpler code with less lines.
- In local file cases, the _peek_ variant does not even need to allocate
  an additional string.
- In other case, if we query several times the path, it is allocated
  once and cached so it stays efficient.
- When possible, working on the GFile rather than on a path string may
  be more robust. For instance I changed one g_unlink() into a
  g_file_delete(). Actually most reading/writing should be done with the
  GIO API when possible, but I didn't want to change too much code
  logics on this commit.
2021-10-01 18:47:30 +02:00
Jehan 2ddc2ab7be plug-ins: some cleanup in file-webp.
- use g_file_peek_path() instead of g_file_get_path() in various places.
  Less prone to memory management bugs (not forgetting to free in all
  cases). Also it is often more efficient, especially for local files
  where the _peek_ variant does not even need to allocate any memory as
  path is already hanging around (and local files are the most common
  use cases, I believe!).
- Also gets rid of one GFile creation with g_file_new_for_path() from
  the path returned from another GFile! We can just use the same GFile
  as it is not freed and perfectly usable.
2021-10-01 18:47:30 +02:00
Daniel Novomesky ea6bcef360 Fix missing return in file-jpegxl.c 2021-10-01 11:00:03 +00:00
Jehan 545257226a plug-ins: use g_file_peek_path() instead of g_file_get_path().
Freeing the path immediately could lead to a free-after-use error as we
used it for an error message when the file pointer failed to be created,
as reported by Massimo (thanks again!).

Using g_file_peek_path() has also other advantages, such as being less
error-prone, but also possibly more efficient. First looking at the
implementation, for local files, we already have the path around, so no
additional memory allocation even needs to happen. As for the generic
code path, it would still allocate a new string, yet cache it and reuse
it when needed later. This makes the _peek_ call much better for quick
peek-use-discard usage.
2021-10-01 12:20:36 +02:00
Jehan e01c37c3dd plug-ins: fix wrong data freeing.
`filename` was being leaked while `file` was not to be freed yet.

Thanks to Massimo for noticing.
2021-10-01 11:47:27 +02:00
Jehan e213f1f4ef plug-ins: minor styling fixes and other.
- .gitignore and gimprc.common updated by manually running ./mkgen.pl.
- Coding style fixes in file-jpegxl:
  * function names go to the line by themselves (return type on previous
    line).
  * avoid some overlong lines by breaking lines between parameters.
  * fix some alignments.
2021-09-28 11:40:33 +02:00
Daniel Novomesky 878c3f6ce6 Use more specific magic string for JPEG XL container format 2021-09-28 07:25:41 +00:00
Daniel Novomesky 7ce0f2d60e Add JPEG XL plug-in 2021-09-27 09:22:24 +02:00
Jacob Boerema a4cb134f14 plug-ins: fix saving of XMP BAG/SEQ array values in metadata-editor
XMP array tags of type BAG and SEQ can have multiple values, each of
which is on a separate line. However, we were reading and saving it as
just one value.

We change this by setting each line as a separate value with
gexiv2_metadata_set_tag_multiple.

In addition to that we found that setting the type of tag struct with
gexiv2_metadata_set_xmp_tag_struct caused arrays of multiple values per
tag to be set incorrectly: the last value in the list got added multiple
times. I'm not sure if we are using this function incorrectly, or that
there is a bug in gexiv2 or exiv2. Anyway, since it seems that all tags
and values I tested work without calling this function, let's just omit
this call.
2021-09-25 14:54:45 -04:00
Jacob Boerema 76dc649b3f plug-ins: improve loading of XMP BAG/SEQ tags in metadata-editor
XMP array tags of type BAG and SEQ can have multiple values, each of these
values needs to be on a separate line to be correctly recognized as a
different value in the tag array. We were incorrectly loading all values
on one line separated by a comma.
For those tags that have equivalent IPTC tags we were also comparing just
the one XMP value with the whole, possibly multiple lines, of the same
IPTC, which could cause a failure to recognize identical tags.

We changed this to now have each value in a tag array on a separate line
by adding \n between values.
Each IPTC equivalent tag value is now compared to each value in the XMP
tag array and only added when a different value is found.
2021-09-25 14:39:40 -04:00
Jacob Boerema baaa1380cf plug-ins: in metadata-viewer improve how we show XMP tags.
XMP tags that have multiple values (usually of type XMpBag or XmpSeq) were
shown on one line. Which, especially for long text values, could make it
difficult to see the separate values for that tag.

Let's do the same as we do for IPTC tags that can occur multiple times and
show each value on a separate line.
2021-09-24 15:22:49 -04:00
Jacob Boerema e9ab89fa4f plug-ins: use separate function for adding multiple values per tag
In the metadata-viewer refactor the code that adds multiple values per tag
to the list store into a separate function.
Currently used for IPTC tags only but the intention is to reuse it for
XMP tags with multiple values.
2021-09-24 15:14:48 -04:00
Jacob Boerema e7f65e4b9f plug-ins: improve formatting in metadata-viewer 2021-09-24 15:11:03 -04:00
Jacob Boerema d61a682b8b plug-ins: fix #7195 Exporting multilayer TIFF with EXIF saves some layers twice
If you first open a multi page TIFF, exiv2 generates EXIF tags for the
first 3 pages in the form of Exif.Image.<tags>, Exif.Image2.<tags>,
Exif.Image3.<tags>. When exporting with EXIF saving enabled, exiv2 thinks
it needs to save TIFF pages for the EXIF metadata of the second and third
page too. Those pages saved by exiv2 contain only metadata no real image
data and give warnings when loading.

The EXIF tags read from page 2 and 3 are only the basic image specs. We
don't use those, nor do we add tags to it. Until we support handling of
metadata for those pages and exiv2 has better support for all TIFF pages
beyond the first few, I see no reason to save this information.

So for now lets just delete all tags that start with Exif.Image followed
by a number.
2021-08-29 17:12:12 -04:00
Jacob Boerema 42e61104d7 plug-ins: fix #3740 Impossible to delete multi page tiff with thumbnail
On Windows there is a long standing issue in its File Explorer. When
GIMP exported as a multi page (multi-layer) TIFF with thumbnail saving
enabled, then the Windows thumbnailer apparently gets stuck and does not
close the TIFF file when browsing a folder. Because those files are not
closed it is impossible to delete them. This issue has been reported
many times over the years to Microsoft without any reaction.

Investigation showed us that this lock up only happens when we save the
thumbnail as a subifd. To resolve this issue we change this and now let
exiv2 handle our thumbnail saving, just as for other image formats. For
TIFF this means the thumbnail is saved as the second page of a TIFF.

Previous commits have made sure that it is now easier to recognize a TIFF
page as a thumbnail and to make sure we don't load thumbnail TIFF pages.

Since saving as a subifd is what made TIFF thumbnail saving different
from other formats, this commit consists of only removal of code.
2021-08-27 15:36:49 -04:00
Jacob Boerema 2a38ec9e4b plug-ins: when loading TIFF images ignore thumbnail pages
TIFF image pages can specify what type of image that page represents.

If the page is marked as FILETYPE_REDUCEDIMAGE we will consider it to be
a thumbnail and filter that out of the list of pages that can be selected
to be loaded.

In addition to that we will try to recognize certain pages as thumbnail
that don't have the subfiletype tag set.
We will consider it a thumbnail if:
- It's the second page
- PhotometricInterpretation is YCbCr
- Compression is old style jpeg
- First page uses a different compression or PhotometricInterpretation
If these conditions are true the page will also be filtered out.

We could consider having an option whether to filter out thumbnail pages.
Since in the situation up until now we also don't load thumbnails, I think
this should be considered as a separate feature.
2021-08-27 15:36:49 -04:00
Jehan 49e534247a app, libgimp*, pdb, plug-ins: use g_memdup2() instead of g_memdup()
Since it appeared with GLib 2.68.0, we could not change this until we
bumped the dependency which has only become possible a few days ago
(since Debian testing is our baseline for dependency bumps). Cf.
previous commit.

As this is a drop-in replacement (just a guint parameter changed to
gsize to avoid integer overflow), search-and-replace with:

> sed -i 's/g_memdup\>/g_memdup2/g' `grep -rIl 'g_memdup\>' *`

… followed by a few manual alignment tweaks when necessary.

This gets rid of the many deprecation warnings which we had lately when
building with a recent GLib version.
2021-08-26 17:32:09 +02:00
Jacob Boerema 7bb892f3d5 plug-ins: fix #5313 Exporting to "Gimp pattern" i.e. pat format fails
After the change that allows multiple layers to be selected exporting to
a pattern fails.

Patch this as suggested by Lloyd Konneker by doing the same as for brushes:
do not allow multiple layers, instead only send the first drawable.
2021-08-09 16:28:33 -04:00
Jacob Boerema 4f86d8088d plug-ins: fix #2655 Can't open EPS-files with german Umlauts
Due to differences between Windows and most other platforms Ghostscript
didn't correctly load files with special characters on Windows.

First we needed to make sure that the filenames we use are in utf-8
format and then tell gsapi that we use utf8 encoding.
2021-08-08 19:31:40 -04:00
Jacob Boerema d94a0c00af plug-ins: add non interactive support for extra parameters in file-bmp-save
When exporting to bmp using a script or plug-in we could not set the
parameters use-rle, write-color-space-info, and rgb-format when used
non-interactively.

This is discussed in issue #491. The patch there does not work for master,
so I came up with this.
2021-08-05 16:18:36 -04:00
Michael Bazzinotti 4d528f297f Issue #5415: compensate for null byte
When exporting a C source file with runtime length encoding, the
C-string's array size does not accomodate for the null byte. However,
GIMP accomodates for the NULL byte in it's NON-RLE export, suggesting
that this has been a mere oversight for RLE.

This can cause at the worst a compile-time error and at least a warning
from the compiler.
2021-08-05 19:49:55 +02:00
programmer-ceds 6664b31d68 SF-ADJUSTMENT Slider Duplicate Label Fix 2021-08-04 00:23:04 +00:00
Jacob Boerema 2329fc1656 plug-ins: fix #7086 Can't remove color space from a 1bit monochrome palette
For 1-bit BMP export we did not show the save dialog, making it
impossible to change settings interactively.

We enable the save dialog for 1-bit too, making sure to disable RLE, which
is not available for 1-bit.
In addition, also set the RLE config option to false for all cases where
it can't be used.
2021-08-03 15:40:29 -04:00
Jehan 488e3c4a0a plug-ins: use GimpUi.ProcedureDialog() instead of…
… GimpUi.ProcedureDialog.new()
The old way is still working and acceptable as far as I am concerned.
Just switching to the recommended (by upstream) syntax to show it works
as expected and as a good example of code.
2021-08-03 19:54:55 +02:00
Jacob Boerema e0707af073 plug-ins: fix #1146 DICOM with big endian transfer syntax fails to load.
Our plug-in was not correctly handling DICOM images that use big endian
transfer syntax, which is deprecated.

We add support for that here, add a few g_debug statements to make future
debugging easier, and also return an error when we encounter a transfer
syntax that we can't handle instead of blindly continuing.
2021-07-23 14:55:37 -04:00
Jacob Boerema 3733a36d84 plug-ins: add support for planar configuration in DICOM images.
Part 1 of the fix for #1146.

In addition to that we also add some g_debug statements to make it easier
to determine certain image info.
2021-07-23 14:55:37 -04:00
Michael McLaughlin 3b3f34cd22 Issue #6994: Color Noise produces artifacts with highly saturated…
… source colors

Reviewer's (Jehan) note: a git blame shows this is a clear bug
introduced in commit 9d19bf2a3e, which was a cleanup patch, and the
BOUNDS() macro was not doing exactly the same thing as the code before
the change.
2021-07-17 18:58:16 +02:00
Michael Schumacher 7f0dafe571 plug-ins: use #!/usr/bin/env python3 shebang line in python-console.py
Fixes #7035.
2021-07-07 17:47:15 +02:00
Mayank Suman d8062d1d77 plug-in, libgimp: Fixes #6753: redesign of WebP Export dialog
Added an option for exporting thumbnail in WebP Export dialogbox.

Additionally, introduced a function gimp_procedure_dialog_fill_expander.
The function is similar to gimp_procedure_dialog_fill_frame but allows
adding GtkExpander instead of GtkFrame.
2021-06-18 16:42:08 +05:30
Jacob Boerema 1731c875a1 plug-ins: fix the fix for #6116 grayscale gif animation.
I must have not been awake yet when I pushed the
fix for #6116 because it has two problems:
- Updating cur_progress caused by not editing the
  for loop after a copy/paste, found thanks to
  Stanislav Grinkov.
- Not using the correct drawable to determine the
  drawable_type which I noticed while fixing the
  above issue.

These issues are not present in the backported
version for 2.10.
2021-05-31 11:59:58 -04:00
Marie-P c112a55958 libgimp*, plug-ins: fix some warnings 2021-05-24 20:36:31 +00:00
lloyd konneker e57304f71a Issue #5402 Scriptfu handle GFile and GimpObjectArray types 2021-05-24 13:28:50 +00:00
Stanislav Grinkov f8320ce535
core: minor memleak fixes
Fix several memory leaks when uri obtained by g_file_get_uri ()
was not g_free'd ().
2021-05-23 20:57:44 +06:00
Jacob Boerema 3b3ab0aa11 plug-ins: fix #6116 grayscale gif animation hangs on export.
GIF export was not taking into account that there can be
both grayscale layers with and without alpha in an image.

We make sure that the GEGL buffer knows the type of
drawable for the current layer.
2021-05-19 17:38:32 -04:00
Jacob Boerema 016948c482 plug-ins: load 16-bit per sample SGI images as 16 bit integer
We were loading 16-bit per sample SGI images as 8-bit
integer images even though we have had support for
16-bit integer for a long time now.

Changed to use 16-bit integer encoding now. Saw
this request a while ago on the gimp user mailing list.
2021-05-18 18:53:59 -04:00
Jacob Boerema e1fcaaaa0a plug-ins: always stop on error after reading PSD layer block. 2021-05-17 21:27:07 -04:00
Jacob Boerema be20a25ec6 plug-ins: additional layer info in PSD images can have multiple resources.
Instead of only checking for the layer resources Lr16 and Lr32 make it
a loop and use the generic get_layer_resource_header to read all
resources.

We still need to figure out at a later time how to best handle these
resources.
2021-05-17 21:27:07 -04:00
Jacob Boerema d99b87c529 plug-ins: add support for reading Photoshop PSB image files. 2021-05-17 21:27:07 -04:00
Jacob Boerema 35f4b7b517 plug-ins: make PSD resource loading handle 64-bit lengths.
For PSB images certain resources have 64-bit lengths.
Let's handle this transparently by adding a psd_version
parameter and depending on that and the type of
resource we decide if the length to read is 32 or 64-bit.

We also return the total header size. This way the
calling function can use that to determine the
remaining length.

Because we needed to check the signature when
loading the header we remove that check from
the load_layer_resource function since that
would be redundant.
2021-05-17 21:27:06 -04:00
Jacob Boerema 6f523d33dd plug-ins: adjust some psd-load debug statements for 64-bit. 2021-05-17 21:27:06 -04:00
Jacob Boerema 2df0569a50 plug-ins: PSD ChannelLengthInfo data_len should be 64 bit. 2021-05-17 21:27:06 -04:00
Jacob Boerema 0de02a5b2d plug-ins: PSD layer size validation only for "normal" layers.
Apparently layer height or width can be negative for certain
PSD layers that have the irrelevant flag set.

We move those checks down until after we have read that
flag and only validate if the irrelevant flag is not set.
2021-05-17 21:27:06 -04:00
Jacob Boerema f82974a70e plug-ins: in psd-load.c change debug state to 4 for 1 bit conversion details.
Since the 1-bit conversion debug statements causes a huge amount
of info which can cause slowdowns when loading do it only when
explicitly setting it to IFDBG(4).
2021-05-17 21:27:06 -04:00
Jacob Boerema 714052e998 plug-ins: remove outdated comment about GIMP_MAX_IMAGE_SIZE in psd-load.c
GIMP_MAX_IMAGE_SIZE is nowadays 524288.
2021-05-17 21:27:06 -04:00
Jacob Boerema 2e2e43a404 plug-ins: add psd_read_len function
In certain places in a PSB file we need to read 64-bit
lengths where in a PSD we read a 32-bit length.

To make handling this easier we add a function that
determines if we need to read 4 or 8 bytes and 
also handles converting the value from big endian.
2021-05-17 21:27:06 -04:00
Jacob Boerema 0a703115d1 plug-ins: increase MAX_CHANNELS in PSD files to 99.
Even though the current specs say max is 56 there
are sample files with more channels. Since there is
no reason why we can't handle more let's increase
the maximum to 99 for now.
2021-05-17 21:27:06 -04:00
Jacob Boerema 32be0ec709 plug-ins: PSD layer name can be NULL.
Apparently in a PSD a layer name can be NULL which
gimp_item_set_name doesn't like so only use it when
we have a valid layer name.
2021-05-17 21:27:06 -04:00
Jacob Boerema 58183e55c6 plug-ins: store PSD file version in our PSDimage data structure. 2021-05-17 21:27:05 -04:00
Jacob Boerema 82cb11eb54 plug-ins: add extra safety checks in psd-load.
Add some extra check when loading  masks to
detect problems and in some cases try to fix them
by skipping the problematic data.
2021-05-12 17:55:29 -04:00
Jacob Boerema eb78aa994e plug-ins: fix computation of padding in fread_unicode_string. 2021-05-12 17:55:29 -04:00
Jacob Boerema 3da302adce plug-ins: consider reading less bytes than we need an error in psd-util. 2021-05-12 17:55:29 -04:00
Jacob Boerema 670ef6b9a3 plug-ins: fix setting error message in psd-util. 2021-05-12 17:55:29 -04:00
Jacob Boerema 3d248dc66f plug-ins: PSD color block can have a non zero length even when mode is RGB.
Not taking a non zero length into consideration caused us to read from the
wrong location in certain cases and then fail loading.

Always use the specified length to go to the correct location. This is not
a guarantee that we will be able to correctly load the image but at least
we won't read wrong data from the wrong location.
2021-05-12 17:55:28 -04:00
Jacob Boerema 666ae4ecfe plug-ins: don't use G_GSIZE_FORMAT specifier in translatable string in psd-load.
See: 38c0344fa8 (note_1103992)
2021-05-12 17:55:28 -04:00
Jehan 9b033f8996 plug-ins: fix creating multiple preview display for JPEG export.
Commit aba721ae68 fixed its intended bug but brought a new: each time
the preview was updated, a new display was created. This fixes this new
bug. Hopefully it's good now!
2021-05-12 22:46:52 +02:00
Jacob Boerema 38c0344fa8 plug-ins: fix #5944 Unable to open XCF converted PSD files
in Gimp and Photoshop- "Too many channels in layer: 4907"

To be better able to handle 64 bit offsets we switch to
using GInputStream/GOutputStream and its related
functions instead of using FILE functions like fseek.

In addition we changed several offsets and sizes to
64 bit instead of 32 bit to correctly handle large
image sizes and offsets.

I should probably have split this out in two parts
(the move to GInput/OutputStream, and the
changing to 64 bit variables) but don't feel like
it's worth the trouble at this point.
2021-05-11 12:34:41 -04:00
Jacob Boerema 8fdeaddbe7 plug-ins: fix using wrong offset for group layer masks in psd export.
Exporting to psd could result in very large files which often failed to
load in both GIMP and PS when a group layer with a layer mask
was present.

Reported on our IRC channel with a sample xcf which made it
possible to figure out the problem.
2021-05-04 15:48:34 -04:00
Jehan 4f1007edbc Issue #6695: Wrong tab after JPG export because of "Show preview"…
… feature.
Using the new gimp_display_present() function in file-jpeg to make sure
the original display is back to the top.
2021-04-30 03:51:21 +02:00
Jehan aba721ae68 Issue #6280: JPEG preview window doesn't get closed.
The port had a slight error, because in gimp-2-10, the display_ID
actually had 3 states: 0 when gimp_export_image() kept the original
image to which we just add a preview layer, -1 when it created a new
image which we wanted to put in its own display, and the display ID
itself when created.

With the new API where display variable is an object, we can only have 2
cases. So I create an additional variable separate_display to make the
distinction.
2021-04-30 01:35:51 +02:00
Jacob Boerema fe228a6f6f plug-ins: fix #5960 Gimp loads 16 bit DDS images with luminosity as 8 bit.
So far all dds images were loaded as 8 bit per channel which makes
sense for most but not all dds formats.

This commit implements loading in 16 bit for "L16" - a 16 bit
luminance channel.

In addition to that we improve security a bit  by not assuming
that L16 is the only left over case but instead explicitly
checking the correct value of rmask for L16.

For other cases we now set an error with enough details
to identify the type of DDS image that needs extra
handling.
2021-04-26 17:35:04 -04:00
Jehan ef2402bf8e app, libgimp, pdb, plug-ins: allow pasting multiple full layers.
When a selection exists, we are copying then pasting the selection
contents. In particular, with multi-layer selection, it means pasting a
merged result of the selected layers (like a sample merged but limited
to selected layers).

Yet when no selection exists, with a single layer selected, a cut in
particular would remove the layer fully, then a paste would copy it
elsewhere (in the same image or even on a different image). This was
still working, but not with multiple layers. This is now fixed and we
can now copy/cut then paste several layers (without merge), which is
sometimes a very practical way to move layers (sometimes simpler than
drag'n drop, especially between images).

As a consequence, the PDB function gimp_edit_paste() now also returns an
array of layers (not a single layer).
2021-04-24 23:22:58 +02:00
Jacob Boerema 165b50abcc plug-ins:fix #6624 metadata viewer default window size is too small
Let's increase the default size of the metadata viewer a bit.
Ideally we would add some logic to determine the width of
the first column since that one currently depends on the
length of the longest tag. However for now this change
will be enough for most cases.
2021-04-24 12:45:52 -04:00
Jacob Boerema ed35579861 script-fu: fix #6741 Round Corners script fails to work on layer masks
The round corners script was assuming that the drawable always
was a layer, which is incorrect when a layer mask is selected.

We fix this by always requesting the active layer instead of
active drawable.

We also enable this script for RGB and GRAY with alpha
channel. Although it might not always make sense to
use this script when an alpha channel is present, there
can be use cases where it is perfectly fine.

So let the designer decide if this script is suited or not
instead of GIMP making that judgement.
2021-04-24 12:41:41 -04:00
Jehan 69fdcf5d3f plug-ins: use g_mkdir() for generic cross-platform code.
This fixes the following error when building for Windows:

> error: too many arguments to function ‘mkdir’

On Windows, mkdir() is deprecated, it is an alias for _mkdir() which
doesn't have a mode parameter. The GLib version duplicates the POSIX
signature and is cross-platform (mode is simply ignored on Windows).
2021-04-24 17:03:43 +02:00
saul 11906fa82c plug-ins: Add 'dir-make' procedure to Script-fu.
Closes: GNOME/gimp#541

Reviewer note: thanks to Stanislav Grinkov for cleaning up and reworking
a bit the patch, such as renaming the procedure to dir-make, as per
Kevin Cozens' review.
2021-04-24 15:09:24 +02:00
Jacob Boerema cad6273fed plug-ins: fix #6755 DDS RGB10A2 has Red and Blue swapped.
Looking at the documentation it is indeed red that should go
in the lowest bits and blue in the highest bits so just
reverse our code for red and blue.

We also update the version of our GIMP DDS plug-in,
this way we can catch and correct RGB10A2 images
written by older versions of our plug-in and correct
them.
2021-04-23 14:31:50 -04:00
bootchk 877d585271 Partial fix 5426. Lets old scriptfu script call old name gimp-image-is-valid,
mapped to new PDB procedure gimp-image-id-is-valid (same signature), for example.

Edit a few comments in new code.

Style changes, no logic change.
2021-04-22 11:27:22 -04:00
bootchk 34150ddda7 Use g_logging and migrate functions for author's errors to separate source file.
Eliminate conditional compile for debugging.
2021-04-22 11:01:43 -04:00
Jacob Boerema 6ec20e6ed0 plug-ins: adapt file-openraster to API changes.
I only fixed the changes that made it fail.
I have not updated it to the sensitivity API.
2021-04-21 13:04:46 -04:00
Jehan 65e10faf50 plug-ins: change non-existing brush.
Fixes:
> Calling error for procedure 'gimp-brush-get-pixels':
> Brush 'Circle (03)' not found

The data/brushes/Circle-3.vbr brush doesn't exist since commit
7aa12175a4 in 2012 as far as I can see.
2021-04-21 17:50:24 +02:00
Jehan 2a1555b082 plug-ins: fix spyro-plus.
- Now using multi-drawable run() signature, but sensitive only with a
  single drawable.
- width|height() calls are now get_width|height().
- PDB call to 'plug-in-sel2path' now expects a drawable array as well.
2021-04-20 22:17:28 +02:00
bootchk e960f1a296 Fix #5915, Python Console Apply button fail. 2021-04-20 16:03:05 +00:00
Jehan fb84b9eba7 plug-ins: fix a bunch of Scheme scripts after API functions renaming.
Since we renamed a bunch of functions for consistency (the like of
gimp_image_width() to gimp_image_get_width() and others), most Scheme
scripts ended up broken. This is a simple bash fix with `sed` to at
least take care of these simple renaming cases.

Many scripts are still broken for other reasons after our API evolution
(to be continued).
2021-04-20 17:47:11 +02:00
Jehan 077f2d4e25 plug-ins: remove now useless/ugly workaround.
See previous commit.
2021-04-20 17:16:32 +02:00
Jehan f15d16150e plug-ins: update foggify to latest API and add a GUI.
The following changes were made:
- run() signature now moved to multi-drawables.
- sensitivity mask now enables the plug-in when one or several drawables
  are selected. When several, a fog layer will be created over each
  selected layer.
- Mnemonics added to properties.
- Color property finally used now that our API has support for boxed
  parameters with GimpRGB value type.
- Use a config object instead of ordered GimpValueArray and use the
  begin|en_run() API to store values between runs.
- Add a graphical interface generated with the new GimpProcedureDialog
  API.
2021-04-20 16:54:40 +02:00
Jehan 623ce4a9e3 plug-ins: move benchmark-foreground-extract to gimp-data-extras.
We did port it to the new API but we are doubting it is useful at all.
It might have been, historically, when foreground extract algorithm was
first introduced, but probably not anymore, even more as the algorithm
is now implemented mostly on GEGL side anyway. So if any benchmark were
to be done, it should probably be added as GEGL tests.

Also as we are planning to update even more the API lately, it feels
really like a waste of time to also fix this plug-in while we currently
believe it to be useless.

Still we move it to the gimp-data-extras repository for being able to
easily bring it back in case we missed some use.
2021-04-19 18:10:54 +02:00
Lloyd Konneker 5cb51e096a Fix issue #6577 : scriptfu hang on select dialog on Mac
(cherry picked from commit 7b0df6f04a)
2021-04-19 16:31:33 +02:00
Jacob Boerema 48ff5313c3 plug-ins: fix #6723 Unable to open DDS files.
This is the same as what we did for #5357
but in the reverse situation. The reason
for not doing the same at that time was
because I wasn't sure if that was valid
in all cases.

Looking at the documentation it does seem
to be the right solution and is working for
the supplied example image.
2021-04-14 13:37:22 -04: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 2f46dfb354 plug-ins: use gimp_procedure_dialog_set_sensitive().
In PNG, JPEG and TIFF export plug-ins which use the new API, use our new
function to set widget sensitivity.

Note that part of it is similar to commit 6a2910bd3b on `gimp-2-10`,
making "Save GeoTIFF data" checkbox insensitive when there are no such
data available (this feature was late on the main branch as we rushed
for 2.10.24 release).
2021-04-06 21:52:33 +02:00
Jehan df723aca28 plug-ins: use GimpChannelOps in gfig rather than using a custom…
… SelectionType enum which lists anyway the same.

Fixes various warnings:

> warning: implicit conversion from ‘SelectionType’ to ‘GimpChannelOps’
2021-04-06 17:27:08 +02: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
Jehan fa16152757 app, libgimp, pdb, plug-ins: update some more functions to get|set().
s/gimp_image_base_type/gimp_image_get_base_type/
s/gimp_image_width/gimp_image_get_width/
s/gimp_image_height/gimp_image_get_height/

Sorry plug-in developers, more porting work! But really this seems like
the right thing to do in order not to get stuck with inconsistent naming
for many more years to come.
2021-04-06 00:49:07 +02:00
Jehan d659bb128d plug-ins: store last used values for QBist with new plug-in API.
This allows last used values to survive the GIMP session.

Alternatively this allows to close !424 as this was the last usage of
PATH_MAX.
2021-04-06 00:15:32 +02:00
Jehan cd3333c6d3 meson, configure, plug-ins: image/x-sun-raster is a supported MimeTypes.
Also ".sun" is a possible (and common) file name extension for Sun
Raster images, according to various sources and samples I found (these
samples with .sun extension also opened fine in GIMP, so it's not just a
subvariant which we may not handle or something of the sort). This one
is not so important though as we also register magic bytes for detection
(which is the proper way), but it can still be useful, mostly for
exporting (as we will direct to the SunRaster plug-in if someone tried
to export a file with .sun extension, since no other file format uses
this extension AFAICS).

There is no functional change, I just had a look at this plug-in while
handling !428 and realized this format was not present in the MimeType
list (which is used to generate the desktop file, in order to have
proper mime types, not detection based on extension only, unlike
Windows in !428).
2021-04-04 16:01:58 +02:00
Jehan 931b9fb539 plug-ins: fix all remaining GimpImageProcedure to new run() API. 2021-04-04 01:40:00 +02:00
Jehan 79e608694e plug-ins: fix many GimpImageProcedure to new run() API.
No logics change so far.
2021-04-04 01:40:00 +02:00
Jacob Boerema 5d14c59d2e plug-ins: fix incorrect saving of Iptc.Application2.Caption in metadata-editor.
The saved value for Iptc.Application2.Caption is copied from Xmp.dc.description.
However the last one is multiline but the former should be single line. This
caused only the first line to be saved instead of all lines.

To fix this we set Iptc.Application2.Caption to single and use a different
conversion based on whether the tags from Xmp and Iptc are both
multiline or whether Iptc is single line.
2021-03-24 12:51:59 -04:00
Jehan 708f075f80 plug-ins: make the applied pattern in qbist a bit more prominent.
The qbist plug-in shows a grid of 9 patterns, it was not clear at all
which one will be applied. Also it looked like selecting a pattern would
make it disappear and loading a same file twice would not create the
same patterns (as said in commit 7fb696206e).

Actually the plug-in works fine, but it is simply not clear at all what
is happening until we look at the code. The center pattern is the main
one: the one which will be applied and the only one which will be stored
or loaded in/from a file if we decide to save the pattern. Also when
selecting a pattern, it does not disappear, it is moved to the center
(but you don't necessarily realize it, especially as several will look
the same). And the reason why you get different result when loading a
saved pattern is that it only reimports the center pattern; all others
are indeed randomized from this stable source.

So my fix is attempting to have this center pattern standing out a bit
more by framing it with a "Pattern" title. It's not perfect, and I'm not
very happy with this design, but I don't find a nice widget for better
framing the center pattern, nor do I want to spend too much time on
this. It's better than before at least.
2021-03-24 01:03:44 +01:00
Jehan 8396fc5022 plug-ins: tweak the pattern preview size relatively to the scale ratio.
Avoiding having tiny preview areas on displays with bigger scale ratio.
2021-03-23 23:40:01 +01:00
Jacob Boerema 93f591931b plug-ins: fix incorrect values for ModelReleaseStatus and PropertyReleaseStatus.
While testing the metadata-editor I noticed that certain values for 
ModelReleaseStatus and PropertyReleaseStatus were incorrectly
read back.

Apparently while copy pasting some values were forgotten to be
updated which caused incorrect values to be saved.

There probably are not many users of these metadata tags
since in all these years there hasn't been a bug report about this.
2021-03-23 16:44:02 -04:00
Jacob Boerema 0a902456ac plug-ins: Do not write to Iptc.Application2.DateCreated if no date was set.
The metadata-editor allowed Iptc tags to be set if an empty string was
used contrary to Xmp tags. In the case of DateCreated this cause an
invalid date "0-00-00" to be written.

We added a check to only write text Iptc metadata if the value is
not empty.
2021-03-23 15:24:07 -04:00
Jacob Boerema a229454915 plug-ins: Do not write empty ModelReleaseStatus and DigitalSourceType.
Fixes issue #3656 Empty metadata tags are written to XCF at least.

Xmp.plus.ModelReleaseStatus and Xmp.iptcExt.DigitalSourceType are
defined as combo boxes with a fixed number of possible values.
However there was no option to leave it empty so there always was
a value written when saving metadata in the metadata-editor.

We added a "select value" as default option and only write
metadata if a different value was chosen.

As a bonus we replaced the fixed loop numbers with
the current actual number of defined choices.
2021-03-23 15:24:07 -04:00
Jehan 7fb696206e plug-ins: fix crash of qbist when loading files.
Contents of these arrays are assumed to be limited to a specific range.
While it did work sometimes (because a further processing would randomly
regenerate some of the indexes and correctly limit the range), it often
crashed.

This commit fixes the crash, but I am not sure this plug-in is working
exactly as expected regarding data load/save. It feels like you would
expect to always get the same patterns with a same source data. Yet
there is further randomization going on.

Oppositely when saving data, and re-loading it later, I would expect
once again to get back the exact same patterns I had when saving the
data. So it would be a way to save the result of randomization (as
chances to get back a pattern one liked are slim by definition when it's
created randomly).

Right now, it doesn't behave at all like this. Files are only used as
some kind of random seed, not as a way to save/load patterns. I feel
this was not the purpose of the file handling here.
2021-03-23 19:36:43 +01:00
Jacob Boerema 34463786b1 plug-ins: interpret Exif.Photo.UserComment before showing in metadata-viewer. 2021-03-22 16:07:13 -04:00
Jacob Boerema a95371c2b0 plug-ins: in metadata-editor use /iptcExt instead of /Iptc4xmpExt when saving.
We need to work around an issue in Exiv2 that saving to /Iptc4xmpExt bag
records fails which seems related to it registering /iptcExt. Unregistering
that and registering the first one doesn't work.
See: https://gitlab.gnome.org/GNOME/gexiv2/-/issues/24

So let's use /iptcExt for saving even though it's the less common form
for now. When loading metadata we try to load the most common
form first and if that fails we will load /iptcExt.
2021-03-15 20:49:39 -04:00
Jacob Boerema d00fe2bfe2 plug-ins: set most common CreatorContactInfo last in metadata-editor.
Set Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:* last since the short
form Xmp.iptc.Ci* could have been used to set this information too.

Becausethe first (longer) form is the most common let that override the
shorter form in the (unlikely) case that both are present and also have
different values.

Due to a bug in the metadata-editor previously only the short form
was saved.
2021-03-14 19:19:09 -04:00
Jacob Boerema 184b803811 plug-ins: fix several memory leaks in metadata-editor. 2021-03-14 18:32:09 -04:00
Jacob Boerema f04b84cb39 plug-ins: fix using incorrect structs and fields in metadata-editor. 2021-03-14 18:07:46 -04:00
Jacob Boerema 4609def72f plug-ins: more refactoring of duplicate code in metadata-editor.
Reordered the strings in artworkorobject to be in the same
order as the columns.
Add write_metadata_tag_multiple function that handles most
of the previously duplicated code and check for special
handling of phonetype when necessary by adding
an enum and a get_phonetype function.
2021-03-12 22:05:52 -05:00
Jacob Boerema 9c2451d813 plug-ins: refactor writing single metadata tag in metadata-editor.
Use a separate function that can be reused and also get rid of
the large output_data array and strcat without length
checking. We will use GString instead.
2021-03-12 22:05:52 -05:00
Jacob Boerema 87763cbe27 plug-ins: remove use of strcpy without length checking in metadata-editor. 2021-03-12 22:05:52 -05:00
Jacob Boerema c2fa21ac7d plug-ins: remove use of global tagdata array in metadata-editor.
This removes some flawfinder warnings by not using a fixed
size array and using g_snprintf instead of g_sprintf and
using more safety checks.
2021-03-12 22:05:52 -05:00
Jacob Boerema 0a0eeac1ad plug-ins: more refactoring of metadata-editor.
There was a lot of duplicate code based on
whether or not value was NULL with for
some tags partially unreachable code.

We combine the parts and only test
value for NULL where needed.

Also rename the typos in enum
COL_REGSITRY_* to
COL_REGISTRY_*
2021-03-12 22:05:52 -05:00
Jacob Boerema e24a6dc8d6 plug-ins: refactor metadata-editor adding values to gui.
There's a lot of duplicate code for adding string values
to the gui (liststore). This is another part of trying
to reduce that.
Besides that the copying code uses fixed size arrays
without length checking as pointed out by flawfinder.

We will instead use a function add_to_store to add a
comma or semicolon separated list of values stored in
value to add rows with values to the gui.
2021-03-12 22:05:52 -05:00
Jacob Boerema fd2aa645af plug-ins: be a little more forgiving loading g3 fax images.
Only count a broken line once and only stop after at
least 10 consecutive broken lines since older fax
images are known for having bad lines.

This enables loading the image in issues #475.
2021-03-05 14:13:37 -05:00
Jacob Boerema 1edd114834 plug-ins: improve error handling when loading g3 fax images.
Fixes issue #475 Loading a fuzzed .g3 file fails.
2021-03-05 14:13:37 -05:00
Jacob Boerema 441631322b plug-ins, TIFF: Oops, forgot to save formatting fixes before committing. 2021-03-04 15:23:29 -05:00
Jacob Boerema a79aac687b plug-ins, TIFF: Don't try to load image with bit depth we can't handle. 2021-03-04 12:45:18 -05:00
Jacob Boerema a6d4ef8b94 plug-ins, TIFF: improve loading of miniswhite/minisblack images.
- Miniswhite and Minisblack TIFF images with bps 1, 2 and 4 were loaded as
indexed. We change this to grayscale since that's what they are.
- Fix not handling of miniswhite for 8 bps.

Fixes issue #1838 Tiff image display wrong (tiff tags not interpreted), black
line instead of white line.
Fixes issue #2680 Failure to load 4-bit grayscale TIFF layers.
2021-03-04 12:45:18 -05:00
Jacob Boerema 20cedd4c0c plug-ins: improve a few error messages and allow translating.
Improved and added a few error messages and made all
user visible messages (g_message) translatable.
2021-03-02 17:11:52 -05:00
Jacob Boerema 2ff9ccf46c plug-ins: add more safety checks when loading a TIFF image.
Testing some fuzzed TIFF images from the imagetestsuite
revealed we should add some more checks for valid input
and function returns.

We now stop whenever the reported bps is above 64.
Even if it is valid we can't handle it anyway and I'm not
aware of any actual valid image like that.

Make sure the image dimensions are valid and in the range
that GIMP can handle.

Return directly when TIFFReadRGBAImage fails instead
of doing further processing and improve the error message.

Check result of TIFFReadTile and return if it fails.
2021-03-02 17:11:52 -05:00
Jacob Boerema 97739af643 plug-ins: libtiff warnings can cause a crash on Windows.
Certain broken tiff fax images can cause a huge amount of warnings
which on Windows eventually causes GIMP to run out of resources
and then crash.

Since the avarage user won't have much use for these warnings
let's just only send them to stderr.
2021-03-02 17:11:52 -05:00
Jehan f0a8c0c3f5 plug-ins: also generate grayscale color profiles from gAMA/cHRM chunks.
The PNG specs says:
> The cHRM chunk is allowed in all PNG datastreams, although it is of
little value for greyscale images.

Though it doesn't say it's completely useless though. So let's still
extract the info and give it to Little-CMS.
As for the gAMA chunk, it doesn't say it's not usable for grayscale
images.

Note that if one of the 2 values is not set, it will use default values
for sRGB (i.e. default simili-sRGB gamma or d65 whitepoint). Not sure if
this is totally right.

See also issue #6501.
2021-03-02 12:02:23 +01:00
luz paz 6457394069 Issue #6446: Typo fixes. 2021-02-24 12:33:03 +01:00
Jehan 72d1f9cb6d plug-ins: get rid of gimp_image_(s|g)et_active_layer().
No more usage of the single active layer concept in existing plug-in
code.
2021-02-24 12:09:15 +01:00
Jehan 0f0e63fff3 plug-ins: multi-layer support in PSD load/export.
- Store the Layer ID (lyid) block. Use GIMP's layer tattoo as a PSD
  layer ID, hence mirroring PSD load processing (we were already reading
  this block into our layer tattoos but always exporting with no ID).
- Add support for the Layer Selection ID(s) block (0x042D) both on
  import and export in order to store and restore the multi-layer
  selection.
  We were previously using the Layer state information block (0x0400) to
  store the active layer, but it doesn't seem to be usable for multiple
  layer selection. Actually it is even doubtful if this was working fine
  even for single layer selection but I can't be sure (I could only test
  in non-Photoshop software available to me). So the new logics is:
  * If more than 1 layer is selected, store only the Layer Selection
    ID(s) block.
  * If exactly 1 layer is selected, store both the Layer Selection ID(s)
    and Layer state information blocks.
  * Otherwise (no layers selected) do not store any of these blocks.
2021-02-24 02:03:28 +01:00