Skip to content

Repository files navigation

@frogebot/image

Image processing module, designed for FrogeBot


Installation

$ npm i @frogebot/image

Use

letfrogeImage=require("@frogebot/image")(options);

Options

imageMagick (bool, optional) - If set to true, will use ImageMagick instead of GraphicsMagick

maxImageSize (int) - The maximum size for input images

maxGifSize (int) - The maximum size for input GIFs

Manipulating images

The exec and execGM functions return image buffers.

// Using JimpawaitfrogeImage.exec(imageUrl,list)// Using GraphicsMagick / ImageMagickawaitfrogeImage.execGM(imageUrl,list)

Custom Methods

These functions can access any methods in their respective libraries and also certain custom methods.

addBackground: Adds a coloured background and applies size change and image offset.

jpeg: JPEG-ifies image (GraphicsMagick/ImageMagick only)

square: Crops image to square (jimp only)

composite: Uses sharp for compositing images, works both in Jimp and GraphicsMagick/ImageMagick

Example implementation

letimageUrl="https://github.com/FrogeBot/frogeBot/blob/master/assets/icon.png?raw=true"letlist=[["explode",[1.5]],["jpeg",[10]]]fs.write("out.png",awaitfrogeImage.execGM(imageUrl,list),(err)=>{if(err)console.log(err)elseconsole.log("Wrote to out.png")})

Other functions

performMethod,customMethod// Exposes the functions used by exec and execGM to for individual methods on image data.readURL// Reads a URL and returns a parsed gm image.jimpReadURL// Reads a URL and returns a parsed jimp image.readBuffer// Reads an image buffer and returns a parsed jimp image.measureText// Measure text using jimp text.measureTextHeight// Measure text height using jimp text.gmToBuffer// Promisified gm.toBuffer() using url in.getFormat// Promisified gm.format() using url in.loadFont// Load and resolve font using jimp text.

About

Image processing module, designed for FrogeBot

Resources

Stars

0 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages