Fixed: Before this PR, imagesize would provide image size in points (that is, taking care of the image resolution) instead of pixels (#2965)

This commit is contained in:
Didier Korthoudt
2022-03-21 14:12:51 +01:00
committed by GitHub
parent 145bf65542
commit 93fc8d29cc
+10 -3
View File
@@ -22,9 +22,16 @@ int getImageSize(const char* utf8Path, BOOL appendLineFeed)
if (!image)
return kErrInvalidPath;
NSSize size = [image size];
NSMutableString* result = [NSMutableString stringWithFormat:@"{\"width\":%g, \"height\":%g}", size.width, size.height];
NSArray *representations = [image representations];
if ([representations count] == 0)
return kErrInvalidPath;
NSImageRep *representation = representations[0];
NSInteger width = [representation pixelsWide];
NSInteger height = [representation pixelsHigh];
NSMutableString* result = [NSMutableString stringWithFormat:@"{\"width\":%ld, \"height\":%ld}", (long)width, (long)height];
if (appendLineFeed)
[result appendString:@"\n"];