Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Node sharp image combine without repeating

I’m using node sharp image manipulation library to combine two images .One image is small and I want to add it to the top left of larger image.

This is the code I’m using

const output = await sharp('sea.png')
  .composite([
    { input: 'circle.png', tile: true, blend: 'over' }
  ])
  .toFile('combined.png');

This is the output

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Combined image

Is there a way to avoid repeating ?

>Solution :

The problem is that you are using tile:true which tells sharp to repeat the image. According to documentation:

images[].tile Boolean set to true to repeat the overlay image across
the entire image with the given gravity. (optional, default false)
https://sharp.pixelplumbing.com/api-composite#composite

So, making it like that should stop repeating

const output = await sharp('sea.png')
  .composite([
    { input: 'circle.png', blend: 'over' }
  ])
  .toFile('combined.png');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading