Skip to content

Bug: Corrupted JPEG uploaded from Samsung Galaxy S24+ (Android 14) #2232

Description

@nicknamepiyapong

Description

Model: samsung S24+
Android: 16
One UI: 8.0

We are experiencing corrupted JPEG files generated by react-native-image-crop-picker only on Samsung Galaxy S24+ (Android 14).

The image:

Can be opened normally on the device

Has correct JPEG SOI (FFD8) and EOI (FFD9)

But fails to be processed on backend using libvips / sharp

Backend error:

VipsJpeg: Corrupt JPEG data: premature end of data segment

Image

This issue does not occur on other Android devices or iOS.

Environment

Device: Samsung Galaxy S24+

OS: Android 14

react-native-image-crop-picker: [please fill version]

React Native: [please fill version]

Backend image processor: libvips / sharp

Backend Debug Log

When the error occurs, backend logs show:

{
fileName: 'image',
contentType: 'image/jpg',
bufferLength: 49510,
jpegStartsCorrectly: true,
jpegEndsCorrectly: true,
firstBytes: 'ffd8ffe100764578696600004d4d002a',
lastBytes: 'bc5ee166e4cbb00fb0242000003fffd9'
}

Notes:

JPEG starts and ends correctly

File size is unusually small for images from S24+

libvips reports premature end of data segment, which suggests corrupted or incomplete scan data (possibly progressive JPEG related)

Steps to Reproduce

Use Samsung Galaxy S24+ (Android 14)

Capture image with:

ImageCropPicker.openCamera({
useFrontCamera: false,
cropping: false,
compressImageQuality: 0.6,
compressImageMaxWidth: 800,
compressImageMaxHeight: 800,
forceJpg: true,
})

Upload the image file (binary, multipart/form-data) to backend

Backend fails to decode JPEG using libvips/sharp

Expected Behavior

JPEG generated by the library should be fully valid and decodable by strict decoders such as libvips/sharp.

Actual Behavior

JPEG header and footer are valid

Internal scan data appears corrupted or incomplete

Backend fails with premature end of data segment

This strongly suggests the issue is related to:

Samsung camera pipeline

Progressive JPEG handling

File write / flush timing on Android 14

Additional Notes

Image viewers (Gallery, Chrome) can open the file normally

Only strict JPEG decoders fail

Issue seems Samsung-specific (S24+ so far)

Questions

Is progressive JPEG used by default on some Android devices?

Is there a known issue with Samsung Android 14 camera output?

Should the library enforce a safer re-encode path on certain devices?

🙏 Thank you for maintaining this library.
Happy to help provide sample files or additional logs if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions