On 09.01.2009, at 15:11, Parimal Das wrote:

in my application i need to resize a .jpg image through a command line


What does it mean: "resize" ?. Every NSBitmapImageRep has two sizes:
a (print-)size which says how long width and hight (expressed in inch, cm or printerpoints or ...) of the depicted (printed) image are. This value can be set (changed) with -setSize:. And it has a (storage-)size which says how many pixel the image has expressed as a dimensionless number. The connection between these two "sizes" is the "resolution". Changing the pixelnumbers results
in a rendering process.

Next point: An icon (NSImage) is a container of several NSBitmapImageReps. You have to select
the one that fits best.

That lets me make a proposal which is close to your first try:

NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:filePath]; NSSize imageSize = { 384.0, 384.0 }; // in points (384 pts = 512 px at 96 dpi resolution)
        
   [icon setSize:imageSize];
NSBitmapImageRep *bitmapImageRep = (NSBitmapImageRep *)[icon bestRepresentationForDevice:nil];
   [bitmapImageRep setSize:imageSize];  // <--- do not forget !!!
[[bitmapImageRep representationUsingType:NSJPEGFileType properties:nil]
       writeToFile:destPath
        atomically:YES];



--
Heinrich Giesen
gies...@acm.org


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to