Socket
Socket
Sign inDemoInstall

imagemin-webp

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemin-webp - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

27

index.js

@@ -5,6 +5,8 @@ 'use strict';

var imageType = require('image-type');
var path = require('path');
var through = require('through2');
var webp = require('cwebp-bin').path;
/**
* webp image-min plugin
* webp imagemin plugin
*

@@ -18,5 +20,15 @@ * @param {Object} opts

return function (file, imagemin, cb) {
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new Error('Streaming is not supported'));
return;
}
if (['jpg', 'png', 'tif'].indexOf(imageType(file.contents)) === -1) {
cb();
cb(null, file);
return;

@@ -36,6 +48,11 @@ }

if (file.path && typeof file.path === 'string') {
var name = path.basename(file.path, path.extname(file.path)) + '.webp';
file.path = path.join(path.dirname(file.path), name);
}
file.contents = buf;
cb();
cb(null, file);
});
};
});
};

11

package.json
{
"name": "imagemin-webp",
"version": "1.0.1",
"description": "webp image-min plugin",
"version": "1.0.2",
"description": "webp imagemin plugin",
"license": "MIT",

@@ -36,8 +36,11 @@ "repository": "imagemin/imagemin-webp",

"exec-buffer": "^1.0.0",
"image-type": "^1.0.0"
"image-type": "^1.0.0",
"through2": "^0.6.1"
},
"devDependencies": {
"ava": "^0.0.4",
"imagemin": "^1.0.3"
"buffer-equal": "0.0.1",
"is-webp": "^1.0.0",
"vinyl-file": "^1.1.0"
}
}

@@ -1,4 +0,4 @@

# imagemin-webp [![Build Status](https://travis-ci.org/imagemin/imagemin-webp.svg?branch=master)](https://travis-ci.org/imagemin/imagemin-webp)
# imagemin-webp [![Build Status](http://img.shields.io/travis/imagemin/imagemin-webp.svg?style=flat)](https://travis-ci.org/imagemin/imagemin-webp) [![Build status](https://ci.appveyor.com/api/projects/status/erd3nf73djfm4gjp)](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin-webp)
> webp image-min plugin
> webp imagemin plugin

@@ -16,16 +16,35 @@

```js
var Imagemin = require('image-min');
var Imagemin = require('imagemin');
var webp = require('imagemin-webp');
var imagemin = new Imagemin()
.src('foo.png')
.dest('foo-optimized.webp')
.src('images/*.{jpg,png}')
.dest('build/images')
.use(webp());
imagemin.optimize();
imagemin.run(function (err, files) {
if (err) {
throw err;
}
console.log('Files optimized successfully!');
});
```
You can also use this plugin with [gulp](http://gulpjs.com):
```js
var gulp = require('gulp');
var webp = require('imagemin-webp');
gulp.task('default', function () {
return gulp.src('images/*.{jpg,png}')
.pipe(webp())
.pipe(gulp.dest('build/images'));
});
```
## License
MIT © [imagemin](https://github.com/imagemin)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc