• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: converting NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >converting NSImage (From: Alexander Cohen <email@hidden>)

  • Prev by Date: Can I set "no extension" as a document file type?
  • Next by Date: Re: Can I set "no extension" as a document file type?
  • Previous by thread: Re: converting NSImage
  • Next by thread: Binding + NSMatrix + custom cell class
  • Index(es):
    • Date
    • Thread