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

webp-middleware

v0.4.0

Published

Generates and delivers JPG-, PNG- and TIFF-images on the fly as WebP-images if the client supports that format.

Downloads

169

Readme

WebP Express Middleware

Inspired by a post from Cloudinary, this middleware generates and delivers JPG-, PNG- and TIFF-images on the fly as WebP-images if the requesting client supports that format.

WebP is a new image format from Google that provides lossless and lossy compression for images on the web. For more information please read the official documentation or the article on html5rocks.com about image compression.

Installation

npm install webp-middleware

Usage

var http = require('http');
var express = require('express');
var webp = require('webp-middleware');

var app = express();

app.use(webp(__dirname + '/public', { ... }));
app.use(express.static(__dirname + '/public'));

It is important to insert the webp middleware before the express.static middleware.

First parameter is the path of the static folder.

Second parameter is an optional options object.

You can also have a look into the example folder for examples.

Options

  • cacheDir is the directory where the webp files are saved. Default is a folder webp-cache in the executing directory (path.join(process.cwd(), 'webp-cache'))
  • preset delegates to the -preset option at cwebp
  • quality delegates to the -q option at cwebp
  • alphaQuality delegates to the -alpha_q option at cwebp
  • method delegates to the -m option at cwebp
  • segments delegates to the -segments option at cwebp
  • bytes delegates to the -size option at cwebp
  • psnr delegates to the -psnr option at cwebp
  • size delegates to the -s option at cwebp. Should be an object with width and height keys
  • spatialNoiseShaping delegates to the -sns option at cwebp
  • filter delegates to the -f option at cwebp
  • strong delegates to the -strong option at cwebp. Should be a boolean value
  • noStrong delegates to the -nostrong option at cwebp. Should be a boolean value
  • partitionLimit delegates to the -partition_limit option at cwebp
  • pass delegates to the -pass option at cwebp
  • crop delegates to the -crop option at cwebp. Should be an object with width, height, x and y keys
  • resize delegates to the -resize option at cwebp. Should be an object with width and height keys
  • multiThreading delegates to the -mt option at cwebp. Should be a boolean value
  • lowMemory delegates to the -low_memory option at cwebp. Should be a boolean value
  • alphaMethod delegates to the -alpha_method option at cwebp
  • alphaCleanup delegates to the -alpha_cleanup option at cwebp. Should be a boolean value
  • noAlpha delegates to the -noalpha option at cwebp. Should be a boolean value
  • lossless delegates to the -lossless option at cwebp. Should be a boolean value
  • hint delegates to the -hint option at cwebp
  • metadata delegates to the -metadata option at cwebp

License

Licensed under the MIT License.