One way to hack around it is to tell the image to use the pixel size of the underlying image representation:
NSImage *image; image = [[NSImage alloc] initWithContentsOfFile: path]; NSBitmapImageRep *rep = [[image representations] objectAtIndex: 0]; // If you think you might get something other than a bitmap image representation, // check for it here. NSSize size = NSMakeSize ([rep pixelsWide], [rep pixelsHigh]); [image setSize: size];
NSBitmapImageRep *bits = ...; // get a rep from your image, or grab from a view NSData *data; data = [bits representationUsingType: NSPNGFileType properties: nil]; [data writeToFile: @"/path/to/wherever/test.png" atomically: NO];There are also TIFF, BMP, GIF, JPEG file types in addition to PNG.