iOS Question Reading Exif Data

Semen Matusovskiy

Well-Known Member
Licensed User
Hi, guys --

I used a code similar https://www.b4x.com/android/forum/threads/exif-data.57419/ and read whole metadata for certain jpg-file (a photo).
Some fields are filled, but I was not able to retrieve GPS-coordinates, smartphone model etc. Meanwhile, for example, Windows Explorer shows this information.

Any ideas, what can be wrong ? It's possible to suspect objective-c code. But I used different samples from stackoverflow. Maybe LoadBitmap ?
 

Semen Matusovskiy

Well-Known Member
Licensed User
Reading stackoverflow's comments, I understood that IOS specially strips Exif for security reasons.
But there is a workaround - to read exactly a file, not UIImage.

B4X:
#If OBJC
#import <ImageIO/ImageIO.h>

- (NSObject*) readExif: (NSString *) path
    {
    NSData *imgData = [NSData dataWithContentsOfFile: path];
    CGImageSourceRef source = CGImageSourceCreateWithData ((__bridge CFDataRef) imgData, NULL);
    NSDictionary *metaData = CFBridgingRelease (CGImageSourceCopyPropertiesAtIndex (source, 0, NULL));
    CFRelease (source);
    return metaData;
    }

#End If

I attached a sample. Place your own photo with name ios.jpg into Files subfolder (forum limits a size of attached files).
 

Attachments

  • Exif.zip
    1.8 KB · Views: 159
Upvote 0
Top