cataas-image-editor
v0.4.0
Published
Cataas image editor library
Downloads
3
Readme
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], [gravity]) => 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
| Param | Type | Default | | --- | --- | --- | | buffer | Buffer | | | mimetype | string | | | [type] | string | "default" | | [text] | string | null | | [color] | string | "white" | | [fontSize] | number | 30 | | [filter] | string | null | | [customWidth] | number | | | [customHeight] | number | |
ImageEditor#readFile(path) => Promise
Read file and return buffer
Kind: Exported function
| Param | Type | | --- | --- | | path | string |
ImageEditor#writeFile(buffer, path) => Promise
Write file from buffer to path
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer | | path | string |
ImageEditor#applyType(buffer, mimetype, [type], [customWidth], [customHeight]) => Promise
Apply type
Kind: Exported function
| Param | Type | Default | | --- | --- | --- | | buffer | Buffer | | | mimetype | string | | | [type] | string | "default" | | [customWidth] | number | | | [customHeight] | number | |
ImageEditor#applyFilter(buffer, mimetype, filter) => Promise
Apply filters
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer | | mimetype | string | | filter | string |
ImageEditor#size(buffer) => Promise
Get size of picture
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer |
ImageEditor#write(buffer, text, [width], [height], [position], [color], [fontSize]) => Promise
Write something on picture
Kind: Exported function
| Param | Type | Default | | --- | --- | --- | | buffer | Buffer | | | text | string | | | [width] | number | 0 | | [height] | number | 0 | | [position] | string | "Center" | | [color] | string | "white" | | [fontSize] | number | 30 |
ImageEditor#resize(buffer, width, [height], [option]) => Promise
Resize picture
Kind: Exported function
| Param | Type | Default | | --- | --- | --- | | buffer | Buffer | | | width | number | | | [height] | number | | | [option] | string | null |
ImageEditor#crop(buffer, width, height, [gravity], [x], [y]) => Promise
Crop picture
Kind: Exported function
| Param | Type | Default | | --- | --- | --- | | buffer | Buffer | | | width | number | | | height | number | | | [gravity] | string | "Center" | | [x] | number | 0 | | [y] | number | 0 |
ImageEditor#blur(buffer, radius, sigma) => Promise
Blur image
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer | | radius | number | | sigma | string |
ImageEditor#mono(buffer) => Promise
Mono
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer |
ImageEditor#sepia(buffer) => Promise
Sepia
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer |
ImageEditor#mosaic(buffer) => Promise
Mosaic
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer |
ImageEditor#negative(buffer) => Promise
Negative
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer |
ImageEditor#paint(buffer, radius`) => Promise
Paint
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer | | radius` | number |
ImageEditor#pixelate(buffer, mimetype, size) => Promise
Pixelate
Kind: Exported function
| Param | Type | | --- | --- | | buffer | Buffer | | mimetype | string | | size | number |