Commit Graph

9004 Commits

Author SHA1 Message Date
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
Niels De Graef dffab0e9a4 Remove GimpInt16Array
It isn't being used by any plug-in or any code in GIMP at all even.
Let's get rid of it while we can still break API, so we can cut down on
all the complexity of the gimp-param stuff a bit.
2021-02-18 11:32:45 +00:00
Jehan e88107153c plug-ins: improve a bit PDF export progression.
Subdivise progression steps inside layer groups.

It is not perfect yet as it would not handle perfectly weird edge cases
where you have for instance a lot of layers in a top layer group with
only many other top layers. But it would still handle it better than
before. Ideally we should simply count all non-group "leaf" layers in
the layer tree and use this as the number of steps. In other words, we
should do a first pass through the whole layer tree.
2021-02-15 22:30:30 +01:00
William Ferguson 636eb02edc plug-ins: update darktable lua script to API change in darktable master
The Lua API is undergoing changes in darktable master. I've fixed the lua-scripts repository as I've made
changes, but I forgot about the collateral damage.

Attached is a fixed version of file-darktable-export-on-exit.lua which should be good for darktable 3.6 and
beyond.

Fixes #6421
2021-02-15 17:11:32 +00:00
Jehan 6b281e8f00 plug-ins: add progression to PDF exporting.
PDF exporting had no progression. In particular when exporting a PDF
with more a hundred pages today, it took maybe 20 secs without any
progression status, which is annoying.

Limitations:
1. When exporting as multi-images, we reset to 0 at each image. I am
   actually not sure if this is the expected behavior.
2. I am updating the progression per top layer, not doing finer grained
   progression steps. An extreme case would be a single top layer group
   with many children layers inside. Yet I wanted to avoid too much
   progression updates for the normal cases.
2021-02-15 00:03:03 +01:00
Jacob Boerema d8009a000b plug-ins: Remove gamma parameter in openraster call to file-png-save.
Commit d57eafd189 removed the
gamma parameter for file-png-save so we have to remove it here too.
2021-01-30 13:18:50 -05:00
Jehan 63d6d770c4 plug-ins: replace gimp_parasite_data*() with gimp_parasite_get_data().
Similarly to the previous commit, it is not only about using the new
API. I also make sure we do not assume that parasite data is
nul-terminated. In many places, we were just assuming so because these
were supposed to be parasite our code set. Yet these are data input
contained in files which can be wrong for any reason (corrupted file,
bugs, other scripts/plug-ins editing these parasites…). So instead of
assuming string parasites are always correctly formatted, I make sure
they are nul-terminated by passing them through g_strndup() when
necessary.
2021-01-30 00:20:34 +01:00
Jehan d57eafd189 plug-ins: gAMA chunk export is now a redundant option.
Now when a gAMA chunk is set on an imported PNG (and if there is no
profile attached), an equivalent profile is created out of the gAMA
chunk. So the displayed image looks like it is supposed to.
On export, the generated profile should simply be saved together in the
PNG file. If not, the sRGB chunk is set anyway (and also an equivalent
gAMA/cHRM as recommended in the specs).

So basically we now have a proper support of the gAMA chunk, from import
to export, and display within GIMP takes this metadata into account
appropriately (in the shape of a generated equivalent profile).
Therefore it looks to me keeping the option is redundant. It is even
confusing (because it's actually hard to understand exactly what this
data is about, even our documentation about this metadata seems to be
wrong) hence possibly dangerous if someone thinks it is important,
checks the box, which would override other data or simply create
irrelevant or contradictory metadata.

So let's just remove this option. Development releases are the right
places anyway for people to notice this change and come to us if we
missed some usage regarding this option.
See also #5363.
2021-01-29 20:06:03 +01:00
Jacob Boerema 4686363606 plug-ins: disable progress updates in file-png in non interactive mode.
The openraster plug-in uses the png plug-in in non interactive mode
to load and save layers. With a lot of layers we get a lot of
flashing popups because of the progress dialogs.

When it is called in non interactive mode there should not
be a need for progress dialogs so let's disable them in
that case.
2021-01-27 19:07:52 -05:00
Jacob Boerema d87cd48f02 plug-ins: check for run_procedure SUCCESS in openraster
The Openraster plug-in calls file-png-load and
gimp-file-load-layer but didn't check if the result
was SUCCESS. Even though I haven't seen any
failures let's improve error checking by adding
a check for a correct result.
2021-01-27 19:07:51 -05:00
Jacob Boerema 9a19cf3b81 plug-ins: add missing parameters to file-png-save in openraster save_ora 2021-01-27 19:07:51 -05:00
Jacob Boerema 9d9f6e6240 plug-ins: add progress updates to openraster load and save.
Since openraster load and save is not very fast for multi layer
images it seems like a good idea to add progress update
support.
2021-01-27 19:07:51 -05:00
Jacob Boerema 6d6b7e90c2 plug-ins: improve exporting of layer modes for openraster.
The current openraster specification only has a limited
number of layer modes. Let's improve things a little bit
by mapping both the current and legacy layer modes
to the same openraster composite-op where available.

For the other layer modes we could examine what the
closest composite-op is, or add a GIMP specific op
(which is what Krita seems to do). For now we set
all these to the openraster equivalent of NORMAL.
2021-01-27 19:07:51 -05:00
Jacob Boerema 304c7d6bc8 plug-ins: don't use the legacy layer modes in openraster load/save
Let's use the non legacy layer modes when importing/exporting
openraster images. That way we are more likely to be able to
import the correct layer modes since openraster only has a
limited number of layer modes defined.
2021-01-27 19:07:51 -05:00
Jacob Boerema 7650767ad3 plug-ins: loading and saving of group layers failed in openraster plug-in. 2021-01-27 19:07:51 -05:00
Jacob Boerema d001e4b38b Issue #5984 file-openraster-save throws CRITICAL at Gimp.ObjectArray.new() 2021-01-27 19:07:51 -05:00
Stanislav Grinkov 926eb43716 plug-ins: #5896. add option for reversing order of layers when importing PDF
This feature adds new 'Load in reverse order' toggle box to allow
selection of order of PDF pages before importing them as a layers or
images.

Adds new bool parameter 'reverse-order' to Non-interactive mode.
Order of parameters was also changed from (password, n-pages, pages)
to (password, reverse-order, n-pages, pages)
2021-01-22 10:44:06 +00:00
Stanislav Grinkov a55cab8f80 plugins: feature #449 allow fract DPI values when importing PDF
This commit fixes the issue when requested page width/height was
not honored because DPI resolution value was constrained to whole
integer numbers only.
2021-01-18 19:27:08 +00:00
Jehan d21911ebfc Issue #3265: PNG gAMA chunk is silently ignored.
PNG has support for profiles, which is the state-of-the-art way to
handle color management nowadays. But it also had some very basic color
management based on a gAMA chunk (for the gamma) and a cHRM chunk
(primary chromaticities).
We don't have a core concept with just these and don't want to walk
backward anyway, but we can easily make basic RGB profiles from these.
This is what this commit is about. It generates profiles at import which
were not actually inside the image, but only represented by these 2 PNG
chunks. What gives it away is that GIMP will propose to convert/keep the
profile at start (unless configured otherwise, as any profile), and the
profile name will specify it is a profile generated from PNG chunks'
values.  One can even discard the profile later (if you didn't convert),
so it gives a solution if somehow these metadata were not proper.
2021-01-18 16:16:56 +01:00
Jehan 7465b0782a plug-ins: more debugging data in file-darktable.
darktable GUI is "mangled" when opened from GIMP for a reporter. There
was already some debug info outputted (when running with DARKTABLE_DEBUG
environment variable). Adding the environment list (and some separation
titles to make it easier to distinguish what is what). Hopefully it will
help debugging.
See #6195 and https://github.com/darktable-org/darktable/issues/7402
2021-01-18 14:37:02 +01:00
Daniel Novomesky 6ca6a8d239 HEIF plug-in: ensure max quality for lossless encoding
There is a possible bug in libheif. Lossless setting is not working
when AVIF is saved via rav1e encoder.
This is a workaround of the problem.
2021-01-18 10:54:09 +00:00