JSPM

optimize-images

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q45106F
  • License MIT

Middleware to optimize images via tinypng and serving optimized images

Package Exports

  • optimize-images

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (optimize-images) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Optimize Images

Github npm Build status Test coverage License

API

const optimizeImages = require('optimize-images')

optimizeImage(root, tinypngApiKey, [options])

Middleware optimizes the images from root directory, save them to disk and then serves the optimized images.

Example

const express = require('express')
const optimizeImages = require('optimize-images')

const app = express()

//generate from https://tinypng.com/developers
const tinypngApiKey = "YOUR_API_SECRET_KEY"
const root = "public"
const options = {
  dirName: "optimized-images" 
}

app.use(optimizeImages(root, tinypngApiKey, options)