Skip to content

base64 string got from ImageEditor.cropImage(uri) have linefeed after each 76 characters. #11142

@linus87

Description

@linus87

Description

I launched "react-native run-android" on MAC 10.11.6 (15G1004). I found when I use ImageEditor.cropImage(uri) to crop an image, the base64 text of image is not as my expected. Base64 text of image should be a whole string. But I found there is a linefeed after each 76 characters. When I put it as a JOSN object value, and stringify the JSON object. Then I try to parse this JSON object. I will meet a error: Unexpected Token. If I use base64Text.replace("\n", "").replace("\r",""), then It's ok;

for example:
ImageStore.getBase64ForTag(url, (base64Data) => {
let sImageBase64Data = "data:image/jpg;base64," + base64Data.replace(/\n|\r/g, "");
}

Solution

Replace all linefeed and carriage-return by base64Data.replace(/\n|\r/g, "").

Additional Information

  • React Native version: 0.29
  • Platform: Android
  • Operating System: MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueInterested in collaborating? Take a stab at fixing one of these issues.Help Wanted :octocat:Issues ideal for external contributors.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions