• 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: Andrei Kolev <email@hidden>
  • Date: Tue, 26 Jun 2001 18:48:09 +0300

The quotation below shows the right way to save a JPEG file. But I am afraid
that the compression factor is a float between 0 and 1 (1 -> best quality,
low compression, 0 -> low quality, max compression).

Andrei


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];


  • Prev by Date: Re: Send action when textDidChange
  • Next by Date: Re: int -> NSString
  • Previous by thread: Re: NSImage - Converting image formats
  • Next by thread: field editor oddness
  • Index(es):
    • Date
    • Thread