Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

13 lines (11 sloc) 0.627 kb
@implementation NSImage (SaveExtensions)
- (void) saveAsJpegWithName:(NSString*) fileName andSize:(NSSize) size {
NSImage *sizedImage = [self imageScaledToFitSize:size];
// Cache the reduced image
NSData *imageData = [sizedImage TIFFRepresentation];
NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];
NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.0] forKey:NSImageCompressionFactor];
imageData = [imageRep representationUsingType:NSJPEGFileType properties:imageProps];
[imageData writeToFile:fileName atomically:NO];
Jump to Line
Something went wrong with that request. Please try again.