ImageBoss Typescript/Javascript API
This is an unofficial API for interacting with ImageBoss image manipulation via Javascript.
Installation
$> npm install --save imageboss-js
Or with Yarn:
$> yarn add imageboss-js
Usage
const { ImageBoss } = require('imageboss-js');
import { ImageBoss } from 'imageboss-js';
After importing the library, you can start manipulating images using getURL
. Let's check out an example:
ImageBoss.source = 'myimages';
const converted = ImageBoss.getURL('/image.png', {
operation: 'cover',
width: 500,
height: 300,
});
const converted = ImageBoss.getURL('/image.png', {
source: 'myimages',
operation: 'cover',
width: 500,
height: 300,
});
In this case, converted
will get the value "https://img.imageboss.me/myimages/cover/300x200/image.png"
You can use all the operations supported by ImageBoss
, like cdn
, width
, height
or cover
. All options like format
, gamma
, trim
or threshold
are also supported. Please check out the documentation of ImageBoss
in order to learn more: https://imageboss.me/docs
More examples
const path = '/image.png';
ImageBoss.source = 'myimages';
const converted = ImageBoss.getURL(path, {
operation: 'cover:center',
width: 500,
height: 300,
});
const converted = ImageBoss.getURL(path, {
operation: 'width',
width: 300,
});
const converted = ImageBoss.getURL(path, {
operation: 'height',
height: 300,
});
const converted = ImageBoss.getURL(path, {
operation: 'cdn',
});
const converted = ImageBoss.getURL(path, {
operation: 'width',
width: 700,
options: 'threshold:125'
});
const converted = ImageBoss.getURL(path, {
operation: 'width',
width: 700,
options: 'blur:2,grayscale:true'
});
Dev mode
Clone this repo, and start adding your code in the index.ts
file.
When you are done, write the tests in the index.test.ts
file. For testing, this repo works with Jest.
Dev Features
- Testing with Jest
- Linting with TSLint
- Works with Typescript
- Coverage, thanks to Jest
- Uses deterministic module resolving, with Yarn
Credits
Developed by Juan Camilo Guarín Peñaranda,
Otherwise SAS, Colombia
2018
License
MIT.
Support us on Patreon