Querying, Editing and removing image metadata in ios - ios

OK, I'm new to IOS development but have a decent amount of programming experience so thought it would be fairly straightforward to pick up.
I'm creating a photo app that will display all of the users images (or take new images using camera) and then display them in galleries based on metadata tags.
I've spent a considerable amount of time searching for the best approach but seems nothing is that suitable, I need to be able to easily access the tags as they will be used as criteria for querying the database and populating the galleries.
The problem is that I want to be able to add extra tags to an image or multiple images at any time without having to parse XMP data and storing an entirely new image.
From what i've found so far there should be ways to add tags to my image file using either XMP or EXIF data to store extra strings but they seem to be quite long-winded, I was considering just making a custom data type that would hold an image and an array of strings for the tags but this doesn't seem logical if there is already a specific structure within the image to store such metadata.
Alot of people have mentioned using
WriteImageDataToSavedPhotosAlbum or
CGImageDestinationSetProperties
Ultimately I would just like to know if anybody can clarify how I should access, edit and display the xXMP or EXIF data in my app or just create my own (shoddy looking) data structure that would essentially be image representation + string array of 'tags'

You are looking at using the ALAssetsLibrary framework. This is quite a good tutorial which I have used before :
http://www.altdevblogaday.com/2011/05/26/getting-metadata-from-images-on-ios/

Related

Offline app data [duplicate]

I have created an app using ionic and cordova and now I want to remake it on iOS. I am working with iOS for the first time, and I cannot figure out how to store data.
For example: I have a form where user has to input some data, but the inputs are not in one view, there must be several views. I used to create empty array and just put everything step by step, but now i can't use same view controller on multiple views. Tried to do it with core data, but core data cannot store arrays. My object would look something like this:
var sampleArray = (
duration: 13,
dayOfTheWeek: Thursday,
personList: [
(name: Rocky,
age: 26),
(name: Ralph,
age:23)
]
)
The question would be: How could I make an input form which would be on several views and where should I store the data, and later I would be able to store all the data into core data?
You can work with persistent data in several ways on iOS.
User Default
This is a tool that is used to store small amounts of information like user settings, preferences etc. Don't use it for data that will scale with application usage (e.g. like notes in notepad app). Documentation will answer all your questions about User Defaults.
Database
You have Core Data as an out of the box solution which is build on top of the SQLite and takes some time to learn, but from my experience it's worth the effort. You are free to use pure SQLite or other database type, but it requires more code and probably custom frameworks.
Text files
You can use arbitrary XML, JSON or CSV files to store your data. Tooling is rich (e.g. NSXMLParser or SwifyJSON just to name two) and if you look on Github, you will find what you need. You can also use build in combination of NSCoder and NSKeyArchiver / NSKeyUnarchiver which are easy to grasp.
Binary files
Finally, for a local storage you can use binary files i.e. images. This is too advanced topic to cover here, but I want to share an example of Open Raster file format. It is used to save informations for drawing apps (eq. GIMP) and inside, it is basically an XML file and a bunch of images compressed to zip and named as .ora file. Creating your own specification for a hybrid format is not that hard.
Network repository
Just to not overlook other methods, you can use remote database API to store data outside of the device, but of course you need your own host and some backend skills.
I hope I didn't miss something important. I just wanted to sum up this knowledge in one place for future reference.
As the first comment says, your question is quite large.
When you say 'one form on several view', I consider it as 'one form per view'.
Keep It Simple S... ;)
(Except if you use page control for your form.)
Basically, you have three ways to store data :
NSUserDefaults :
Store data in Dictionary for later use
File :
Save data to a File (why not .csv like ?)
CoreData :
You can persist arrays as binary data in Core Data
There are numerous tutorials on these topics.
www.raywenderlich.com site is a good one to begin...

Advise where to store data for iOS app

I have created an app using ionic and cordova and now I want to remake it on iOS. I am working with iOS for the first time, and I cannot figure out how to store data.
For example: I have a form where user has to input some data, but the inputs are not in one view, there must be several views. I used to create empty array and just put everything step by step, but now i can't use same view controller on multiple views. Tried to do it with core data, but core data cannot store arrays. My object would look something like this:
var sampleArray = (
duration: 13,
dayOfTheWeek: Thursday,
personList: [
(name: Rocky,
age: 26),
(name: Ralph,
age:23)
]
)
The question would be: How could I make an input form which would be on several views and where should I store the data, and later I would be able to store all the data into core data?
You can work with persistent data in several ways on iOS.
User Default
This is a tool that is used to store small amounts of information like user settings, preferences etc. Don't use it for data that will scale with application usage (e.g. like notes in notepad app). Documentation will answer all your questions about User Defaults.
Database
You have Core Data as an out of the box solution which is build on top of the SQLite and takes some time to learn, but from my experience it's worth the effort. You are free to use pure SQLite or other database type, but it requires more code and probably custom frameworks.
Text files
You can use arbitrary XML, JSON or CSV files to store your data. Tooling is rich (e.g. NSXMLParser or SwifyJSON just to name two) and if you look on Github, you will find what you need. You can also use build in combination of NSCoder and NSKeyArchiver / NSKeyUnarchiver which are easy to grasp.
Binary files
Finally, for a local storage you can use binary files i.e. images. This is too advanced topic to cover here, but I want to share an example of Open Raster file format. It is used to save informations for drawing apps (eq. GIMP) and inside, it is basically an XML file and a bunch of images compressed to zip and named as .ora file. Creating your own specification for a hybrid format is not that hard.
Network repository
Just to not overlook other methods, you can use remote database API to store data outside of the device, but of course you need your own host and some backend skills.
I hope I didn't miss something important. I just wanted to sum up this knowledge in one place for future reference.
As the first comment says, your question is quite large.
When you say 'one form on several view', I consider it as 'one form per view'.
Keep It Simple S... ;)
(Except if you use page control for your form.)
Basically, you have three ways to store data :
NSUserDefaults :
Store data in Dictionary for later use
File :
Save data to a File (why not .csv like ?)
CoreData :
You can persist arrays as binary data in Core Data
There are numerous tutorials on these topics.
www.raywenderlich.com site is a good one to begin...

Adding keyword metadata to images in iOS

I've been wrestling with finding a way to add keyword metadata to images in iOS. I've scoured the internet and stackoverflow but haven't found anything specific to adding keywords to images in iOS. I've seen that different applications like Photoshop and Aperture allow you to do this type of thing so, the capability for images is there in general, but is there a way to achieve this in iOS?
Specifically, is it possible to create a new key/value pair and nest it within the image metadata?
Look in the CGImageProperties reference. As you can see, you are allowed to add EXIF dictionary information to an image. This is exactly how Photoshop and Aperture do it. The ImageIO framework will give you the means to write into the EXIF dictionary.

Advices to store pre-populated data (image + text) for an iOS app [duplicate]

This question already has answers here:
How to read data structure from .plist file into NSArray
(8 answers)
Closed 8 years ago.
I have built a recipe app for iOS and recently lost all my code thanks to a defective SSD drive and my astonishing stupidity not backing anything up. I learnt my lesson but instead of trying to build the same app again, I'd like to be a bit smarter this time.
The problem I always had was that adding new recipes was a huge pain because of the way they were stored: I named each picture "recipe_X.png" and I had a text file containing a bunch of comma separated lines with the following format "title, subtitle, quantity1, ingredient1, quantity2, ingredient2...".
I would then run a while loop from 1 to X and read the recipe information and load the image.
This worked fine but adding 10 new recipes would take me hours because I would need to fill all the data, resize all the images, rename them and then test each recipe to make sure names weren't too long. I would sometimes miss a line when entering data and everything would be screwed up. I also localized my app which would just multiple the time spent.
I wonder what is a better way to store the data knowing that it is read-only, the data size is relatively small and my main concern is the ease to pre-populate data. Core DB seems great but not the easiest to pre-populate data.
I like the suggestion from techzen but I would love an example about how to save an NSArray as a static file:
Prepopulated stored data in iOS4
Any suggestion is appreciated.
I would suggest looking into the NSCoding protocol. Considering UIImage conforms to this protocol, you could create a model class with properties for image, title, subtitle, etc. that conforms to NSCoding. Add instances of this object to an NSArray, then call:
[NSKeyedArchiver archiveRootObject:theArray toFile:someFilePath];

iPhone local storage -- Core Data, NSFileManager, ...?

I am making a simple iPhone app that will basically be an editor.
As such, I need some way to store the documents the user creates.
Since on iPhone, the concept of the filesystem is not present for the user, I searched around to see what I should use.
I found this question & answer that basically says to use Core Data, but I recently found out about NSFileManager.
My question simply is, for user-created documents, what is the best storage system to use? Traditional files by using NSFileManager? Core Data? Something else?
Personally, I would use CoreData because it will abstract away all of the file-management code for you. If you are making simple text documents then this isn't such a big deal, but if you are working with a complex document architecture (i.e., a collection a numerous objects) then it can save you a lot of effort.
If the user wants to export their document it is very easy to write a function to do so with your CoreData objects.
The only downside to CoreData is that if you are using non-standard attributes it can get a little bit tricky, but it is certainly not a deal breaker in most cases.
People create document formats without CoreData all of the time, so there are plenty of examples out there, and it will just come down to personal preference. There really isn't any generalized right answer to this - it a design decision that should be evaluated on a per-app basis.
If all of your data for displaying the file is contained in one long string (like HTML) then I would recommend that you use the file manager, since it will be easy to get a list of files in a certain directory to display to the user for opening. However, if they are not self contained (like NSAttributedString, which has many stored formatting regions along with the actual content) then you should use CoreData, as it will be easier to keep all the pieces together.

Resources