Commit Graph

9061 Commits

Author SHA1 Message Date
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