项目作者: tjuretzek

项目描述 :
A lightweight image compressor (with little to no quality loss) on gulp basis using node.js. The compression-rate is optimized, but do not expect file sizes to be as small as lossy compressed (e.g. tinypng.org) images. This project was created to compress large amounts of files or images with a huge file size (e.g. 4K resolution images).
高级语言: JavaScript
项目地址: git://github.com/tjuretzek/gulp-image-compressor.git
创建时间: 2017-06-19T10:22:08Z
项目社区:https://github.com/tjuretzek/gulp-image-compressor

开源协议:

下载


Gulp Image Compressor

This is a lightweight image compressor (with little to no quality loss) on gulp basis using node.js. The compression-rate is optimized for the best image quality:size ratio, but do not expect file sizes to be as small as lossy compressed (e.g. TinyPNG) images. However I managed to compress the included sample files to a lower file size than TinyPNG risking a slightly higher quality loss.

This project was created to compress large amounts of files or images with a huge file size (e.g. 4K resolution images). Small images files are crutial for search engine optimization (SEO) these days, that’s why I felt the need to create this project.

You can use this repository as a standalone image compressor or include it into your gulp routine by using the images task.

NOTE: Images may appear not as sharp as you want them to. You can always adjust the settings inside the tasks/images.js file, to increase quality AND filesize.

Development dependencies

Please be sure to have at least Git, NodeJS v7.10.0 installed. It is also recommented to use NPM v4.2.0

You’ll also need NVM to be able to run the setup

Setup

You can setup the compressor by running

  1. npm run setup

Windows setup

To setup the project for windows machines use

  1. npm run windows

Using the compressor

To compress all images inside the original-images folder just run

  1. npm start

The compressed-images folder will be cleared every time you run the npm run setup, npm run compress or npm start command.

Compress

To compress your images, just use:

  1. npm run compress

This will delete all images inside the compressed-images folder and recompress them.

If you want to keep your compressed images and want to compress new ones, use:

  1. gulp images

Convert

If you want to use the .webp and jpeg-2000 converter, just use:

  1. npm run convert

This command will generate .webp images from you .png, .jpg and .jpeg images.

!ATTENTION! You’ll need imagemagick installed on your system
To install imagemagick via homebrew use

  1. brew install imagemagick

Wait for the compressor to finish

The compressor is done working as soon, as you see the message gulp-imagemin: Minified X images (saved X.XX MB - XX.XX%) inside the console/terminal.