我使用以下代码来获取 NSImage 的宽度和高度:
NSImage *image = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:s]] autorelease];
imageWidth=[image size].width;
imageHeight=[image size].height;
NSLog(@"%f:%f",imageWidth,imageHeight);
有时候 imageWidth
和 imageHeight
无法正确返回值,例如当我读取一张图片时,它的 EXIF 信息显示:
PixelXDimension = 2272;
PixelYDimension = 1704;
但是imageWidth、imageHeight的输出
521:390