Hi,

I am trying to reduce the size of an NSImage by 50% and then save the
reduced image out to disk.  The following code does not reduce the image.
 Should I be going about this a different way?


Thanks!

Simon



NSImage* inputImage = [[NSImage alloc] initWithContentsOfFile:[fileNames
objectAtIndex:0]];


NSSize halfSize = [inputImage size];

halfSize.height = (int)(halfSize.height / 2);

halfSize.width  = (int)(halfSize.width  / 2);


[inputImage setScalesWhenResized:YES];

[inputImage setSize:halfSize];



NSBitmapImageRep* imageRepx = [NSBitmapImageRep
imageRepWithData:[inputImage TIFFRepresentation]];

NSDictionary *imagePropsx = [NSDictionary dictionaryWithObject:[NSNumber
numberWithFloat:0.9]


 forKey:NSImageCompressionFactor];

NSData* outputImageDatax = [imageRepx representationUsingType:NSJPEGFileType
properties:imagePropsx];



[outputImageDatax writeToFile:@"resizedimage.jpg" atomically:YES];
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to