Skip to content

Instantly share code, notes, and snippets.

@DelphiWorlds
Created June 23, 2020 02:11
Show Gist options
  • Save DelphiWorlds/9e6aa5dab3271cb3631767b6cd8febcb to your computer and use it in GitHub Desktop.
Save DelphiWorlds/9e6aa5dab3271cb3631767b6cd8febcb to your computer and use it in GitHub Desktop.
Extracting EXIF data on Android
uses
Androidapi.JNI.Media, Androidapi.JNIBridge;
var
LEXIF: JExifInterface;
LLatLong: TJavaArray<Single>;
LOrientation: Integer;
LLatitude, LLongitude: Single;
LDateTaken, LCameraMake, LCameraModel: string;
begin
LEXIF := TJExifInterface.JavaClass.init(StringToJString(AFileName));
LDateTaken := JStringToString(LEXIF.getAttribute(TJExifInterface.JavaClass.TAG_DATETIME));
LCameraMake := JStringToString(LEXIF.getAttribute(TJExifInterface.JavaClass.TAG_MAKE));
LCameraModel := JStringToString(LEXIF.getAttribute(TJExifInterface.JavaClass.TAG_MODEL));
LLatLong := TJavaArray<Single>.Create(2);
try
if LEXIF.getLatLong(LLatLong) then
begin
LLatitude := LLatLong.Items[0];
LLongitude := LLatLong.Items[1];
end;
finally
LLatLong.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment