Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata support #102

Closed
fnakstad opened this issue Feb 5, 2016 · 2 comments
Closed

Metadata support #102

fnakstad opened this issue Feb 5, 2016 · 2 comments

Comments

@fnakstad
Copy link
Contributor

fnakstad commented Feb 5, 2016

Hey guys! Great job on this library. My favorite image picker by far, and currently attempting to use it in my own app project.

One problem I'm having is that I also need to extract EXIF data for each image, so that I can store geotags and timestamps along with the raw image. As far as I can tell, this is not supported yet, and I'm guessing it will have to be done independently via the Photos Framework. Am I missing an obvious feature here? Or are there perhaps plans to also include metadata in the ImagePickerDelegate callbacks?

@zenangst
Copy link
Contributor

zenangst commented Feb 7, 2016

Hey @fnakstad, right now we don't support any type of meta data because it hasn't been a requirement for us but it would be super cool if it did! Feel free to make a PR to add this kind of functionality, regardless if you do or don't, we will keep it in our backlog so that it doesn't get lost (personally I would love this feature).

Thanks for supporting ImagePicker and bringing this to our attention!

@fnakstad
Copy link
Contributor Author

fnakstad commented Feb 8, 2016

Cool! I checked into it some more, and discovered that this can be done fairly easily for photos taken with the standard camera app by directly accessing the assets, for example like this:

func doneButtonDidPress(images: [UIImage]) {
    imagePicker.dismissViewControllerAnimated(true, completion: nil)
    for imageAsset in imagePicker.stack.assets {
        let options = PHContentEditingInputRequestOptions()
        options.networkAccessAllowed = true
        imageAsset.requestContentEditingInputWithOptions(options) { (contentEditingInput: PHContentEditingInput?, _) -> Void in
            let fullImage = CIImage(contentsOfURL: contentEditingInput!.fullSizeImageURL!)
            print(fullImage?.properties)
        }
    }
}

The fullImage?.properties is a dictionary containing various metadata such as GPS, EXIF, TIFF, etc. This works perfectly when using a picture taken with the standard camera app and loaded with ImagePicker. However, when snapping a picture with the custom CameraView of ImagePicker a lot of this data isn't stored along with the picture, so the dictionary is missing EXIF and GPS data. For this kind of use-case it might be preferable if the imageAssets themselves were passed as arguments to the doneButtonDidPress callback, but at least this works for now.

As far as I can tell The EXIF data can be fetched from the dictionary returned by AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation, but the GPS location needs to be manually fetched begging a dependency on CoreLocation. I might scrap together an initial PR after some more experimentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants