Heinrich when i am using the code corrected by U * NSImage *myIcon = [[NSWorkspace sharedWorkspace] iconForFile:filePath];
NSLog(@"%@", myIcon); // check 1 NSLog(@"OK1"); NSSize imageSize = { 384.0, 384.0 }; // in points (384 pts = 512 px at 96 dpi resolution) [myIcon setSize:imageSize]; NSBitmapImageRep *bitmapImageRep2 = (NSBitmapImageRep *)[myIcon bestRepresentationForDevice:nil]; [bitmapImageRep2 setSize:imageSize]; // <--- do not forget !!! NSLog(@"%@", bitmapImageRep2); // check 2 [[bitmapImageRep2 representationUsingType:NSJPEGFileType properties:nil] writeToFile:destPath atomically:YES]; NSLog(@"image resized"); // check 3 * i am getting the following output error- 2009-01-15 13:43:09.313 te[747:10b] *NSImage 0x117340 Size={32, 32} Reps=( NSIconRefBitmapImageRep 0x117e30 Size={128, 128} ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=128x128 Alpha=YES Planar=NO Format=0, NSIconRefBitmapImageRep 0x11cdd0 Size={48, 48} ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=48x48 Alpha=YES Planar=NO Format=0, NSIconRefBitmapImageRep 0x118280 Size={32, 32} ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=32x32 Alpha=YES Planar=NO Format=0, NSIconRefBitmapImageRep 0x11ce80 Size={16, 16} ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=16x16 Alpha=YES Planar=NO Format=0 )* 2009-01-15 13:43:09.314 te[747:10b] *OK1* 2009-01-15 13:43:09.315 te[747:10b] *NSIconRefBitmapImageRep 0x117e30 Size={384, 384} ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=128x128 Alpha=YES Planar=NO Format=0* *Segmentation fault* -----> program exited this segmentation fault is coming just before the image writing step (notice check 3 is not coming). ie program is crashing before the step *[[bitmapImageRep2 representationUsingType:NSJPEGFileType properties:nil] writeToFile:destPath atomically:YES]; *i am really clueless about why it is happening ???? also there is a big difference between general NSImage and what i am getting in myIcon (see its a mixture of 4 images as in the .icn files)* * On Tue, Jan 13, 2009 at 4:36 PM, Heinrich Giesen < heinrich.gie...@t-online.de> wrote: > > 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 > > > -- -- Warm Regards, Parimal Das _______________________________________________ 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