To add text to an image in cocoa I ended up starting with a PNG image and ending with a PNG. Note: I used cocoa instead of imagemagick annotation command due to an odd decoder issue with fonts. Also it is always best to use native code when available.
----sample code
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont fontWithName:@"Times" size:42], NSFontAttributeName, nil ];
NSImage *cdimage = [[NSImage alloc] initWithContentsOfFile:cd_image_path];
[cdimage lockFocus];
[pword_msg drawAtPoint:NSMakePoint(55,90) withAttributes:attributes];
[cdimage unlockFocus];
//create a NSBitmapImageRep
NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc]initWithData:[cdimage TIFFRepresentation]];
//add the NSBitmapImage to the representation list of the target
[cdimage addRepresentation:bmpImageRep];
//get the data from the representation
NSData *data = [bmpImageRep representationUsingType: NSPNGFileType properties: nil];
//write the data to a file
[data writeToFile:cd_image_path atomically: NO];
Addendum : see new post - Cocoa Native Image Manipulation
----sample code
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont fontWithName:@"Times" size:42], NSFontAttributeName, nil ];
NSImage *cdimage = [[NSImage alloc] initWithContentsOfFile:cd_image_path];
[cdimage lockFocus];
[pword_msg drawAtPoint:NSMakePoint(55,90) withAttributes:attributes];
[cdimage unlockFocus];
//create a NSBitmapImageRep
NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc]initWithData:[cdimage TIFFRepresentation]];
//add the NSBitmapImage to the representation list of the target
[cdimage addRepresentation:bmpImageRep];
//get the data from the representation
NSData *data = [bmpImageRep representationUsingType: NSPNGFileType properties: nil];
//write the data to a file
[data writeToFile:cd_image_path atomically: NO];
Addendum : see new post - Cocoa Native Image Manipulation