#image gen

5 messages · Page 1 of 1 (latest)

robust spruce

So i want to generate a simple line image but the colour will be set from random hex gen which i have already defined.

width = 778 and height = 13

I tried doing it with sharp but it's showing download error can some one suggeste me another lib


const hexColor = '#FACADE'; //example color code
const width = 778;
const height = 13;

sharp({
  create: {
    width,
    height,
    channels: 4, // 4 channels: RGBA
    background: { r: 0, g: 0, b: 0, alpha: 0 } // transparent background
  }
})
  .composite([{ input: Buffer.from(hexColor.slice(1).match(/.{1,2}/g).map(h => parseInt(h, 16))), blend: 'over' }]) // convert hex color to RGBA and blend with the image
  .toFile('image.png', (err, info) => {
    if (err) throw err;
    console.log(info);
  });```
fervent coral

probably canvas, the package that discord.js uses in the guide i think is called rs-canvas

lemme just check

@napi-rs/canvas

narrow condor

you can use snappy