Skip to content

Conversation

@pieterdd
Copy link

Often I don't need a photo at maximum resolution. To efficiently use disk space, it's helpful to be able to limit the pixel size of the longest edge.

screenshot

@thestinger
Copy link
Member

This isn't the way we want to implement this. The camera stack should be configured to take the pictures in a lower resolution instead of doing a conversion from JPEG to JPEG which makes it more lossy and will be much slower.

@pieterdd
Copy link
Author

Fair enough, I'll see if I can write an improved version tomorrow.

@thestinger
Copy link
Member

CameraX may have an API for doing this, but it's possible that it's currently missing. CameraX has made a huge number of improvements we haven't caught up with yet.

@pieterdd
Copy link
Author

It seems to be possible via https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionStrategy, which Camera already uses for QR codes. However, CameraX is unable to guarantee the requested resolution. We need to specify a fallback strategy towards a higher/lower resolution, both of which would be undesirable.

To truly deliver on the promise of the feature, I think I would need to fall back to the higher resolution, and then again resort to a lossy JPG-to-JPG conversion to size to the correct limit if needed.

An alternative might be to find a CameraX API that exposes the "native" resolutions of the camera, assuming it's a relatively limited set of options.

@pieterdd pieterdd force-pushed the limit-long-edge branch 2 times, most recently from de58a76 to c6afab0 Compare December 14, 2025 13:16
@pieterdd
Copy link
Author

I've changed the implementation so that the user can now choose their preferred native camera resolution:

screenshot2

There's one bug I can't explain yet, and which is the spinner always jumping back up when I try to scroll down.

@pieterdd
Copy link
Author

Fixed, didn't realize that reloadSettings was being called quite regularly.

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.

2 participants