• 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: Properly dealing with images
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properly dealing with images


  • Subject: Re: Properly dealing with images
  • From: Michael Becker <email@hidden>
  • Date: Thu, 17 Jun 2004 15:47:47 +0200

Am Jun 17, 2004 um 11:39 AM schrieb Michael Becker:
NSImage doesn't seem to take into account that there are different image resolutions. I have a 1800 x 1800 pixel image at 20 pixels per inch. NSImage tells me that it's 6480 x 6480 pixels (which would be true if it was at the standard 72 pixels per inch).

Ok, I am using NSBitmapImageRep's pixelsHigh and pixelsWide, which works fine. But I realised another issue:

Say, I have a 300dpi JPEG image. I load it into an NSImage (using initWithContentsOfFile:). Then I do something with it (manipulate in whatever way, say, render an NSAttributedString on the image). Now I want to save this image to disk, using the exact same properties as the loaded image had. This code:

NSImage* theImage;
. . .
NSData* data = [ theImage TIFFRepresentation];
NSBitmapImageRep *imageRep = [ NSBitmapImageRep imageRepWithData:[[[NSImage alloc] initWithData:data] TIFFRepresentation]];
NSDictionary *propDict = [ NSDictionary dictionaryWithObjectsAndKeys:[ NSNumber numberWithFloat:1.0], NSImageCompressionFactor, nil];

[[ imageRep representationUsingType:NSJPEGFileType properties:propDict] writeToFile:path atomically:YES];
Always produces a typical 72dpi-JPEG-image.

What can I do? Actually, the most important thing is to preserve the pixel-dimensions. That means, I don't really care about the dpi, but the output image needs to have the same pixel-width / pixel-height as the original. Being a newbie to this image manipulation myself, I hope that somebody understands what I am saying :-)

Cheers,
Michael
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Properly dealing with images (From: Michael Becker <email@hidden>)

  • Prev by Date: Re: Scrolling List of Thumbnails?
  • Next by Date: Job Opportunity Hamburg
  • Previous by thread: Re: Properly dealing with images
  • Next by thread: A bit confused
  • Index(es):
    • Date
    • Thread