https://github.com/BestImageViewer/geeqie/issues/923
This is an excerpt from ISO/IEC 23008-12:2017(E):
---------
Metadata specified in Annex A or according to the item type and MIME
type values is descriptive and does not normatively affect the
presentation.
In particular, an image item can be rotated by 90°, 180°, or 270° using
the 'irot' transformative item property.
Rotation metadata, e.g. according to Annex A, is ignored in the
displaying process.
8.2 Metadata for image items
------------
Therefore libheif is rotating the image in accordance with the irot
property - and then Geeqie rotates it again using the Exif value.
If the libheif decoding option "ignore_transformations" is used, the
result is different on two systems I use - one one system the option is
ignored, and on the other system the option is used, but then no Exif
data is displayed for the file.
As the compiled code is the same in both cases, there must be an
influence from other system library files.
The implemented solution ignores the Exif rotation parameter and
inhibits writing manually applied rotation metadata for all files
processed by libheif.
g_free(fd->owner);
g_free(fd->group);
g_free(fd->sym_link);
g_free(fd->owner);
g_free(fd->group);
g_free(fd->sym_link);
+ g_free(fd->format_name);
g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */
file_data_change_info_free(NULL, fd);
g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */
file_data_change_info_free(NULL, fd);
+ il->fd->format_name = il->backend.get_format_name(il->loader);
+
g_mutex_unlock(il->data_mutex);
}
g_mutex_unlock(il->data_mutex);
}
else
if (options->metadata.write_orientation)
{
else
if (options->metadata.write_orientation)
{
- orientation = metadata_read_int(fd_n, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ if (g_strcmp0(imd->image_fd->format_name, "heif") == 0)
+ {
+ orientation = EXIF_ORIENTATION_TOP_LEFT;
+ }
+ else
+ {
+ orientation = metadata_read_int(fd_n, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ }
if (orientation != (fd_n->exif_orientation ? fd_n->exif_orientation : 1))
{
if (orientation != (fd_n->exif_orientation ? fd_n->exif_orientation : 1))
{
- if (!options->metadata.write_orientation)
+ if (g_strcmp0(fd_n->format_name, "heif") != 0)
+ {
+ if (!options->metadata.write_orientation)
+ {
+ /* user_orientation does not work together with options->metadata.write_orientation,
+ use either one or the other.
+ we must however handle switching metadata.write_orientation on and off, therefore
+ we just disable referencing new fd's, not unreferencing the old ones
+ */
+ if (fd_n->user_orientation == 0) file_data_ref(fd_n);
+ fd_n->user_orientation = orientation;
+ }
+ }
+ else
- /* user_orientation does not work together with options->metadata.write_orientation,
- use either one or the other.
- we must however handle switching metadata.write_orientation on and off, therefore
- we just disable referencing new fd's, not unreferencing the old ones
- */
if (fd_n->user_orientation == 0) file_data_ref(fd_n);
fd_n->user_orientation = orientation;
}
if (fd_n->user_orientation == 0) file_data_ref(fd_n);
fd_n->user_orientation = orientation;
}
fd_n->user_orientation = 0;
}
fd_n->user_orientation = 0;
}
- if (options->metadata.write_orientation)
+ if (g_strcmp0(fd_n->format_name, "heif") != 0)
- if (type == ALTER_NONE)
- {
- metadata_write_revert(fd_n, ORIENTATION_KEY);
- }
- else
+ if (options->metadata.write_orientation)
- metadata_write_int(fd_n, ORIENTATION_KEY, orientation);
+ if (type == ALTER_NONE)
+ {
+ metadata_write_revert(fd_n, ORIENTATION_KEY);
+ }
+ else
+ {
+ metadata_write_int(fd_n, ORIENTATION_KEY, orientation);
+ }
}
else if (options->image.exif_rotate_enable)
{
}
else if (options->image.exif_rotate_enable)
{
- imd->orientation = metadata_read_int(imd->image_fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
- imd->image_fd->exif_orientation = imd->orientation;
+ if (g_strcmp0(imd->image_fd->format_name, "heif") == 0)
+ {
+ imd->orientation = EXIF_ORIENTATION_TOP_LEFT;
+ imd->image_fd->exif_orientation = imd->orientation;
+ }
+ else
+ {
+ imd->orientation = metadata_read_int(imd->image_fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ imd->image_fd->exif_orientation = imd->orientation;
+ }
if (options->image.exif_rotate_enable)
{
if (options->image.exif_rotate_enable)
{
- imd->orientation = metadata_read_int(imd->image_fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ if (g_strcmp0(imd->image_fd->format_name, "heif") != 0)
+ {
+ imd->orientation = metadata_read_int(imd->image_fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ }
+ else
+ {
+ imd->orientation = EXIF_ORIENTATION_TOP_LEFT;
+ }
{
if (!il->fd->exif_orientation)
{
{
if (!il->fd->exif_orientation)
{
- il->fd->exif_orientation = metadata_read_int(il->fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ if (g_strcmp0(il->fd->format_name, "heif") != 0)
+ {
+ il->fd->exif_orientation = metadata_read_int(il->fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ }
+ else
+ {
+ il->fd->exif_orientation = EXIF_ORIENTATION_TOP_LEFT;
+ }
}
if (il->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
}
if (il->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
{
if (!tl->fd->exif_orientation)
{
{
if (!tl->fd->exif_orientation)
{
- tl->fd->exif_orientation = metadata_read_int(tl->fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ if (g_strcmp0(il->fd->format_name, "heif") != 0)
+ {
+ tl->fd->exif_orientation = metadata_read_int(tl->fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ }
+ else
+ {
+ tl->fd->exif_orientation = EXIF_ORIENTATION_TOP_LEFT;
+ }
}
if (tl->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
}
if (tl->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
{
if (!tl->fd->exif_orientation)
{
{
if (!tl->fd->exif_orientation)
{
- tl->fd->exif_orientation = metadata_read_int(tl->fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ if (g_strcmp0(tl->fd->format_name, "heif") != 0)
+ {
+ tl->fd->exif_orientation = metadata_read_int(tl->fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ }
+ else
+ {
+ tl->fd->exif_orientation = EXIF_ORIENTATION_TOP_LEFT;
+ }
}
if (tl->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
}
if (tl->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
const gchar *extension;
gchar *extended_extension;
FileFormatClass format_class;
const gchar *extension;
gchar *extended_extension;
FileFormatClass format_class;
+ gchar *format_name; /**< set by the image loader */
gchar *collate_key_name;
gchar *collate_key_name_nocase;
gint64 size;
gchar *collate_key_name;
gchar *collate_key_name_nocase;
gint64 size;