npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

slicica

v14.0.1

Published

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

Downloads

33

Readme

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)