Fix expo-camera corrupting JPEG files on Android by using skipProcessing, lowering quality, and adding file flush delay
This commit is contained in:
@@ -235,12 +235,16 @@ export default function CameraScreen({
|
|||||||
console.log('Capturing from built-in camera fallback...');
|
console.log('Capturing from built-in camera fallback...');
|
||||||
if (expoCameraRef.current) {
|
if (expoCameraRef.current) {
|
||||||
const photo = await expoCameraRef.current.takePictureAsync({
|
const photo = await expoCameraRef.current.takePictureAsync({
|
||||||
quality: 0.95,
|
quality: 0.7, // Lower quality slightly to reduce file size and OOM risk
|
||||||
skipProcessing: false,
|
skipProcessing: true, // Crucial for Android tablets: prevents internal OOM that corrupts the image file
|
||||||
});
|
});
|
||||||
capturedUri = photo.uri;
|
capturedUri = photo.uri;
|
||||||
rawWidth = photo.width;
|
rawWidth = photo.width;
|
||||||
rawHeight = photo.height;
|
rawHeight = photo.height;
|
||||||
|
|
||||||
|
// Wait 500ms to ensure the OS has completely flushed the file to disk.
|
||||||
|
// This prevents "Loading bitmap failed" when ImageManipulator reads it too fast.
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Kamera-Referenz ist nicht verfügbar.');
|
throw new Error('Kamera-Referenz ist nicht verfügbar.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user