Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda