@capgo/camera-preview 7.4.0-alpha.1 → 7.4.0-alpha.3
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.
|
@@ -1040,12 +1040,40 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
1040
1040
|
saveImageToGallery(bytes);
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
|
-
String
|
|
1043
|
+
String resultValue;
|
|
1044
|
+
boolean returnFileUri =
|
|
1045
|
+
sessionConfig != null && sessionConfig.isStoreToFile();
|
|
1046
|
+
if (returnFileUri) {
|
|
1047
|
+
// Persist processed image to a file and return its URI to avoid heavy base64 bridging
|
|
1048
|
+
try {
|
|
1049
|
+
String fileName =
|
|
1050
|
+
"cpcp_" +
|
|
1051
|
+
new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(
|
|
1052
|
+
new java.util.Date()
|
|
1053
|
+
) +
|
|
1054
|
+
".jpg";
|
|
1055
|
+
File outDir = context.getCacheDir();
|
|
1056
|
+
File outFile = new File(outDir, fileName);
|
|
1057
|
+
FileOutputStream outFos = new FileOutputStream(outFile);
|
|
1058
|
+
outFos.write(bytes);
|
|
1059
|
+
outFos.close();
|
|
1060
|
+
|
|
1061
|
+
// Return a file path; apps can convert via Capacitor.convertFileSrc on JS side
|
|
1062
|
+
resultValue = outFile.getAbsolutePath();
|
|
1063
|
+
} catch (IOException ioEx) {
|
|
1064
|
+
Log.e(TAG, "capturePhoto: Failed to write image file", ioEx);
|
|
1065
|
+
// Fallback to base64 if file write fails
|
|
1066
|
+
resultValue = Base64.encodeToString(bytes, Base64.NO_WRAP);
|
|
1067
|
+
}
|
|
1068
|
+
} else {
|
|
1069
|
+
// Backward-compatible behavior
|
|
1070
|
+
resultValue = Base64.encodeToString(bytes, Base64.NO_WRAP);
|
|
1071
|
+
}
|
|
1044
1072
|
|
|
1045
1073
|
tempFile.delete();
|
|
1046
1074
|
|
|
1047
1075
|
if (listener != null) {
|
|
1048
|
-
listener.onPictureTaken(
|
|
1076
|
+
listener.onPictureTaken(resultValue, exifData);
|
|
1049
1077
|
}
|
|
1050
1078
|
} catch (Exception e) {
|
|
1051
1079
|
Log.e(TAG, "capturePhoto: Error processing image", e);
|