0.6.0 • Published 1 year ago

sharp-mozjpeg-image-processor v0.6.0

Weekly downloads
37
License
MIT
Repository
-
Last release
1 year ago

sharp-mozjpeg-image-processor

npm version Node Build & Test

Generates scaled (by sharp) and optimized (by mozjpeg) image files from a source image file

Install

$ npm i -save sharp-mozjpeg-image-processor

How to use

const fs = require('fs')
const { ImageProcessor } = require('sharp-mozjpeg-image-processor')

const processor = new ImageProcessor()

const srcStream = fs.createReadStream('./source.jpg')
const imgInfos = [
  {
    kind: 'large',
    width: 1200,
    height: 1200,
  },
  {
    kind: 'small',
    width: 800,
    height: 800,
  },
  {
    kind: 'thumb',
    width: 400,
    height: 400,
    crop: true, // cover for example thumbnail
  }
]
const quality = 70 // default 80 for jpeg image quality

processor.execute(srcStream, imgInfos, quality)
.then(outImgInfos => {
  for (let outImgInfo of outImgInfos) {
    console.log(outImgInfo)
  }
})
{
  kind: 'large',
  format: 'jpeg',
  width: 900,
  height: 1200,
  filePath: '/tmp/work897439499/optimized/large.jpg'
}
{
  kind: 'small',
  format: 'jpeg',
  width: 600,
  height: 800,
  filePath: '/tmp/work897439499/optimized/small.jpg'
}
{
  kind: 'thumb',
  format: 'jpeg',
  width: 400,
  height: 400,
  filePath: '/tmp/work897439499/optimized/thumb.jpg'
}
0.6.0

1 year ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.2.0

3 years ago

0.1.0

4 years ago