diff options
| author | Elliot Wolk <elliot.wolk@gmail.com> | 2016-10-29 04:56:13 -0400 | 
|---|---|---|
| committer | Elliot Wolk <elliot.wolk@gmail.com> | 2016-10-29 04:56:13 -0400 | 
| commit | 66b581330ee0517e346170a3695c3b53a32a0c18 (patch) | |
| tree | 32b0f14042c54323854a21710e84048b45db8ff2 /src | |
| parent | c6752c190fb54252d9f808e179bfee28f7bf3f0d (diff) | |
imlib: fix autorotate EXIF parsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/imlib.c | 27 | 
1 files changed, 15 insertions, 12 deletions
| diff --git a/src/imlib.c b/src/imlib.c index 16fbfba..1cf2e5b 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -258,22 +258,25 @@ int feh_load_image(Imlib_Image * im, feh_file * file)  		return(0);  	} +	int orientation = 0;  #ifdef HAVE_LIBEXIF -	file->ed = exif_get_data(file->filename); - -	if (file->ed) { -		entry = exif_content_get_entry(file->ed->ifd[EXIF_IFD_0], 0x0112); -		if (entry != NULL) { -			if (*(entry->data) == 3) -				gib_imlib_image_orientate(*im, 2); -			else if (*(entry->data) == 6) -				gib_imlib_image_orientate(*im, 1); -			else if (*(entry->data) == 8) -				gib_imlib_image_orientate(*im, 3); -		} +	ExifData *exifData = exif_data_new_from_file(file->filename); +	if (exifData) { +		ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); +		ExifEntry *exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION); +		if (exifEntry) +			orientation = exif_get_short(exifEntry->data, byteOrder);  	} +	file->ed = exifData;  #endif +	if (orientation == 3) +		gib_imlib_image_orientate(*im, 2); +	else if (orientation == 6) +		gib_imlib_image_orientate(*im, 1); +	else if (orientation == 8) +		gib_imlib_image_orientate(*im, 3); +  	D(("Loaded ok\n"));  	return(1);  } | 
