mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(preview): handle libexif missing fields, don't accept 0-value orientation
Last fix was a hack when the error was actually us using the default 0 value of orientation since the returned ExifData was null.
This commit is contained in:
parent
5dcea74db5
commit
535b01a841
|
@ -36,20 +36,18 @@ namespace ExifTransform
|
||||||
return Orientation::TopLeft;
|
return Orientation::TopLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
int orientation = 0;
|
|
||||||
const ExifByteOrder byteOrder = exif_data_get_byte_order(exifData);
|
const ExifByteOrder byteOrder = exif_data_get_byte_order(exifData);
|
||||||
const ExifEntry* const exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION);
|
const ExifEntry* const exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION);
|
||||||
if (exifEntry) {
|
|
||||||
orientation = exif_get_short(exifEntry->data, byteOrder);
|
if (!exifEntry) {
|
||||||
|
exif_data_free(exifData);
|
||||||
|
return Orientation::TopLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int orientation = exif_get_short(exifEntry->data, byteOrder);
|
||||||
exif_data_free(exifData);
|
exif_data_free(exifData);
|
||||||
|
|
||||||
switch (orientation){
|
switch (orientation){
|
||||||
case 0:
|
|
||||||
// Exif spec defines 1-8 only, but when the orientation field isn't explcitly defined, we read 0 from
|
|
||||||
// libexif. It seems like exif_data_get_entry should return null in that case rather than saying the entry
|
|
||||||
// is present but with a value of zero.
|
|
||||||
return Orientation::TopLeft;
|
|
||||||
case 1:
|
case 1:
|
||||||
return Orientation::TopLeft;
|
return Orientation::TopLeft;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user