Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Correct image size calculation for macOS with NSImage #316

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sejong2401
Copy link

Summary

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.

Testing

  • Verified the correct image size is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant