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

185
Visualizações
Is there a way to determine if a cross-origin image would taint the canvas without painting it?

I'm writing a script that allows a user to enter an image URL. I'd like to draw it to the canvas - but only if CORS policy allows me to do so without tainting the canvas. Is there a straightforward way of determining whether the image would taint the canvas without first drawing it to a canvas?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Since you've been given the URL, you can simply force the HTMLImageElement's crossOrigin to be set to "anonymous". If the image loads, it won't taint your canvas*, if its error event fired... you won't be able to draw it.

*Well, there is one case where this could still happen: if the image represents an other security threat for the browser, e.g svg images with <foreignObject> in Safari. For these edge cases, drawing on a 1x1 canvas is the only way to know.

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