Adding keyword metadata to images in iOS - 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.

Related

Image diffing in iOS to obtain % difference

I am creating a comprehensive filtering tweak for Instagram's iOS app to remove unwanted posts. I am trying to add a feature to store all viewed thumbnails and use image diffing to determine whether any new thumbnails are reposts.
What is the most efficient way to obtain a % difference between two images in iOS? Since this is a tweak, I would like to avoid the use of third-party libraries, if possible.
Thanks.

Inspect CGColorSpace ICC color profile data on iOS

I'm looking for a way to inspect the the ICC color profile data provided CGColorSpace's copyICCData() method.
Specifically, I'm loading PNG images into UIImages on iOS, and trying to find a way to use the let iccData:CFData? = aUIImage.cgImage!.colorSpace!.copyICCData() to determine the gamma for the image file.  This is for a game that uses 3D rendering— if the source image has a standard 2.2 gamma, I'll load the image data into a texture as sRGB (e.g. MTLPixelFormatRGBA8Unorm_sRGB) and if it has a gamma of 1.0 I'll instead load it as a linear texture (e.g. MTLPixelFormatRGBA8Unorm).
Note: The solution of just passing a UIImage/CGImage to the rendering system (SceneKit/Metal) and letting it sort it out won't work here because: 1. Some of the rendering I'm doing is assembling 2D images into a 3D texture, so that's something I need to do with raw data, not something I can just read from a standard image file format; 2. I'm specifically trying to pass gamma-1.0 images into the rendering system to avoid the overhead of sRGB→linear conversion (rendering is in linear space).
Also: Manual ICC-parsing solutions, Apple-API-using solutions, and open-source library suggestions are all acceptable answers.  This is not specifically a query for tool recommendation — any solution that'll work is a good one — but in my research, manual ICC parsing would be unwieldy and Apple's APIs don't seem to expose any ICC properties.  So I believe the most likely answer is a pointer to some library out there that I haven't been able to find via Google or GitHub or CocoaPods or StockOverflow, and will be gladly accepted.
Your best bet is to use sample icc 'https://sourceforge.net/projects/sampleicc/'. Just get the profile data as you described, then use OpenIccProfile to load it up. From there, get a ref to the header structure (.m_Header) and pull the info you need. I'd also recommend you take a look at RefIccMax 'https://github.com/InternationalColorConsortium/RefIccMAX' which is a newer version of the same lib, but not ready for primetime.

Querying, Editing and removing image metadata in 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/

simple image recognition with any api/library

Is it possible to do very basic image recognition to compare an image against a database of images(resource folder images or any web servers images if we have) and determine which image in the database is the best match? I don't need to do any processing of any of the images, but simply differentiate between a finite list of images.
Is it any open source code available ?
I would recommend using OpenCV if you simply want to compare images (i.e. decide if two images are the same).
Here is a similar question on SO:
iOS image comparison
I would also go about reading a little bit about what Core Image (the iOS image library) has to offer, before going about OpenCV or other 3rd party.
I hope this helps.

How to write or modify EXIF data for an existing image on the filesystem, without loading the image?

I've asked similar questions before, but have not received a definitive answer. Seems that there must be a way to simply add/modify metadata to an image without loading the image into memory, without having to deal with directly reading bits.
Seems like ways exist when using CMSampleBufferRefs, but I need to be able to do this with a regular image already saved to disk.
For instance, given a very large png at /Documents/photo.png, I want to modify its exif metadata without having to load that image.
You can use libexif - I've had success with compiling it for iOS before. With libexif, you can modify any image's EXIF metadata.
If you know how to modify the EXIF, you can modify the binary data directly from the file. Just replace in the image the binary portion with the new one.
I don't know if objective-c permit this, but in ansi c should be simple. The complicate part is to identify the exact part to change.

Resources