0.2.0 • Published 7 years ago

image-editor v0.2.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Image editor

A image editor library

Example

const ie = require('image-editor');

ie.readFile('./input.png')
    .then(buffer => ie.edit(buffer, 'image/png', 'square', 'Hello'))
    .then(buffer => ie.writeFile(buffer, './output.png'))
    .then(() => console.log('Done'));

Dependencies

Like gm library, you need install GraphicsMagick on your computer.

API Reference

ImageEditor

  • ImageEditor
    • ImageEditor#edit(buffer, mimetype, type, text, color, fontSize, filter, customWidth, customHeight) => Promise
    • ImageEditor#readFile(path) => Promise
    • ImageEditor#writeFile(buffer, path) => Promise
    • ImageEditor#applyType(buffer, mimetype, type, customWidth, customHeight) => Promise
    • ImageEditor#applyFilter(buffer, mimetype, filter) => Promise
    • ImageEditor#size(buffer) => Promise
    • ImageEditor#write(buffer, text, width, height, position, color, fontSize) => Promise
    • ImageEditor#resize(buffer, width, height, option) => Promise
    • ImageEditor#crop(buffer, width, height, gravity, x, y) => Promise
    • ImageEditor#blur(buffer, radius, sigma) => Promise
    • ImageEditor#mono(buffer) => Promise
    • ImageEditor#sepia(buffer) => Promise
    • ImageEditor#mosaic(buffer) => Promise
    • ImageEditor#negative(buffer) => Promise
    • ImageEditor#paint(buffer, radius`) => Promise
    • ImageEditor#pixelate(buffer, mimetype, size) => Promise

ImageEditor#edit(buffer, mimetype, type, text, color, fontSize, filter, customWidth, customHeight)=> Promise

Edit an image

Kind: Exported function

ParamTypeDefault
bufferBuffer
mimetypestring
typestring"default"
textstringnull
colorstring"white"
fontSizenumber30
filterstringnull
customWidthnumber
customHeightnumber

ImageEditor#readFile(path) => Promise

Read file and return buffer

Kind: Exported function

ParamType
pathstring

ImageEditor#writeFile(buffer, path) => Promise

Write file from buffer to path

Kind: Exported function

ParamType
bufferBuffer
pathstring

ImageEditor#applyType(buffer, mimetype, type, customWidth, customHeight) => Promise

Apply type

Kind: Exported function

ParamTypeDefault
bufferBuffer
mimetypestring
typestring"default"
customWidthnumber
customHeightnumber

ImageEditor#applyFilter(buffer, mimetype, filter) => Promise

Apply filters

Kind: Exported function

ParamType
bufferBuffer
mimetypestring
filterstring

ImageEditor#size(buffer) => Promise

Get size of picture

Kind: Exported function

ParamType
bufferBuffer

ImageEditor#write(buffer, text, width, height, position, color, fontSize) => Promise

Write something on picture

Kind: Exported function

ParamTypeDefault
bufferBuffer
textstring
widthnumber0
heightnumber0
positionstring"Center"
colorstring"white"
fontSizenumber30

ImageEditor#resize(buffer, width, height, option) => Promise

Resize picture

Kind: Exported function

ParamTypeDefault
bufferBuffer
widthnumber
heightnumber
optionstringnull

ImageEditor#crop(buffer, width, height, gravity, x, y) => Promise

Crop picture

Kind: Exported function

ParamTypeDefault
bufferBuffer
widthnumber
heightnumber
gravitystring"Center"
xnumber0
ynumber0

ImageEditor#blur(buffer, radius, sigma) => Promise

Blur image

Kind: Exported function

ParamType
bufferBuffer
radiusnumber
sigmastring

ImageEditor#mono(buffer) => Promise

Mono

Kind: Exported function

ParamType
bufferBuffer

ImageEditor#sepia(buffer) => Promise

Sepia

Kind: Exported function

ParamType
bufferBuffer

ImageEditor#mosaic(buffer) => Promise

Mosaic

Kind: Exported function

ParamType
bufferBuffer

ImageEditor#negative(buffer) => Promise

Negative

Kind: Exported function

ParamType
bufferBuffer

ImageEditor#paint(buffer, radius`) => Promise

Paint

Kind: Exported function

ParamType
bufferBuffer
radius` | number

ImageEditor#pixelate(buffer, mimetype, size) => Promise

Pixelate

Kind: Exported function

ParamType
bufferBuffer
mimetypestring
sizenumber