ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: Dickens DIng on November 03, 2023, 11:36:03 AM

Title: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: Dickens DIng on November 03, 2023, 11:36:03 AM
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?
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: StarGeek on November 03, 2023, 11:47:08 AM
In this post (https://exiftool.org/forum/index.php?topic=13059.msg70594#msg70594), 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 (https://apps.apple.com/us/app/perl-programming-language/id486217730) for iphone.
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: greybeard on November 03, 2023, 01:04:00 PM
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.
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: Dickens DIng on November 04, 2023, 10:44:26 AM
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.
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: 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.
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: Dickens DIng on November 04, 2023, 11:16:52 AM
Quote from: StarGeek on November 03, 2023, 11:47:08 AMIn this post (https://exiftool.org/forum/index.php?topic=13059.msg70594#msg70594), 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 (https://apps.apple.com/us/app/perl-programming-language/id486217730) 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. 
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: 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.
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: Dickens DIng on November 04, 2023, 11:31:07 PM
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...
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: greybeard on November 05, 2023, 03:23:48 AM
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.
Title: Re: I want to use exiftool on iOS, and I'm just starting to get ready to do that!
Post by: Phil Harvey on November 07, 2023, 07:29:59 AM
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. (https://exiftool.org/htmldump.html)

- Phil