How to use the jimp.MIME_PNG function in jimp

To help you get started, we’ve selected a few jimp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NiGhTTraX / mugshot / tests / node / suite.ts View on Github external
// eslint-disable-next-line no-restricted-syntax
  for (const row of rows) {
    let x = 0;

    // eslint-disable-next-line no-restricted-syntax
    for (const pixel of row) {
      // eslint-disable-next-line no-await-in-loop
      await j.setPixelColor(getHexFromChar(pixel), x, y);

      x++;
    }

    y++;
  }

  return j.getBufferAsync(Jimp.MIME_PNG);
}
github nuxt-community / modules / modules / icon / index.js View on Github external
return Promise.all(sizes.map(size => new Promise((resolve, reject) => {
      srcIcon.clone().contain(size, size).getBuffer(Jimp.MIME_PNG, (err, buff) => {
        if (err) {
          return reject(err)
        }
        let fileName = `icons/icon_${size}.${hash}.png`
        resolve({ size, buff, fileName })
      })
    }))).then(icons => {
      // Fill manifest icons
github pmlrsg / GISportal / app / lib / proxy.js View on Github external
jimp.read(url, function(err, image) { // Gets the image file from the URL
            if (err) {
               utils.handleError(err, res);
            } else if (image) {
               image.getBuffer(jimp.MIME_PNG, function(err2, image2) { // Buffers the image so it sends correctly
                  if (err2) {
                     utils.handleError(err2, res);
                  } else {
                     res.setHeader('Content-type', 'image/png'); // Makes sure its a png
                     res.send(image2); // Sends the image to the browser.
                  }
               });
            } else {
               res.status(404).send();
            }
         });
      } else {
github SyntonicApps / slackicons / src / slackicons.js View on Github external
// Write image to buffer to read in with jimp
    const imageBuffer = await streamToBuffer(savePixels(imageArr, 'png'));

    const image = await jimpRead(imageBuffer);

    // Rotate image random number of degrees
    const degrees = Math.floor(rng() * 360);
    image.rotate(degrees, false);

    const CROP_CONST = 0.146892655; // TODO: is this even right?
    let cropPos = imageSize * CROP_CONST;
    image.crop(cropPos, cropPos, size, size);

    const imageGetBuffer = Promise.promisify(image.getBuffer, { context: image });
    return await imageGetBuffer(jimp.MIME_PNG);
};
github AnalyticalGraphicsInc / gltf-pipeline / lib / encodeImages.js View on Github external
function encodeImages(gltf) {
    var images = gltf.images;
    var promises = [];
    for (var imageId in images) {
        if (images.hasOwnProperty(imageId)) {
            var image = images[imageId];
            var pipelineExtras = image.extras._pipeline;
            if (pipelineExtras.imageChanged) {
                // re-encode the jimp image here to a buffer that can be put in source
                var mime;
                switch (pipelineExtras.extension) {
                    case '.png':
                        mime = Jimp.MIME_PNG;
                        break;
                    case '.jpeg':
                        mime = Jimp.MIME_JPEG;
                        break;
                    case '.jpg':
                        mime = Jimp.MIME_JPEG;
                        break;
                    case '.bmp':
                        mime = Jimp.MIME_BMP;
                        break;
                }
                promises.push(loadImageSource(pipelineExtras, mime));
            }
        }
    }
    return Promise.all(promises)
github NiGhTTraX / mugshot / packages / mugshot / src / lib / jimp-processor.ts View on Github external
img: Buffer,
    x: number,
    y: number,
    w: number,
    h: number,
    c: string
  ) => {
    const j = await Jimp.read(img);

    JimpProcessor.checkBounds(j, x, y, w, h);

    const colorSquare = new Jimp(w, h, c);

    await j.composite(colorSquare, x, y);

    return j.getBufferAsync(Jimp.MIME_PNG);
  };
github ameerthehacker / better-default-avatar / src / utils.js View on Github external
getMime(mime) {
    mime = mime || "";

    switch (mime.toLowerCase()) {
      case ("jpeg", "jpg"):
        return Jimp.MIME_JPEG;
      case "png":
        return Jimp.MIME_PNG;
      case "bmp":
        return Jimp.MIME_BMP;
      default:
        return Jimp.MIME_JPEG;
    }
  }
};
github wavebox / waveboxapp / src / app / src / Windows / MailboxesWindow / MailboxesWindowTouchBarProvider.js View on Github external
.then(([jimg, mask]) => {
        const masked = jimg.resize(64, 64).mask(mask, 0, 0)
        return masked.getBufferAsync(Jimp.MIME_PNG)
      })
  }
github Mitorisia / Komugari / commands / memes / shit.js View on Github external
}

        await message.channel.startTyping()

        const text = args;
        const shit = await Jimp.read('assets/images/shit.jpg');
        const blank = await Jimp.read('assets/images/Empty.png');

        const font = await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK);

        blank.resize(350, 350);
        const search = blank.print(font, 0, 0, text, 350);
        search.rotate(310);

        shit.composite(search, 195, 585);
        shit.getBuffer(Jimp.MIME_PNG, async(err, buffer) => {
            return await message.channel.send({
                files: [{
                    name: 'shit.png',
                    attachment: buffer
                }]
            })

            await message.channel.stopTyping()
        })

        return null;
    }
}