react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Sending a jpeg using XMLHttpRequest is increasing the file size on IOS

Open vbmaarten opened this issue 4 years ago • 1 comments

Description

Using XMLHttpRequest to upload a JPEG on IOS, increases the file size. Sending a compressed JPEG with XMLHttpRequest is uploading a file of which the file size is increased.

Executing the following will code will trigger the behaviour

const xhr = new XMLHttpRequest();
xhr.open('PUT', <FileUploadURL>);
xhr.send({uri: <Compressed JPEG uri>});

It seems to be that the following code is being executed on the IOS side

Libraries/Image/RCTImageLoader.mm
1104:      imageData = UIImageJPEGRepresentation(image, 1.0);

From what I understand, this code is uncompressing and then recompressing the JPEG file using the compressing value supplied to the call (1.0).

React Native version:

0.63.3

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Have a compressed JPEG file available
  2. Execute the code as provided above
  3. Inspect the difference between the original and the uploaded file

Expected Results

I expect that the original file is being uploaded, not a recompressed version with a different amount of compression

vbmaarten avatar Jun 01 '21 11:06 vbmaarten

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 03 '24 05:02 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Feb 10 '24 05:02 github-actions[bot]