This PR fixes an issue where NSImage was returning incorrect image sizes on macOS.
Issue
Some images were being compressed to a size smaller than the provided minWidth or minHeight values.
This is because NSImage.size method returns size information that is screen resolution dependent.
For example, consider this sample image which has a real size of 1920 x 1200 pixels.
When compressing this image with a minHeight value of 1000, the resulting image size is 460 x 288, which is incorrect. This issue was observed on a Mac Mini connected to an LG monitor. It is unclear whether the same problem occurs with an iMac or an Apple external display.
Details
Replaced the NSImage.size method with NSImageRep.pixelsWide and NSImageRep.pixelsHigh to get the actual image size.
The issue and solution were inspired by the discussion found here.
Summary
This PR fixes an issue where
NSImage
was returning incorrect image sizes on macOS.Issue
minWidth
orminHeight
values.NSImage.size
method returns size information that is screen resolution dependent.minHeight
value of 1000, the resulting image size is 460 x 288, which is incorrect. This issue was observed on a Mac Mini connected to an LG monitor. It is unclear whether the same problem occurs with an iMac or an Apple external display.Details
NSImage.size
method withNSImageRep.pixelsWide
andNSImageRep.pixelsHigh
to get the actual image size.Testing