npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@yohacoo/gulp-image-compress

v1.0.0

Published

gulp plugin to compress images using sharp

Readme

@yohacoo/gulp-image-compress

Gulp plugin to compress images. This version compress jpeg, png, webp and svg images. Other files skip compression.

Install

npm install --save-dev @yohacoo/gulp-image-compress

Usage

import gulp from 'gulp';
import imageCompress from '@yohacoo/gulp-image-compress';

function compressImages(cb) {
  gulp
    .src('src/images/**/*', { encoding: false })
    .pipe(imageCompress())
    .pipe(gulp.dest('dist/images'));
  cb();
}

export default compressImages;

Make sure to add { encoding: false } to gulp.src from Gulp 5. Otherwise, you'll get an unsupported image format error.

With options

import gulp from 'gulp';
import imageCompress from '@yohacoo/gulp-image-compress';

function compressImages(cb) {
  gulp
    .src('src/images/**/*', { encoding: false })
    .pipe(
      imageCompress({
        jpeg: { quality: 85, progressive: true },
        png: { quality: 85, progressive: true },
        webp: { quality: 85, alphaQuality: 85 },
        svg: {
          plugins: [
            {
              name: 'preset-default',
              params: {
                overrides: {
                  cleanupIds: false,
                },
              },
            },
            'removeDimensions',
          ],
        },
        allowLargerOutput: true,
        verbose: true,
      })
    )
    .pipe(gulp.dest('dist/images'));
  cb();
}

export default compressImages;

This plugin compressed with sharp and optimize with svgo. jpeg, png, webp options are passed to sharp as is. Similarly, svg option is passed to svgo. In this example, svgo's preset-default is customized: cleanupIds plugin is disabled, and removeDimensions plugins is enabled.

If you set verbose to true, you can see the compression results for each file.

Note

If the compression output by sharp is larger than the input, this plugin returns the original input data by default. You can change this behavior by setting options.allowLargerOutput to true.

API

imageCompress(options?)

options

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | object | | compression options | | [options.jpeg] | object | { quality: 80 } | jpeg options for sharp | | [options.png] | object | { quality: 80 } | png options for sharp | | [options.webp] | object | { quality: 80 } | webp options for sharp | | [options.svg] | object | { plugins: [ { name: 'preset-default' } ] } | svg options for svgo, default to preset-default | | [options.allowLargerOutput] | boolean | false | allow larger output than input | [options.verbose] | boolean | false | log info on every image |