Skip to content

Conversation

@hiking93
Copy link

@hiking93 hiking93 commented Aug 1, 2025

Image compression is using screenSize.scale as the resize factor:

screenshot = image.resize(Math.floor(pngSize.width / screenSize.scale))

But scale is currently hard-coded to 1 for Android, so while the file size is reduced, the resolution of the image won't be scaled, causing #140.

@krismuhi
Copy link
Member

thanks. we are gonna check this soon

@gmegidish
Copy link
Member

@hiking93 This looks neat and is a very good patch. Only change I'll ask is that instead of throwing an exception (which is very unlikely to happen in our scenario, the device is working properly), let's assume the dpi is 160 so there's no scaling. It'll make the code simpler and remove an exception that needs to be tested. What do you think, should we make this change?

@gmegidish
Copy link
Member

@hiking93 I just realized something. my emulated device has value of 560, which means 560/160=3.5

I just need to test this thoroughly to make sure taps on screenshot coordinates dont get broken (they're not stable regardless because of the way LLMs work). Need to make sure imagemagick supports scaling down by 3.5 factor.

@hiking93
Copy link
Author

@hiking93 This looks neat and is a very good patch. Only change I'll ask is that instead of throwing an exception (which is very unlikely to happen in our scenario, the device is working properly), let's assume the dpi is 160 so there's no scaling. It'll make the code simpler and remove an exception that needs to be tested. What do you think, should we make this change?

Sure, I've updated the implementation: 8e4267c

@hiking93
Copy link
Author

Need to make sure imagemagick supports scaling down by 3.5 factor.

I tried a Pixel 9 Pro Fold emulator:

  • wm size: 2076x2152
  • wm density: 390 (scale = 2.4375)

mobile_take_screenshot created a screenshot image with size 851 × 882, seems to be working well.

@hiking93
Copy link
Author

I just need to test this thoroughly to make sure taps on screenshot coordinates don't get broken (they're not stable regardless because of the way LLMs work).

To my knowledge, mobile_get_screen_size, mobile_list_elements_on_screen, and mobile_click_on_screen_at_coordinates all work with raw pixels on the Android side (instead of “points” on iOS), so I think density doesn't affect them. May double-check on that, though.

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.

3 participants