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

241
Views
Rendering multiple image blob ulrs using react result in corrupted images

I'm trying to build an app that takes an image file as input, posts it to the server, and receives a styled image as blob URL. The problem is that some of the received images are sometimes corrupted. There is no pattern here and some of them are randomly corrupted. And sometimes it works fine with no corrupted images. Here are the relevant code snippets. I'm using django-rest framework for the backend.

var styled_images = []

function StyleTransferCarousel() {
    const [styledImages, setStyledImages] = useState([])
    const [styled, setStyled] = useState(false)

    // this function gets the image blob from server
    const getStyledImage = async (model) => {
            var formData = new FormData()
            ...
            try {
                const { data } = await axios.post('/style_transfer/stylev2/', formData, config)
                return data
            } catch (error) {...}
        }
    
    // this function gets the image blob untill the size of image list is equal to available models and re-renders
    async function getStyledImages() {
            var styledImageDict = {}
            for (let i = 0; i < models.length; i++) {
                var model_i = models[i]
                var data = getStyledImage(model_i)
                data.then(data => {
                    styledImageDict = {
                        image: "data:image/png;base64," + data.image,
                        model: models[i]
                    }
                    styled_images = styled_images.concat([styledImageDict])
                    if (styled_images.length !== models.length) {
                        setLoader(false)
                        setStyledImages(styled_images) //react hook
                    }
                })
            }

    }
    
// this is called once, if images are not styled
    useEffect(() => {
        if (models.length !== 0 && !styled) {
            //styled = true
            setStyled(true)
            getStyledImages()
            setLoader(true)
        }
    }, [models])
...
}

The images setStyledImages object are rendered. Some examples of corrupted images are below: enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
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!