drewnoakes / metadata-extractor-dotnet

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] - OfType<ExifIfd0Directory>().FirstOrDefault() returns null on some specific Android devices

Brunoporto2702 opened this issue · comments

(Please include as much information as possible, and attach a sample image if possible.)

Hi!

I have implemented this library in order to get Xamarin's MediaPicker library to work properly, once it takes pictures rotated in diferent angles depending on the phone that is running the app.

var meta = ImageMetadataReader.ReadMetadata(await photo.OpenReadAsync());
var subIfd0Directory = meta.OfType<ExifIfd0Directory>().FirstOrDefault();
var orientation = subIfd0Directory?.GetDescription(ExifDirectoryBase.TagOrientation);
var rotationAngle = GetRotationAngle(orientation);

Tha problem is pretty straigth forward: on some especific devices e.g. Asus ZenPhoneSelfie, Motorola moto g(8) plus, and Motorola moto g(7) power, the result of the query

.OfType<ExifIfd0Directory>().FirstOrDefault()

returns null and I am unable to get the phone's orientation properly.

Does someone have any idea how to make it work properly on those devices?

I do not have access to test devices like the ones that are going through this problem....

Cheers!

Have you verified that the images in question actually contains orientation information? Use ExifTool or some other application capable of reading these data, and verify that they are there. If that's the case, you need to post a sample of one such problematic image.

As @Nadahar says, a null here suggests the metadata isn't there. If you can see metadata in another app (e.g. exiftool) then please attach a sample image here to allow further debugging.

I'll close this for now as we do not yet have evidence of a bug. If you believe a bug exists, please attach an image that demonstrates the problem and we can reopen this. Thanks.