New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fast-imagemin-cli

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-imagemin-cli

A tool for fast secondary compression of images.

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
2
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

A tool for fast secondary compression of images.

Version Languages License Star Download

Inspired by easy-tinypng-cli and vite-plugin-imagemin

Why

In the daily production mode, it is always necessary to compress a large number of image resources.

  • When using vite-plugin-imagemin, it has to be recompressed every time you build, which I think is unnecessary.
  • When using easy-tinypng-cli, it needs to be connected to the Internet, and there is a limit of 500, which cannot meet a large number of processing.

so, a compression tool that can be locally unlimited and can avoid duplication of work is needed.

Usage

Install

# pnpm
pnpm install fast-imagemin-cli -D

# npm
npm install fast-imagemin-cli -D

# yarn
yarn add fast-imagemin-cli -D

CHANGELOGS

0.1.0

  • Feat⭐: Added the function of backing up the original image

China installation note

(The scheme is extracted to vite-plugin-imagemin)

Because imagemin is not easy to install in China. Several solutions are now available

  • Use yarn to configure in package.json (recommended)
"resolutions": {
    "bin-wrapper": "npm:bin-wrapper-china"
  },
  • Use npm, add the following configuration to the computer host file
199.232.4.133 raw.githubusercontent.com
  • Install with cnpm (not recommended)

Config

fm.config.ts or fm.config.json

  • inclde(required): The image directory that needs to be compressed will be automatically traversed recursively.
  • options: Imagemin configuration items
// fm.config.ts
import { defineFmConfig } from 'fast-imagemin-cli/support'

export default defineFmConfig({
  include: ['./src/assets'], // string | string[]
  backup: false, // backup origin image  verison 0.1.0
  options: {
    gifsicle: {
      optimizationLevel: 7,
      interlaced: false,
    },
    optipng: {
      optimizationLevel: 7,
    },
    mozjpeg: {
      quality: 20,
    },
    pngquant: {
      quality: [0.8, 0.9],
      speed: 4,
    },
    svgo: {
      plugins: [
        {
          name: 'removeViewBox',
        },
        {
          name: 'removeEmptyAttrs',
          active: false,
        },
      ],
    },
  },
})

Options

paramstypedefaultdefault
svgoobject or false-See Options
gifsicleobject or false-See Options
mozjpegobject or false-See Options
optipngobject or false-See Options
pngquantobject or false-See Options
webpobject or false-See Options

Add Script

// package.json
{
  "scripts": {
    "fm": "fm" // or "fm --force" forced compression
  }
}

Demo

packages/playground xlegex

first

You will find that one of the .png files takes up to 76930ms. If it takes so long each time, it will greatly affect the work efficiency.

second

Keywords

imagemin

FAQs

Package last updated on 24 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts