• 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: Resizing an image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resizing an image


  • Subject: Re: Resizing an image
  • From: Heinrich Giesen <email@hidden>
  • Date: Sun, 22 Jan 2006 12:48:19 +0100


On 22.01.2006, at 09:54, Eamon Ford wrote:


I found out how to do it: you have to create a new NSImage of the desired size, lock focus on it, and draw the original image into the new one.

That's an overkill.

There really should be an easier way to do it.

Please remember that the natural incarnation (object) of the data of an image file is an object of one of the subclasses of NSImageRep and not an NSImage. Locking, drawing, unlocking wastes a lot of time and space; this will work:

NSBitmapImageRep *theRep = ...;
// get the rep from the file or:
// in most cases [theOriginalImage objectAtIndex:0] will do it
// but it must be an NSBitmapImageRep
[theRep setSize:theNewSize];
[[theRep representationUsingType:NSJPEGFileType properties:nil] // or another type
writeToFile:fileName atomically:YES];


The best way to change the size (i.e. the resolution) of an image is
the way sips goes. But sips has some bugs and is not uptodate (Tiger).

--
Heinrich Giesen
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
  • Follow-Ups:
    • Re: Resizing an image
      • From: Eamon Ford <email@hidden>
    • Re: Resizing an image
      • From: Robert Dell <email@hidden>
  • Prev by Date: Re: NSImage NSInternalInconsistencyException
  • Next by Date: Re: Resizing an image
  • Previous by thread: Re: Resizing an image
  • Next by thread: Re: Resizing an image
  • Index(es):
    • Date
    • Thread