npm.io
1.0.2 • Published 11h ago

@imagepix/client

Licence
MIT
Version
1.0.2
Deps
0
Size
13 kB
Vulns
0
Weekly
0

CI License NPM Version

imagepix client

Resize, crop and convert images dynamically using imagepix.

Getting Started

Installation
npm install @imagepix/client
Usage
Resize to fit

Get an imagepix url to resize image keep aspect ratio.

import { getResizeToFitUrl } from '@imagepix/client'
getResizeToFitUrl('sample/landscape.png', {
  width: 300,
  height: 300,
  format: 'webp',
  quality: 80
}, { subdomain: 'demo' })

https://demo.imagepix.app/fit/300/300/webp/80/sample/landscape.png

When you set environment variable IMAGEPIX_SUBDOMAIN, you can also write following:

getResizeToFitUrl('sample/landscape.png', {
  width: 300,
  height: 300,
  format: 'webp',
  quality: 80
})
Resize to fill

Get an imagepix url to resize and crop image.

import { getResizeToFillUrl } from '@imagepix/client'
getResizeToFillUrl('sample/landscape.png', {
  width: 300,
  height: 300,
  gravity: 'c',
  format: 'webp',
  quality: 80
}, { subdomain: 'demo' })

https://demo.imagepix.app/fill/300/300/c/webp/80/sample/landscape.png

When you set environment variable IMAGEPIX_SUBDOMAIN, you can also write following:

getResizeToFillUrl('sample/landscape.png', {
  width: 300,
  height: 300,
  gravity: 'c',
  format: 'webp',
  quality: 80
})
Resize to fill_pad

Get an imagepix url to resize image and fill background.

import { getResizeToFillPadUrl } from '@imagepix/client'
getResizeToFillPadUrl('sample/landscape.png', {
  width: 300,
  height: 300,
  gravity: 'c',
  background: 'red',
  format: 'webp',
  quality: 80
}, { subdomain: 'demo' })

https://demo.imagepix.app/fill_pad/300/300/c/red/webp/80/sample/landscape.png

When you set environment variable IMAGEPIX_SUBDOMAIN, you can also write following:

getResizeToFillPadUrl('sample/landscape.png', {
  width: 300,
  height: 300,
  gravity: 'c',
  background: 'red',
  format: 'webp',
  quality: 80
})

Supported format

Input
  • jpeg
  • png
  • webp (including animated)
  • gif (including animated)
  • avif
  • jpeg xl
  • svg
  • ico
  • heif / heic
  • bmp
  • tiff
Output
  • jpeg
  • png
  • webp (including animated)
  • gif (including animated)

Parameter limits

  • width / height: 1 to 2560
  • quality: 1 to 100

License

imagepix client is licensed under a MIT License.

Keywords