Loading/Retrieving an image from Photos Library based on metadata in iOS - ios

I have an iOS application that I am working where I am capturing an image, and then storing it in my Photos Album. I realize that I am able to write custom metadata for this image when I store it using the following:
writeImageDataToSavedPhotosAlbum:metadata:completionBlock:
My question is, is it possible for me to somehow retrieve this same image later on, using this metadata as my search criteria (if for example I store this same metadata in CoreData, and use it later in a query)? An example of possible metadata I am planning on using is either a date and time stamp, and/or geolocation. Is retrieval of images possible using metadata and not knowing the exact file name?

If you already have a Core Data store, save all of the metadata and the asset URL (for the default representation). Then you can do all of your querying locally and access the assets only when required (though you should check they haven't been deleted before showing results).
When you have done your search to get the asset URL you can get the image using assetForURL:resultBlock:failureBlock: from the ALAssetsLibrary.

Related

Get an image from URL and upload it to Firebase Storage

Is it possible to write a function to get an image from a url such as https://website.com/images/myImage.jpg and then automatically upload it to a Firebase Storage bucket?
I am trying to do it with multiple images in one go but am struggling to get one to work at the moment. My best attempt so far has seen me having to download the images, save them in the Media Library and then send them all up to Firebase, which surely cannot be the most efficient way?
In a nutshell, I have 10 images with URL's like the above and, when the function is fired I need them all to upload to my storage bucket, without the need to save them to the users device library.
Does anyone have any ideas on the most efficient way to do this please?

Accessing metadata of video stored in S3

I have uploaded a video file to S3 using their NodeJS SDK with some metadata. I can see the metadata on the S3 console.
I am recording the timestamp of when in the video a particular event occurs to begin playback from that time when someone renders the video.
This timestamp is what I am storing as part of the metadata in the video file so that I do not need to pass this data to the server through another medium.
I need to use this metadata in my Rails application during render.
When I download the video file, the metadata seems to be lost. I tried using ffprobe to get all meta content but that data visible in S3 is lost.
I read the answer to this question and I seem to be doing the upload right.
Is the metadata I see on the console AWS specific?
How do I access that data through my Rails server?
A "head" operation will allow you to access the metadata without fetching the entire object. Follow this link for more info.
If I were you I would store the metadata in DynamoDB. It is much easier to play with & makes your app more flexible for the future.

AWS S3 Metadata iOS

I am developing photo sharing application in iOS using Amazon as backend.
I have uploaded photo to S3 but my problem is how to get metadata of uploaded photo, actually i want lat and lang of that photo. I am using latest sdk version 2.0.2 of aws.
Can you help me? Can you guid me which function I have to use to get meta data information?
The location data, if available, is embedded inside the image file itself and is not part of the file's S3 object metadata. You can define your own custom metadata when the image is uploaded and set the image's coordinates there.
It may be better though to store the coordinates in a DynamoDB table along with the image's S3 object key to provide better lookup and querying.

Offline Blog Reading (Images) capability (cache)?

I am creating a UITableView where I will load and show data from my blog's feed. This data will be updated daily, on launch or dynamically.
What I want to do is provide some offline capability to this screen, as such if user isnt connected to internet, he can still see the view and its contents (mainly post list with its images).
For such I will need some hints or solutions on how to do this, probably cache ?
Basically if user is connected to net, the view will update the contents and fetch he blog post feeds from my API and update it with new content, but if user isnt connected to net, he should see the last fetched/updated content (with images) till he connects to net and updates the view.
For this probably I need to save/cache 3 things which I will need and use in the View, all of which are fetched and provided by my API:- The Post Title, Date and its cover image.
Would best way would be to add them to some dictionary, use NSCache (aint it temporary ?) or download images locally and then save them as UIImage along with NSString (title/date) in a dic/array ?
I would like to know as many different approaches possible.
After testing a bit, I found caching images can solve my offline image problem, but is cache temporary or how long can it last ? How can I store that cached image with my text data in some dictionary to load it if network isnt connected ?
You can use a ready to use, opensource caching library like SDWebImage. It provides asynchronous image downloading as well as caching, so any image that is cached will appear in place when your app is offline.

ALAsset Unique identifier

I want to duplicate an image from the Photo Library but I want to check in the future if I already have imported this image.
Immagine this scenario.
I have a photo in my Photo Library.
I import it in my app by making a copy of it.
I remove this photo from my library.
At a later time I reinsert this picture to my photo library (Same photo from iPhoto, just didn't synch it's album before and I have now)
Is there a unique identifier that I can use to compare the two pictures? is the URL unique?
Or do I have to look into the metadata and try to match it?
If so, what would you suggest? Created Data and location? Just created Date? Size?
Thanks for your advice.
Observations
I've been working with similar functionality, so this is what I know:
Each photo inserted into the photo library will have a unique URL (this means if you insert an image, delete it, then insert it again, even if it is the same image, it will have a new URL).
There is no straight forward way of knowing whether an image is a duplicate of a previous image or not.
I don't think you are trying to do this, but I will warn you that you cannot delete an image programmatically from the iPhone Photo library.
Solutions
I really only have one way of handling this: Create a hash of the photo and store the hash somewhere. If the photo inserted is the exact same photo as before, it should give you the same hash. You can use that hash comparison to determine if you are using the same photo or not. This is the method that I am using and it seems to work reliably for the most part. I have noticed some discrepancies, but these usually involve my work hashing the files before they are added to the photo library (I have noticed that the saved photo can be different from the photo that is being saved).
I hope this information helps. Let me know if I've missed anything or you notice different results in your work.

Resources