I am using share extension in my application and I want to show image taken time while I am sharing image with share extension.Is there any way to get the time of image when we use share extension.
Asked
Active
Viewed 241 times
1 Answers
1
The timestamp is available in EXIF data stored with the images. You can get it using UIImagePickerController like this:
https://stackoverflow.com/a/33672661/4042468
On the other hand, if you have image file url, you can use import ImageIO
and the below code to get all the properties of the image of which date time is one.
if let imagePath = Bundle.main.path(forResource: "test", ofType: "jpg") {
let imageURL = NSURL(fileURLWithPath: imagePath)
if let imageSource = CGImageSourceCreateWithURL(imageURL, nil) {
if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? [String: AnyObject] {
}
}
}
Note that there is a Exif key in which you can find timestamp.
-
i am not using image picker controller i share image direct from gallery so i want time of the image – Deepak Saki Feb 10 '17 at 11:08
-
@DeepakSaki Have a look now. – kerry Feb 10 '17 at 11:51
-
is it possible with the help of asset url because i share image direct from gallery. asset url is not passed in file path. – Deepak Saki Feb 10 '17 at 15:49