Description
Proposal
With the release of CamerAwesome 1.0.0, we lost the ability to know and choose the resolution we want to take pictures with.
Instead, we can set an aspect ratio that is respected both on the preview and on the image captured with the best resolution available.
Some use cases need to set a lower resolution and to know what resolution it will be.
Android side
We are now using CameraX
instead of Camera2
, which comes with its pros and cons.
When asking to take a picture, we can set either a target aspect ratio OR a target resolution.
The targeted aspect ratio should be respected but the target resolution can vary for several reasons:
- the resolution doesn't exist for this camera, so it chooses a better one with a possible different aspect ratio
- it there is no better resolution than target resolution, it will choose the closest below target resolution with a possible different aspect ratio
Having a different aspect ratio than the preview seems wrong. One solution is to scale/crop the picture taken to better match the preview but it won't have the exact same resolution as we've set in target resolution.
Additionally, getting the list of camera resolutions is not as easy as it seems since the camera used can vary depending on settings such as the zoom ratio. On a Pixel 7 Pro for instance, there are several lenses with different zoom levels and with different resolutions available. Depending on the current zoom, CameraX
will take the picture with one or the other lens resulting in a varying resolution.
Here is the list of possibilities we have in mind
1. Only let users set aspect ratio (current solution)
When setting an aspect ratio, target resolution is the best possible available. It's up to the user to resize it afterwards if they need it at a lower resolution.
2. Let users set target resolution OR target aspect ratio
Similar to CameraX, the user could set either a target resolution OR an aspect ratio but not both at the same time.
When setting a target resolution, images taken might have a different resolution than the target resolution, but should be close. Aspect ratio might not be the same.
When setting an aspect ratio, target resolution would be the best possible available (like now). It's up to the user to resize it afterwards if they need it at a lower resolution.
3. Set target resolution AND aspect ratio
Let the user set a target resolution and a target aspect ratio.
a. Aspect ratio priority
Set only the target aspect ratio to CameraX to ensure we get the same aspect ratio.
Resize the image captured to match the target resolution.
b. Target resolution priority
Set only the target resolution to CameraX to ensure we get a close resolution.
Scale / crop the image captured to match the target aspect ratio.
Other possible improvement
- Add the size of the picture taken to
MediaCapture
iOS side
To be completed.