@capgo/camera-preview 6.2.1 → 6.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,8 @@
13
13
 
14
14
  This plugin is compatible Capacitor 6 and above.
15
15
 
16
+ Use v5 for Capacitor 5 and below.
17
+
16
18
  **PR's are greatly appreciated.**
17
19
 
18
20
  -- [@riderx](https://github.com/riderx), current maintainers
@@ -877,17 +877,26 @@ public class CameraActivity extends Fragment {
877
877
  double targetRatio = (double) previewSize.width / previewSize.height;
878
878
  Camera.Size optimalSize = null;
879
879
  double minDiff = Double.MAX_VALUE;
880
+ long maxPixels = 0;
880
881
 
881
882
  for (Camera.Size size : supportedSizes) {
882
883
  double ratio = (double) size.width / size.height;
883
884
  if (Math.abs(ratio - targetRatio) > 0.1) continue;
884
- if (Math.abs(size.height - height) < minDiff) {
885
+
886
+ long pixels = (long) size.width * size.height;
887
+ if (pixels > maxPixels) {
888
+ maxPixels = pixels;
885
889
  optimalSize = size;
886
- minDiff = Math.abs(size.height - height);
890
+ } else if (pixels == maxPixels) {
891
+ if (Math.abs(size.height - height) < minDiff) {
892
+ optimalSize = size;
893
+ minDiff = Math.abs(size.height - height);
894
+ }
887
895
  }
888
896
  }
889
897
 
890
898
  if (optimalSize == null) {
899
+ Log.d(TAG, "No picture size matches the aspect ratio");
891
900
  minDiff = Double.MAX_VALUE;
892
901
  for (Camera.Size size : supportedSizes) {
893
902
  if (Math.abs(size.height - height) < minDiff) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "6.2.1",
3
+ "version": "6.2.4",
4
4
  "description": "Camera preview",
5
5
  "author": "Martin Donadieu <martindonadieu@gmail.com>",
6
6
  "license": "MIT",