Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda