Camera icon indicating copy to clipboard operation
Camera copied to clipboard

Allow limiting photo resolution

Open pieterdd opened this issue 1 week ago • 6 comments

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

pieterdd avatar Dec 13 '25 22:12 pieterdd

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.

thestinger avatar Dec 13 '25 23:12 thestinger

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

pieterdd avatar Dec 13 '25 23:12 pieterdd

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.

thestinger avatar Dec 13 '25 23:12 thestinger

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 avatar Dec 14 '25 10:12 pieterdd

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 avatar Dec 14 '25 13:12 pieterdd

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

pieterdd avatar Dec 15 '25 14:12 pieterdd