Quantcast
Channel: Coding and Programing » image
Viewing all articles
Browse latest Browse all 10

save NSImage as new file

$
0
0

Problem And Question

How can I save a NSImage as a new file (png, jpg, …) in a certain directory?

Thank you for answering my “noobish” question.

Best Solution And Answer

Do something like this:

NSBitmapImageRep *imgRep = [[image representations] objectAtIndex: 0];
NSData *data = [imgRep representationUsingType: NSPNGFileType properties: nil];
[data writeToFile: @"/path/to/file.png" atomically: NO];

Viewing all articles
Browse latest Browse all 10

Trending Articles