Skip to content

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

@vbmaarten

Description

@vbmaarten

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions