14.0.1 • Published 4 months ago

slicica v14.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 months ago

slicica npm version

diminutive for image in croatian

Image serving/resizing/optimizing Express/Connect middleware using sharp/libvips.

Intended for usage behind a proxy cache (e.g. nginx, varnish) or a CDN (e.g. CloudFlare) as it doesn't cache results on its own.

Install

npm add slicica

Installing this module will automatically fetch and build libvips and its dependencies on Linux, MacOS and Windows x64.

For more information read sharp's documentation.

Usage

app.use(require('slicica')(options))
const app = express()
const slicica = require('slicica')

app.use(
  slicica(
    // default options below
    {
      prefix: '/', // url prefix on which to serve the images
      root: '', // root folder / prefix to prepend to the requested image (path where the images reside)
      maxAge: 0, // takes seconds as integer || ms compatible string || false to disable
      progressive: false, // progressive scan for JPG and PNG
      quality: 80, // output quality for jpeg, webp, png, tiff
      compression: 6, // image compression level (0-9)
      etag: true, // generate and send the ETag header
      lastModified: true, // send the Last-Modified header
      cache: false, // options passed to sharp.cache
      concurrency: 0, // number of threads sharp will use (0 resets it to default = number of cores)
      contentTypes: ['image/jpeg', 'image/png', 'image/webp', 'image/tiff'], // content types to serve, other requests are ignored
    },
  ),
)

Request example

http://localhost:####/images/random.jpg?w=800
http://localhost:####/images/random.jpg?h=600
http://localhost:####/images/random.jpg?w=300&h=200&g=north
w // width
h // height
g = 'center' // gravity (north|northeast|east|southeast|south|southwest|west|northwest|center|centre)
if (w && h) {
  // crops to exact dimensions using the default or specified gravity
} else if (w || h) {
  // resizes preserving the aspect ratio
} else {
  // just pipes the original image as response
}

License

MIT © Stipe Kotarac (https://github.com/kotarac)

14.0.1

4 months ago

13.0.11

6 months ago

13.0.12

6 months ago

14.0.0

5 months ago

13.0.10

8 months ago

13.0.8

10 months ago

13.0.9

9 months ago

13.0.6

12 months ago

13.0.7

10 months ago

13.0.5

1 year ago

13.0.4

1 year ago

13.0.2

1 year ago

13.0.3

1 year ago

13.0.0

2 years ago

13.0.1

1 year ago

12.0.5

2 years ago

12.0.3

2 years ago

12.0.4

2 years ago

12.0.2

3 years ago

12.0.1

3 years ago

12.0.0

3 years ago

11.0.3

4 years ago

11.0.2

4 years ago

11.0.1

4 years ago

11.0.0

4 years ago

10.0.3

4 years ago

10.0.2

4 years ago

10.0.1

4 years ago

10.0.0

4 years ago

9.0.2

4 years ago

9.0.1

5 years ago

9.0.0

5 years ago

8.0.3

6 years ago

8.0.2

6 years ago

8.0.1

7 years ago

8.0.0

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

6.0.0

7 years ago

5.1.0

8 years ago

5.0.1

8 years ago

5.0.0

8 years ago

4.0.0

8 years ago

3.0.0

8 years ago

2.1.0

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago