From 93fc8d29ccddadbb66347e216bef6c177d6b670e Mon Sep 17 00:00:00 2001 From: Didier Korthoudt Date: Mon, 21 Mar 2022 14:12:51 +0100 Subject: [PATCH] Fixed: Before this PR, imagesize would provide image size in points (that is, taking care of the image resolution) instead of pixels (#2965) --- Tools/imagesize/imagesize.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Tools/imagesize/imagesize.m b/Tools/imagesize/imagesize.m index fed8edb9d..3d427ec65 100644 --- a/Tools/imagesize/imagesize.m +++ b/Tools/imagesize/imagesize.m @@ -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"];