Commit Graph

18 Commits

Author SHA1 Message Date
Jehan 231ca0c505 Issue #9994: do not call g_file_info_get_is_hidden() (and others) directly.
This is not the main reason for the specific output in #9994. These ones are
more probably because of similar usage in GTK (which updated its own calls to
g_file_info_get_is_hidden|backup() in version 3.24.38). But we should likely
also update the various calls we have to use the generic
g_file_info_get_attribute_*() variants.

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

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

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

Even though it also says just after:

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

Which is very contradictory. But assuming that this error warning was
over-zealous documentation, I kept the direct accessors since they are supposed
to be slightly more optimized (still according to in-code documentation) so
let's priorize them when we know they are set for sure.
2023-09-19 15:34:48 +02:00
Jehan fb1f16d4b8 plug-ins: fix a crash in tiff_io_error().
I had a TIFF file which would crash while triggering an error, inside g_logv()
code (and according to the stacktrace, even probably inside some lower level
printf implementation code).

The reason was that I already processed the variable list with
g_strdup_vprintf() and printf didn't like this va_list being reused, then
segfaulted with some "Cannot access memory at address" error.

The alternate fix was to first copy the va_list in the first use with
va_copy()/G_VA_COPY, yet since we already processed the format data, I thought
it was useless to do this. Let's just directly use the formatted string.
2023-02-10 19:28:19 +01:00
Jacob Boerema 0ad54f863a plug-ins: fix #8467 "incorrect value RichTIFFIPTC" when loading TIFF ...
created by Adobe Lightroom 5.1

Adobe products are known to write incorrect RichTIFFIPTC tags in TIFF
images.

Since libtiff correctly detects and handles this there is no real need
for end users to be warned. So instead of a warning we will only output
a message to stderr.
2022-08-23 17:27:18 -04:00
Jacob Boerema ac5a6e56b7 plug-ins: fix TIFF warnings about unknown tags not filtered out anymore
Due to a change in the format string in libtiff, warnings about unknown
fields were not filtered out anymore.

Adjust our filtering of warning messages so we catch this again since
end-users don't need to worry about this and we don't need the
possible extra issues.
2022-08-23 17:27:17 -04: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 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
Ruthra Kumar b67ca557f0 Issue #5691: Import/Export of GeoTIFF loses important header tags.
file-tiff plugin can read and write GeoTIFF tags
New checkbox 'Save GeoTIFF data' has been added to Export dialog.

Signed-off-by: Ruthra Kumar <ruthrab@gmail.com>
2020-11-01 13:12:37 +01:00
Sabri Ünal 93a0b640d2 CID 228074: Missing varargs init or cleanup in file-tiff-io.c
missing va_end: va_end was not called for ap_test.

(cherry picked from commit a7a18cc83f)
2019-10-20 14:27:53 +02:00
Jehan de866d8815 plug-ins: get rid of compilation warning.
Note that I am using twice TIFFErrorHandler type. This is because
TIFFWarningHandler does not exist, despite what the docs says and
upstream code actually uses twice the same handler type.
2019-06-12 12:54:37 +02:00
Jehan b090bc5213 Issue #3493: GIMP changes R-channel, when it should not.
Our TIFF loading code was not taking into account the case when extra
channels were stored in the TIFF file while ExtraSamples field is not
set. Yet as a side effect of a later channel count, we were setting
`alpha` to TRUE while `save_transp_pixels` was left uninitialized (hence
undefined behavior).

For now let's make sure we have no undefined behavior. When the
ExtraSamples field is missing and at least one extra channel is stored,
we will consider the first extra channel as non-premultiplied alpha
(this is also what we were doing when ExtraSamples was set to
"Unspecified data" and apparently according to Massimo, it would be a
common behavior in other software).

Note that it is an improvement from previous code (no undefined
behaviour anymore, instead we handle explicitly the TIFF error). Yet
this is not perfect yet. Ideally we should pop-up a dialog asking what
to do with this extra channel: either open as a channel (no alpha), or
as premultiplied or non-premultiplied alpha.
2019-06-11 15:33:15 +02:00
Tobias Ellinghaus 7584969453
plug-ins: Add layer support to TIFF writing 2019-04-16 10:04:16 +02:00
Jehan 02adc61b05 plug-ins: add a new possible format for TIFF tag warning messages.
Completing fix from commit 3cb70e6.
Checking further into libtiff logs, I can see another version of the
warning message for private tags which was used before libtiff 3.7.
For sake of completeness, let's check against this version of the
warning as well.
2016-07-23 18:35:16 +02:00
Jehan 3cb70e67cc Bug 768950 - TIFF private tags should not generate warnings.
This is a regression from bug 131975. Any unknown tag over 32768 is not
an error. This is a reserved zone where it is allowed to create custom
tags.
The warning indeed changed since libtiff 4.0.0alpha where it has become:
"Unknown field with tag %d (0x%x) encountered"
This explains why it was not recognized anymore.
2016-07-23 18:20:53 +02:00
Jehan 35a0d8ddbb plug-ins: tiff_open() returns a pointer, not a boolean. 2016-07-23 17:41:00 +02:00
Michael Natterer 4cf6dad0a0 plug-ins: port file-tiff to GIO
Using code from gegl:tiff-load and gegl:tiff-save which has a mode for
local buffering if the input/output streams don't support seeking.
Unfortunately this code is broken and is disabled for now.
2016-04-19 23:09:26 +01:00
Michael Natterer b4e48c7ecd plug-ins: pass GFiles around instead of filenames in file-tiff
This is no port to GIO yet.
2016-04-19 17:18:17 +01:00
Michael Natterer c64a104155 plug-ins: merge the file-tiff-load and file-tiff-save plug-ins
so they can share duplicated code.
2015-12-05 08:53:09 +01:00