Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Anyone find way to get exif data from photo in IOS gallery


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 11 - Last Post: Mar 2, 2017 12:53 PM Last Post By: Markus Humm
William Brookfi...

Posts: 55
Registered: 1/1/10
Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2017 7:35 AM
I am stumped, I need to get the date a picture was taken on users IOS device

The typical method of fetching images using standard action TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap) only returns bitmap (No metadata)

Trying to use IFMXImageManagerService does not work since it appears to not be implemented on IOS

Appears someone is porting PhotoLibrary framework but it is work in progress with no code

Customer wants the Images my apps sends to them to have the EXIF data.

Any suggestions?
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2017 11:50 AM   in response to: William Brookfi... in response to: William Brookfi...
William Brookfield wrote:

Appears someone is porting PhotoLibrary framework but it is work in progress with no code

That's probably me. The work was delayed for a while, however I've made more progress with it recently. I can at least
check whether I can extract EXIF data from photos, and report back.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2017 12:59 PM   in response to: Dave Nottage in response to: Dave Nottage
I wrote:

That's probably me. The work was delayed for a while, however I've made more progress with it recently. I can at least
check whether I can extract EXIF data from photos, and report back.

I'm attempting to use this library:

https://github.com/esmondb/ccr-exif

But it needs tweaking to compile for iOS. I'll work on it later today.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
William Brookfi...

Posts: 55
Registered: 1/1/10
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 10:34 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
I wrote:

That's probably me. The work was delayed for a while, however I've made more progress with it recently. I can at least
check whether I can extract EXIF data from photos, and report back.

I'm attempting to use this library:

https://github.com/esmondb/ccr-exif

But it needs tweaking to compile for iOS. I'll work on it later today.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

I looked at CCR-EXIF and it appears to required the image file. If I could get access to the image file, I can send the file to the server and use CCR-EXIF on the server side to extract the metadata.
The problem is I can find no way to access the actual file as the camera/ gallery callbacks only returns a Bitmap.

Bill B
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 11:46 AM   in response to: William Brookfi... in response to: William Brookfi...
William Brookfield wrote:

I looked at CCR-EXIF and it appears to required the image file. If I could get access to the image file, I can send
the file to the server and use CCR-EXIF on the server side to extract the metadata. The problem is I can find no way
to access the actual file as the camera/ gallery callbacks only returns a Bitmap.

I have the way to access the picture; I just need some EXIF code that works on iOS that can extract the useful info
like GPS coords etc. Sadly, it looks like CCR-EXIF needs a boatload of work to make that happen. I'm currently
attempting to pare out the bits that matter.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
William Brookfi...

Posts: 55
Registered: 1/1/10
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 11:56 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
William Brookfield wrote:

I looked at CCR-EXIF and it appears to required the image file. If I could get access to the image file, I can send
the file to the server and use CCR-EXIF on the server side to extract the metadata. The problem is I can find no way
to access the actual file as the camera/ gallery callbacks only returns a Bitmap.

I have the way to access the picture; I just need some EXIF code that works on iOS that can extract the useful info
like GPS coords etc. Sadly, it looks like CCR-EXIF needs a boatload of work to make that happen. I'm currently
attempting to pare out the bits that matter.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

You say you have a way to get the image with the metadata (EXIF) (Not just the bitmap). Can you share how? I can just send the data back to my server and do the EXIF work there. The mobile does not need to see the EXIF values just the server side at least for my problem.

Bill B
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 12:20 PM   in response to: William Brookfi... in response to: William Brookfi...
William Brookfield wrote:

You say you have a way to get the image with the metadata (EXIF) (Not just the bitmap). Can you share how?

Since my current intention is to productise my work, no. There's a major hoop that I needed to jump through to make it
work.

I can just send the data back to my server and do the EXIF work there. The mobile does not need to see the EXIF
values just the server side at least for my problem.

At this point, I just want to find out if the picture I retrieve has EXIF data. I assume it has, since it is being
fetched directly from the system, however I want to be sure, mostly so I can answer that part of your question, but
also because I may need to do it myself.

The fact that the EXIF extraction doesn't have to happen on the mobile is a good point. I'll see what I can do, however
it would be much easier if there was code that works on mobile. It looks like it would take a pretty huge effort to
change CCR-EXIF.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 2, 2017 12:52 AM   in response to: Dave Nottage in response to: Dave Nottage
I wrote:

At this point, I just want to find out if the picture I retrieve has EXIF data. I assume it has, since it is being
fetched directly from the system, however I want to be sure, mostly so I can answer that part of your question, but
also because I may need to do it myself.

OK, so after a few hours of Googling, head scratching, tearing my hair out etc, I managed to extract EXIF data, however
that was achieved inside of iOS using the appropriate API calls, inside of the Photos framework.

I expect this may be the only way of achieving it on iOS, and as I indicated earlier, I've put a substantial amount of
effort into the code (including tearing more hair out), so I'm disinclined to share it without some kind of return.

If you want to take the DIY path, Eli is on the right track by suggesting the use of the translated framework header
(i.e. iOSapi.Photos - I suggest using CnPack's code formatter to make it readable, but I seem to recall it also needs a
bit of tweaking), however that just gives you the API. In order to make it useful there's a bunch of other coding,
working out how to make some calls work (hint: they won't with Delphi code alone), and for extracting EXIF data it
includes filling in other APIs for iOS (e.g. ImageIO) that have been around since iOS 4, but are not included (for iOS)
with Delphi.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 2, 2017 10:33 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 02.03.2017 um 09:52 schrieb Dave Nottage (TeamB):
I wrote:

At this point, I just want to find out if the picture I retrieve has EXIF data. I assume it has, since it is being
fetched directly from the system, however I want to be sure, mostly so I can answer that part of your question, but
also because I may need to do it myself.

OK, so after a few hours of Googling, head scratching, tearing my hair out etc, I managed to extract EXIF data, however
that was achieved inside of iOS using the appropriate API calls, inside of the Photos framework.

I expect this may be the only way of achieving it on iOS, and as I indicated earlier, I've put a substantial amount of
effort into the code (including tearing more hair out), so I'm disinclined to share it without some kind of return.

If you want to take the DIY path, Eli is on the right track by suggesting the use of the translated framework header
(i.e. iOSapi.Photos - I suggest using CnPack's code formatter to make it readable, but I seem to recall it also needs a
bit of tweaking), however that just gives you the API. In order to make it useful there's a bunch of other coding,
working out how to make some calls work (hint: they won't with Delphi code alone), and for extracting EXIF data it
includes filling in other APIs for iOS (e.g. ImageIO) that have been around since iOS 4, but are not included (for iOS)
with Delphi.

Hello,

if you can get at the raw bytes of the image there's no need for some
api providing the exif data if that should be so hard to use.

Just grab a copy of the JPEG specification and the one describing the
Exif data and you should be able to parse this stream wise or so.

Such things are doable, unless the format is as complex and variable as
TIFF (which I guess it's not). Such things (not exif back then) I
already did in Turbo Pascal for DOS way back...

Greetings

Markus
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 2, 2017 11:33 AM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:

if you can get at the raw bytes of the image there's no need for some
api providing the exif data if that should be so hard to use.

I prefer to use documented methods, but in any event, getting at the EXIF data was probably the easiest part of the
exercise.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 2, 2017 12:53 PM   in response to: Dave Nottage in response to: Dave Nottage
Am 02.03.2017 um 20:33 schrieb Dave Nottage (TeamB):
Markus Humm wrote:

if you can get at the raw bytes of the image there's no need for some
api providing the exif data if that should be so hard to use.

I prefer to use documented methods, but in any event, getting at the EXIF data was probably the easiest part of the
exercise.

I can understand you.
I don't like OS which try to hide the concept of "file" from you when
these are actually there! I guess part of the issue is related to that.

Greetings

Markus
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Anyone find way to get exif data from photo in IOS gallery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 11:41 AM   in response to: William Brookfi... in response to: William Brookfi...
Seems like Photos is the new library to do it in IOS9+ and ALAssetsLibrary is depreciated.

https://stackoverflow.com/questions/9542487/select-multiple-images-from-photo-library

https://developer.apple.com/reference/photos

The framework headers:
https://github.com/FMXExpress/ios-object-pascal-wrapper/blob/master/iOSapi.Photos.pas

Some sample code in Swift which you could translate to Object Pascal using the above headers:
https://stackoverflow.com/questions/28259961/swift-how-to-get-last-taken-3-photos-from-photo-library
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02