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

173
Visualizações
fabric.Image.filters.Blend is not a constructor

The task

I am trying to blend an image over another image using Fabric JS.

From my research I found this Blend class that can be used to achieve this task. But I found the documentation unclear without any proper examples. So I referred and followed this answer as a guidance to proceed forward

My attempts

Here is the sample of my code. I want the image with the id image-2 to be blended by keeping image-1 in the background.

const firstImage = document.getElementById('image-1');
const secondImage = document.getElementById('image-2');

window.onload = () => {
  const canvas = new fabric.Canvas('previewCanvas');
  const bgImage = new fabric.Image(firstImage);
  const fgImage = new fabric.Image(secondImage)

  const filter = new fabric.Image.filters.Blend({
    image: fgImage,
    mode: 'multiply',
    alpha: 0.5
  });
  bgImage.filters.push(filter);
  bgImage.applyFilters(canvas.renderAll.bind(canvas));
  
  canvas.add(bgImage);
}
<img src="https://dummyimage.com/150x150/000/fff" id="image-1" />
<img src="https://dummyimage.com/150x150/404582/fff" id="image-2" />

<canvas id="previewCanvas"><canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.3.1/fabric.js" integrity="sha512-CzyxOXSECwo2nGJQZ2P8fdDxWVMVzn0jNdT2lYJ3afbqDJbaQ4qxgv9sLc85f6KP8HO2y929Bu+lnPKGC3ofSg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

As you can see when you run the above snippet I keep on receiving this error

Uncaught (in promise) TypeError: fabric.Image.filters.Blend is not a constructor

Why is that and how can this error be solved?

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