Socket
Book a DemoInstallSign in
Socket

slicica

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slicica

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

14.0.4
latest
Source
npmnpm
Version published
Weekly downloads
7
-22.22%
Maintainers
1
Weekly downloads
 
Created
Source

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)

Keywords

image

FAQs

Package last updated on 17 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.