Re: Resizing an image
Re: Resizing an image
- Subject: Re: Resizing an image
- From: Eamon Ford <email@hidden>
- Date: Sun, 22 Jan 2006 10:42:55 -0800
But, I already tried that and it didn't work. When I write the file
to disk, it's still the original size.
On Jan 22, 2006, at 3:48 AM, Heinrich Giesen wrote:
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