1.2.1 • Published 2 years ago

@frogebot/image v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@frogebot/image

Image processing module, designed for FrogeBot


Installation

$ npm i @frogebot/image

Use

let frogeImage = 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 Jimp
await frogeImage.exec(imageUrl, list)

// Using GraphicsMagick / ImageMagick
await frogeImage.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

let imageUrl = "https://github.com/FrogeBot/frogeBot/blob/master/assets/icon.png?raw=true"
let list = [
  ["explode", [1.5]],
  ["jpeg", [10]]
]
fs.write("out.png", await frogeImage.execGM(imageUrl, list), (err) => {
  if (err) console.log(err)
  else console.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.
1.2.0

2 years ago

1.2.1

2 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago