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...');
|
||||
if (expoCameraRef.current) {
|
||||
const photo = await expoCameraRef.current.takePictureAsync({
|
||||
quality: 0.95,
|
||||
skipProcessing: false,
|
||||
quality: 0.7, // Lower quality slightly to reduce file size and OOM risk
|
||||
skipProcessing: true, // Crucial for Android tablets: prevents internal OOM that corrupts the image file
|
||||
});
|
||||
capturedUri = photo.uri;
|
||||
rawWidth = photo.width;
|
||||
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 {
|
||||
throw new Error('Kamera-Referenz ist nicht verfügbar.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user