resizin
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

resizin

Bundlephobia

Core package for uploading images and building url of images from Resizin.

Table of contents

Installation

Using npm:

npm i -s resizin

Using yarn:

yarn add resizin

Quick start

import { buildUrlFactory, uploadFactory } from 'resizin';
import config from '../config';

// Uploading image
const upload = uploadFactory({
    apiKey: config.RESIZIN_API_KEY,
})

upload(files[0]);

// Building image url
const buildUrl = buildUrlFactory({
    bucket: 'ackee',
});
 
const imageUrl = buildUrl('walle',  {
    width: 250,
});

API

buildUrlFactory

buildUrlFactory(options: ClientOptions): function(imageId, modifiers)

interface ClientOptions {
    serverUrl?: string;
    bucket: string;
}

The factory returns buildUrl(imageId: string, modifiers: object) function.
The function returns url of an image that is available at image server adjusted according to a provided modifiers.

import { buildUrl } from 'resizin';

const buildUrl = buildUrlFactory({
    serverUrl: 'https://img.resizin.com',
    bucket: 'ackee',
});

const imageUrl = buildUrl(
    'walle', 
    {
        width: 250, 
        filter: 'sharpen', 
        backgroundColor: '00bcd4',
        border: [10, 60, 10, 10]
    }
);

const secondImageUrl = buildUrl('walle',  { filter: 'negative', rotate: 180 });

Here's how result images look like

Example image 1

imageUrl

Example image 2

secondImageUrl

For a complete list of usable modifiers look at the standalone modifiers section.

Usage tips

  • You can omit serverUrl option when it's https://img.resizin.com as it is a default value

    import { buildUrlFactory } from 'resizin';
    
    const buildUrl = buildUrlFactory({ bucket: 'ackee' });
  • buildUrlFactory is also default export from the package sou you can choose from two ways of importing it

    import { buildUrlFactory } from 'resizin';
    
    // is the same as a
    
    import buildUrlFactory from 'resizin';

    That gives you an ability to name the factory whatever you like at the phase of importing it.


Modifiers documentation


Upload factory documentation

License

MIT

Package Sidebar

Install

npm i resizin

Weekly Downloads

6

Version

0.9.0

License

MIT

Unpacked Size

53.9 kB

Total Files

40

Last publish

Collaborators

  • ackeecz