1

I am working on an iOS application that does some image processing. The result of the processing is a grey-scale image. When the process is finished, I want to save the original RGB image together with the result in a same image file to camera roll, so I thought of using alpha channel for that.

Also, I want to attach some parameters got in the processing as image metadata.

So here it comes my problem. I could not find an iOS compatible image format that allows saving alpha channel together with metadata. On the one hand, JPEG images accept metadata, but not alpha channel. On the other hand, PNG images accept alpha channel, but not metadata.

Any ideas?

Thanks in advance.

Jom
  • 13
  • 2

1 Answers1

1

On the other hand, PNG images accept alpha channel, but not metadata.

But yes metadata.

Community
  • 1
  • 1
  • Thanks @H2CO3 for your comment. I tried saving XMP metadata for PNG images. Although Apple has some primitives for [XMP-PNG metadata](http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGImageProperties_Reference/Reference/reference.html#//apple_ref/doc/uid/TP40005103-CH202-SW1), I could not get it. Here there are some interesting [links](http://stackoverflow.com/questions/15212083/how-to-write-custom-metadata-to-png-images-in-ios?rq=1) – Jom Apr 22 '13 at 20:18
  • Other option is to use [imagemagick](http://www.imagemagick.org/script/binary-releases.php#iOS) for iOS, but the only way I found to save metadata was using command-line [png-imagmagick](http://blog.client9.com/2007/08/editing-png-metadata-from-command-line.html) but adapted to iOS using [MagicCommandGenesis](http://www.imagemagick.org/discourse-server/viewtopic.php?f=6&t=20527), which by the way turned to me into a more complex problem. – Jom Apr 22 '13 at 20:18
  • So I finally decided to use TIFF, which also allows alpha and EXIF. In theory, it should work, but no luck. I attach one of my attempts. Any idea? NSMutableDictionary *tif = [[NSMutableDictionary alloc] init]; [tif setObject:@"Description" forKey:(NSString*)kCGImagePropertyTIFFImageDescription]; NSMutableDictionary *meta = [[NSMutableDictionary alloc] init]; [meta setObject:tif forKey:(NSString*)kCGImagePropertyTIFFDictionary]; ALAssetsLibrary *lib = [ALAssetsLibrary new]; [lib writeImageToSavedPhotosAlbum:img.CGImage metadata:meta completionBlock:nil];` – Jom Apr 22 '13 at 20:31