I want to use exiftool on iOS, and I'm just starting to get ready to do that!

Started by Dickens DIng, November 03, 2023, 11:36:03 AM

Previous topic - Next topic

Dickens DIng

As far as I know, iOS doesn't seem to support the perl language, so I don't know if anyone has done anything like this before, and checking github I don't seem to see anyone else doing it. I'm wondering if there's any experience with this, or if anyone else has encountered any difficulties?

StarGeek

In this post, Phil says he has Perl and exiftool running on an old jailbroken ipad touch, but the Perl version he used didn't exist anymore

A quick google search pulls up this Perl for iphone.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

greybeard

I've asked about this before and not found any way to do it.

As I'm mostly interested in Fujifilm I wrote my own exif extract routine in Swift - but migrating all of exiftool and keeping it current would be a lot of work.

Dickens DIng

hi, bro, Can you share how you handled this?  A few sample codes or a few ideas , I'd hope to have a reference, because this is really some idea. Your mobility is awesome.

Dickens DIng

Quote from: greybeard on November 03, 2023, 01:04:00 PMI've asked about this before and not found any way to do it.

As I'm mostly interested in Fujifilm I wrote my own exif extract routine in Swift - but migrating all of exiftool and keeping it current would be a lot of work.

hi, bro, Can you share how you handled this?  A few sample codes or a few ideas , I'd hope to have a reference, because this is really some idea. Your mobility is awesome.

Dickens DIng

Quote from: StarGeek on November 03, 2023, 11:47:08 AMIn this post, Phil says he has Perl and exiftool running on an old jailbroken ipad touch, but the Perl version he used didn't exist anymore

A quick google search pulls up this Perl for iphone.
Yeah, I saw that, but perl doesn't run on iOS at the moment, so it's blocked here.    I guess I need to find some other way to read the exif information of these jpeg files on iOS, on ImageIO I've already tried to use the iOS api and I can't get it, I don't even see the binary data, so I'll have to find a way to read the exif information. 

greybeard

Quote from: Dickens DIng on November 04, 2023, 11:13:47 AM
Quote from: greybeard on November 03, 2023, 01:04:00 PMI've asked about this before and not found any way to do it.

As I'm mostly interested in Fujifilm I wrote my own exif extract routine in Swift - but migrating all of exiftool and keeping it current would be a lot of work.

hi, bro, Can you share how you handled this?  A few sample codes or a few ideas , I'd hope to have a reference, because this is really some idea. Your mobility is awesome.


There are two ways to do it using Swift - one is much easier but much more limited:

- read the image file in binary format: let imageData = try? Data(contentsOf: url)

- pass the binary image file to CIImage: let cImage = CIImage(data: imageData)

- then use the CIImage properties as a complex array object : let exif = cImage?.properties as? [String:Any]

You then parse up the [String:Any] array and extract the metadata.

The main problem with this approach is that Apple doesn't expose all of the metadata - so if you want simple stuff like camera make, model, lens model, timestamp and so on this is the way to go - but not if you want everything that Exiftool gives you.

The other problem (for me) is that Apple doesn't support Fujifilm compressed raw so this doesn't work at all for those files. Apple is also very slow in supporting new cameras.

The other approach is to parse up the binary file (basically mimicking Exiftool) but its a lot of work - especially if you want to handle a lot of different raw files.

Dickens DIng

Quote from: greybeard on November 04, 2023, 12:43:35 PM
Quote from: Dickens DIng on November 04, 2023, 11:13:47 AM
Quote from: greybeard on November 03, 2023, 01:04:00 PMI've asked about this before and not found any way to do it.

As I'm mostly interested in Fujifilm I wrote my own exif extract routine in Swift - but migrating all of exiftool and keeping it current would be a lot of work.

hi, bro, Can you share how you handled this?  A few sample codes or a few ideas , I'd hope to have a reference, because this is really some idea. Your mobility is awesome.


There are two ways to do it using Swift - one is much easier but much more limited:

- read the image file in binary format: let imageData = try? Data(contentsOf: url)

- pass the binary image file to CIImage: let cImage = CIImage(data: imageData)

- then use the CIImage properties as a complex array object : let exif = cImage?.properties as? [String:Any]

You then parse up the [String:Any] array and extract the metadata.

The main problem with this approach is that Apple doesn't expose all of the metadata - so if you want simple stuff like camera make, model, lens model, timestamp and so on this is the way to go - but not if you want everything that Exiftool gives you.

The other problem (for me) is that Apple doesn't support Fujifilm compressed raw so this doesn't work at all for those files. Apple is also very slow in supporting new cameras.

The other approach is to parse up the binary file (basically mimicking Exiftool) but its a lot of work - especially if you want to handle a lot of different raw files.
I tested this, and it's essentially the same thing.

    let imageData = try? Data(contentsOf: url)
        if let imageData = imageData {
            let cImage = CIImage(data: imageData)
            let exif = cImage?.properties as? [String:Any]
            print(exif)
            print(exif)
        }

like this Image/io

        if let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) {
            if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? [String: Any] {
                print("All Image Metadata: \(imageProperties)")
            }




I think I may need to parse the binary, because I need the exif data to be more than just the publicly available part, but it's hard to do that ....

Have you tried reading the binary .... ? Or have a suggestion for that ? I'm trying to do this now...

greybeard

Yes I have tried reading the binary but haven't found good examples or tutorials on the Web.

Once you start I'd recommend using the exiftool -htmlDump option which is brilliant at giving a visual representation of the file structure. JPGs comprise blocks of metadata tags connected by pointers and you're going to have to follow the pointers and parse up the metadata blocks - converting the binary data to the appropriate Swift data type.

If you have specific questions you are welcome to PM or post on here.

Phil Harvey

Quote from: greybeard on November 05, 2023, 03:23:48 AMI'd recommend using the exiftool -htmlDump option which is brilliant at giving a visual representation of the file structure.

:) :)

Link to -htmlDump example page.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).