Socket
Socket
Sign inDemoInstall

imagemin

Package Overview
Dependencies
37
Maintainers
7
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.1 to 8.0.0

30

index.js

@@ -1,11 +0,10 @@

'use strict';
const {promisify} = require('util');
const path = require('path');
const fs = require('graceful-fs');
const fileType = require('file-type');
const globby = require('globby');
const makeDir = require('make-dir');
const pPipe = require('p-pipe');
const replaceExt = require('replace-ext');
const junk = require('junk');
import {promisify} from 'util';
import path from 'path';
import fs from 'graceful-fs';
import {promises as fsPromises} from 'fs';
import FileType from 'file-type';
import globby from 'globby';
import pPipe from 'p-pipe';
import replaceExt from 'replace-ext';
import junk from 'junk';

@@ -23,4 +22,5 @@ const readFile = promisify(fs.readFile);

const {ext} = await FileType.fromBuffer(data);
let destinationPath = destination ? path.join(destination, path.basename(sourcePath)) : undefined;
destinationPath = (fileType(data) && fileType(data).ext === 'webp') ? replaceExt(destinationPath, '.webp') : destinationPath;
destinationPath = ext === 'webp' ? replaceExt(destinationPath, '.webp') : destinationPath;

@@ -37,3 +37,3 @@ const returnValue = {

await makeDir(path.dirname(returnValue.destinationPath));
await fsPromises.mkdir(path.dirname(returnValue.destinationPath), {recursive: true});
await writeFile(returnValue.destinationPath, returnValue.data);

@@ -44,3 +44,3 @@

module.exports = async (input, {glob = true, ...options} = {}) => {
export default async function imagemin(input, {glob = true, ...options} = {}) {
if (!Array.isArray(input)) {

@@ -64,5 +64,5 @@ throw new TypeError(`Expected an \`Array\`, got \`${typeof input}\``);

);
};
}
module.exports.buffer = async (input, {plugins = []} = {}) => {
imagemin.buffer = async (input, {plugins = []} = {}) => {
if (!Buffer.isBuffer(input)) {

@@ -69,0 +69,0 @@ throw new TypeError(`Expected a \`Buffer\`, got \`${typeof input}\``);

{
"name": "imagemin",
"version": "7.0.1",
"version": "8.0.0",
"description": "Minify images seamlessly",
"license": "MIT",
"repository": "imagemin/imagemin",
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},

@@ -28,20 +30,19 @@ "scripts": {

"dependencies": {
"file-type": "^12.0.0",
"globby": "^10.0.0",
"graceful-fs": "^4.2.2",
"file-type": "^14.6.0",
"globby": "^11.0.3",
"graceful-fs": "^4.2.6",
"junk": "^3.1.0",
"make-dir": "^3.0.0",
"p-pipe": "^3.0.0",
"replace-ext": "^1.0.0"
"p-pipe": "^4.0.0",
"replace-ext": "^2.0.0"
},
"devDependencies": {
"ava": "^2.1.0",
"del": "^4.1.1",
"imagemin-jpegtran": "^6.0.0",
"imagemin-svgo": "^7.0.0",
"imagemin-webp": "^5.0.0",
"ava": "^3.15.0",
"del": "^6.0.0",
"imagemin-jpegtran": "^7.0.0",
"imagemin-svgo": "^9.0.0",
"imagemin-webp": "^6.0.0",
"is-jpg": "^2.0.0",
"tempy": "^0.3.0",
"xo": "^0.24.0"
"tempy": "^1.0.1",
"xo": "^0.39.1"
}
}

@@ -1,15 +0,36 @@

# imagemin [![Build Status](https://travis-ci.org/imagemin/imagemin.svg?branch=master)](https://travis-ci.org/imagemin/imagemin)
# imagemin ![GitHub Actions Status](https://github.com/imagemin/imagemin/workflows/CI/badge.svg?branch=master)
> Minify images seamlessly
<br>
---
<div align="center">
<sup>Gumlet is helping make open source sustainable by sponsoring Sindre Sorhus.</sup>
<a href="https://www.gumlet.com">
<div>
<img src="https://sindresorhus.com/assets/thanks/gumlet-logo.svg" width="300"/>
</div>
<sup><b>Optimised Image Delivery made simple</b></sup>
</a>
<p>
<p>
<sup>
<a href="https://github.com/sponsors/sindresorhus">Sindre Sorhus' open source work is supported by the community</a>
</sup>
</p>
<sup>Special thanks to:</sup>
<br>
<br>
<a href="https://standardresume.co/tech">
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="180">
</a>
<br>
<br>
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=imagemin&utm_source=github">
<div>
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
</div>
<b>All your environment variables, in one place</b>
<div>
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
<br>
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
</div>
</a>
</p>
</div>

@@ -19,2 +40,3 @@

<br>

@@ -27,27 +49,23 @@ ## Install

## Usage
```js
const imagemin = require('imagemin');
const imageminJpegtran = require('imagemin-jpegtran');
const imageminPngquant = require('imagemin-pngquant');
import imagemin from 'imagemin';
import imageminJpegtran from 'imagemin-jpegtran';
import imageminPngquant from 'imagemin-pngquant';
(async () => {
const files = await imagemin(['images/*.{jpg,png}'], {
destination: 'build/images',
plugins: [
imageminJpegtran(),
imageminPngquant({
quality: [0.6, 0.8]
})
]
});
const files = await imagemin(['images/*.{jpg,png}'], {
destination: 'build/images',
plugins: [
imageminJpegtran(),
imageminPngquant({
quality: [0.6, 0.8]
})
]
});
console.log(files);
//=> [{data: <Buffer 89 50 4e …>, destinationPath: 'build/images/foo.jpg'}, …]
})();
console.log(files);
//=> [{data: <Buffer 89 50 4e …>, destinationPath: 'build/images/foo.jpg'}, …]
```
## API

@@ -83,3 +101,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `true`

@@ -86,0 +104,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc