I have an NSImage that I am trying to modify this way:
NSImage *capturePreviewFill = [[NSImage alloc] initWithData:previewData]; NSSize newSize; newSize.height = 160; newSize.width = 120; [capturePreviewFill setScalesWhenResized:YES]; [capturePreviewFill setSize:newSize]; NSData *resizedPreviewData = [capturePreviewFill TIFFRepresentation]; resizedCaptureImageBitmapRep = [[NSBitmapImageRep alloc] initWithData:resizedPreviewData]; saveData = [resizedCaptureImageBitmapRep representationUsingType:NSJPEGFileType properties:nil]; [saveData writeToFile:@"/Users/ricky/Desktop/Photo.jpg" atomically:YES];
My first problem is that my image is crushed when I try to resize it and disagree with the aspect ratio. I read that using -setScalesWhenResized will solve this problem, but it is not.
The second problem is that when I try to write the image to a file, the image does not actually change at all.
Thanks in advance, Ricky.
source share