Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

803
Views
Convert image into binary file in React Native

I am new to react native and I am practicing converting images into binary files. I randomly downloaded the image from the internet. I am trying to convert images into binary files to upload to the server through API. The server takes input as a binary file. I have attached the code below. I searched on the internet but could not find the solution.

import React from 'react'
import {
    View,
    Text,
    StyleSheet,
    Image,
    Button,
    Alert
} from 'react-native'


let imagePath = './src/image/macTest.jpeg'

const imageToBinary = (imagePath) => {
    //Alert.alert(imagePath)

// this function needs to convert image into the binary file
}

const App = () => {
    return (
        <View>
            <Text style={styles.headerStyle}> Image </Text>

            <Image
                style={styles.imageStyle}
                source= {require('./src/image/macTest.jpeg')}
            />

            <Button 
                title="Binary Value"
                onPress={() => imageToBinary(imagePath)}
            />

            <View style= {styles.binaryStyle}>
               <Text>
               // binary value of the image
               </Text>
            </View>
        </View>
    )
}

const styles = StyleSheet.create({

    headerStyle:{
        fontSize: 20,
        textAlign: 'center',
        margin: 15
    },

    imageStyle:{
        alignItems: 'center',
        height: 300,
        width: 450,
    },

    binaryStyle: {
        borderWidth: 1,
        borderColor: 'black',
        width: 400,
        height: 250,
        margin: 5
    }

})

export default App;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you're using Expo there is FileSystem:

https://docs.expo.dev/versions/latest/sdk/filesystem/#filesystemreadasstringasyncfileuri-options

Example:

const img = await FileSystem.readAsStringAsync(photo.uri, { encoding: 'base64' });

Another alternative is react-native-image-picker:

https://www.npmjs.com/package/react-native-image-picker

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!