Unverified Commit 2a9a7e25 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Disable --auto-rotate in feh builds compiled wiht Imlib2 1.7.5+

Imlib2 v1.7.5 introduces automatic (and transparent) orientation adjustment
based on EXIF orientation tags. This makes feh's --auto-rotate function
both superfluous and erroneous: It doesn't know about Imlib2's adjustments,
so it rotates an image which is already correctly oriented, leading to
incorrect orientation.

I am not aware of a simple run-time check for detecting whethen running
Imlib2 < 1.7.5 or ≥ 1.7.5. For now, feh disables --auto-rotate entirely when
compiled on a system with Imlib2 1.7.5+ and outputs a warning when the
option is used.

Rationale: The Imlib2 version available at run-time should in most cases be
at least as recent as the Imlib2 version used at compile-time. So, while there
may be cases where feh was compiled with Imlib2 1.7.4 and exhibits erroneous
auto-rotate behaviour on an Imlib2 1.7.5 system, the inverse case
(a feh with disabled auto-rotate support running on Imlib2 1.7.4) should be
sufficiently rare. If it does occur, it can be remedied by compiling feh
from source locally.

Possible caveat: Imlib2 only adjusts for EXIF orientation when loading JPEG
and TIFF images. If there are additional EXIF-aware file formats supported by
feh, but not Imlib2, they lose auto-rotate support.

Reference: GitHub issue #642
parent 7076b7a2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -261,9 +261,12 @@ Automatic reload is not supported in montage, index, or thumbnail mode.
.It Cm --auto-rotate
.
.Pq optional feature, $MAN_EXIF$ in this build
.Pq deprecated in favor of Imlib2's auto-orientation support
Automatically rotate images based on EXIF data.
Does not alter the image files.
.
.Pp
.
Note that Imlib2 version 1.7.5+ performs auto-rotation by itself, so this option is obsolete on systems with Imlib2 version 1.7.5 or later.
.Nm
currently cannot detect this at runtime.
+2 −1
Original line number Diff line number Diff line
@@ -462,9 +462,10 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
	if (file->ed) {
		ExifByteOrder byteOrder = exif_data_get_byte_order(file->ed);
		ExifEntry *exifEntry = exif_data_get_entry(file->ed, EXIF_TAG_ORIENTATION);
		if (exifEntry && opt.auto_rotate)
		if (exifEntry && opt.auto_rotate) {
			orientation = exif_get_short(exifEntry->data, byteOrder);
		}
	}

	if (orientation == 2)
		gib_imlib_image_flip_horizontal(*im);
+5 −0
Original line number Diff line number Diff line
@@ -758,7 +758,12 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
			opt.draw_exif = 1;
			break;
		case OPTION_auto_rotate:
#if defined(IMLIB2_VERSION_MAJOR) && defined(IMLIB2_VERSION_MINOR) && defined(IMLIB2_VERSION_MICRO) && (IMLIB2_VERSION_MAJOR > 1 || IMLIB2_VERSION_MINOR > 7 || IMLIB2_VERSION_MICRO >= 5)
			weprintf("This feh release was built with Imlib2 version %d.%d.%d, which transparently adjusts for image orientation according to EXIF data.", IMLIB2_VERSION_MAJOR, IMLIB2_VERSION_MINOR, IMLIB2_VERSION_MICRO);
			weprintf("--auto-rotate would rotate an already correctly oriented image, resulting in incorrect orientation. It has been disabled in this build. Rebuild feh with Imlib2 <1.7.5 to enable --auto-rotate.");
#else
			opt.auto_rotate = 1;
#endif
			break;
#endif
		case OPTION_no_xinerama: