Re: converting NSImage
Re: converting NSImage
- Subject: Re: converting NSImage
- From: Matt Mashyna <email@hidden>
- Date: Wed, 27 Sep 2006 16:47:44 -0400
Here's how I do it. From a view class I have:
[[self getJpegData] writeToFile:path atomically:YES];
- (NSData *)getJpegData:(NSImage*) image
{
NSImageRep* imageRep;
NSData* jpegData;
NSDictionary* repProperties;
imageRep = [image bestRepresentationForDevice:nil];
if (![imageRep isKindOfClass:[NSBitmapImageRep class]]) {
NSRunAlertPanel( @"Non-bitmap image",
@"Image's representation isn't an NSBitmapImageRep",
@"Cancel", nil, nil );
return nil;
}
repProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:0.9], NSImageCompressionFactor,
nil];
jpegData = [(NSBitmapImageRep*)imageRep
representationUsingType:NSJPEGFileType
properties:repProperties];
return jpegData;
} // getJpegData
On Sep 27, 2006, at 10:05 AM, Alexander Cohen wrote:
Hi, i need to use NSImage to load up any type of image (weel, at
least any type NSImage supports), remove all of its metadata,
profiles, anything that might make the file heavier, and save it
out as an RGB JPEG. Is this possible with NSImage? How would i go
about doing this? Im mostly looking for the info on removing all
the extra data an image can drag around.
thanks
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden