• 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: NSImage - Converting image formats
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage - Converting image formats


  • Subject: Re: NSImage - Converting image formats
  • From: Jonathan Hendry <email@hidden>
  • Date: Mon, 25 Jun 2001 22:39:14 -0500

On Monday, June 25, 2001, at 07:31 , Ivan Salina Fernandes wrote:

I'm trying to convert PDF images into Jpeg images. I used TIFFRepresentation in a NSBitmapImageRep, but I can't change the compression. Can anybody help me to change this parameters?

I think you want to use NSBitmapImageRep's method

- (NSData *)representationUsingType:(NSBitmapImageFileType)storageType properties:(NSDictionary *)properties;

with NSJPEGFileType as the storageType.

If you want an actual jpeg file, then I don't think you
want to use - TIFFRepresentation.

eg,

//I haven't compiled or run this, so you may have to tweak it.

NSBitmapImageRep *imageRep;
NSDictionary *propertyDict;
NSNumber *compressionFactor;
NSData *jpgData;

// The compression factor is a float between 1.0 and 255.0,
// with larger numbers providing greater compression and
// more distortion. See the HTML docs for NSBitmapImageRep.

compressionFactor = [NSNumber numberWithFloat:10.0];

propertyDict = [NSDictionary dictionaryWithObject:compressionFactor
forKey:NSImageCompressionFactor];

jpgData = [imageRep representationUsingType:NSJPEGFileType
properties:propertyDict];

[jpgData writeToFile:@"foo.jpg" atomically:NO];


References: 
 >NSImage - Converting image formats (From: Ivan Salina Fernandes <email@hidden>)

  • Prev by Date: Re: How doess Cocoa handle SIGINT?
  • Next by Date: Re: [NEWBIE] Sheets problem
  • Previous by thread: NSImage - Converting image formats
  • Next by thread: Re: NSImage - Converting image formats
  • Index(es):
    • Date
    • Thread