All Projects → stnvh → gulp-tinypng-compress

stnvh / gulp-tinypng-compress

Licence: other
TinyPNG API wrapper for compressing PNG & JPG images

Projects that are alternatives of or similar to gulp-tinypng-compress

gulp-upload-qcloud
腾讯云 cos 静态资源上传 gulp 插件
Stars: ✭ 18 (-63.27%)
Mutual labels:  gulp, gulp-plugin
gulp-es6-transpiler
[DEPRECATED] Transpile ES2015 to ES5
Stars: ✭ 47 (-4.08%)
Mutual labels:  gulp, gulp-plugin
gulp-xo
Validate files with XO
Stars: ✭ 37 (-24.49%)
Mutual labels:  gulp, gulp-plugin
Glup
Some of the gulp tutorial -《gulp笔记》
Stars: ✭ 136 (+177.55%)
Mutual labels:  gulp, gulp-plugin
gulp-esbuild
gulp plugin for esbuild bundler
Stars: ✭ 39 (-20.41%)
Mutual labels:  gulp, gulp-plugin
Gulp Tap
Easily tap into a gulp pipeline without creating a plugin.
Stars: ✭ 158 (+222.45%)
Mutual labels:  gulp, gulp-plugin
gulp-sitemap
Generate a search engine friendly sitemap.xml using a Gulp stream
Stars: ✭ 60 (+22.45%)
Mutual labels:  gulp, gulp-plugin
Gulp Ftp
[DEPRECATED] Upload files to an FTP-server
Stars: ✭ 100 (+104.08%)
Mutual labels:  gulp, gulp-plugin
gulp-ava
Run AVA tests
Stars: ✭ 56 (+14.29%)
Mutual labels:  gulp, gulp-plugin
gulp-merge-json
A gulp plugin to merge JSON & JSON5 files into one file
Stars: ✭ 35 (-28.57%)
Mutual labels:  gulp, gulp-plugin
Gulp Bro
👊 gulp + browserify + incremental build, done right.
Stars: ✭ 119 (+142.86%)
Mutual labels:  gulp, gulp-plugin
gulp-px2rem
This is a gulp plugin for node-px2rem.
Stars: ✭ 19 (-61.22%)
Mutual labels:  gulp, gulp-plugin
Gulp Modernizr
Gulp wrapper for custom Modernizr builds
Stars: ✭ 111 (+126.53%)
Mutual labels:  gulp, gulp-plugin
Gulp Html Replace
Replace build blocks in HTML. Like useref but done right.
Stars: ✭ 222 (+353.06%)
Mutual labels:  gulp, gulp-plugin
Gulp Flatten
Gulp plugin: remove or replace relative paths for files
Stars: ✭ 102 (+108.16%)
Mutual labels:  gulp, gulp-plugin
gulp-sort
Sort files in stream by path or any custom sort comparator
Stars: ✭ 22 (-55.1%)
Mutual labels:  gulp, gulp-plugin
Gulp Plugin Boilerplate
Boilerplate to kickstart creating Gulp plugins
Stars: ✭ 74 (+51.02%)
Mutual labels:  gulp, gulp-plugin
Gulp Ngmin
[DEPRECATED] Pre-minify AngularJS apps with ngmin
Stars: ✭ 89 (+81.63%)
Mutual labels:  gulp, gulp-plugin
TinyPngPlugin
TinyPng gradle plugin for android
Stars: ✭ 240 (+389.8%)
Mutual labels:  tinypng, compress-images
tinypng-free
Use the upload api of tinypng's homeage to compress images
Stars: ✭ 29 (-40.82%)
Mutual labels:  gulp, tinypng

Version Downloaded Build

gulp-tinypng-compress

TinyPNG API wrapper for compressing PNG & JPG images

An actively maintained & developed fork of gulp-tinypng.

Main differences from gulp-tinypng:

  • File signature checking (to minimise unnecessary API calls, optional)
  • No temporary files/folders are created on compressed image download - fed straight from tinypng to the pipe
  • Maintained with the intention of standardising the tinypng featureset across gulp & grunt (and others too!)

Install

Requires node 6 or above

Install with npm - In your project folder, run:

npm install gulp-tinypng-compress

To run tests:

npm test

Example

var gulp = require('gulp');
var tinypng = require('gulp-tinypng-compress');

gulp.task('tinypng', function () {
	gulp.src('images/src/**/*.{png,jpg,jpeg}')
		.pipe(tinypng({
			key: 'API_KEY',
			sigFile: 'images/.tinypng-sigs',
			log: true
		}))
		.pipe(gulp.dest('images'));
});

API

tinypng([options])

Returns Stream containing compressed images

options

Type: Object / String Default: false

Sets options described below from its properties. If type is not object, string presumed (the API key)

options.key

Type: String Default: ''

Your TinyPNG API key to use for requests

options.sigFile

Type: String Default: ''

If set to a filename, it will compare existing source file md5 signatures against those found in the file's json data. When the signatures match, the file is skipped from being minified again, allowing you to better stay within your API request limits. When an image is minified, the md5 signature is determined from the unminified source image and written to the file at options.sigFile (a suggested location would be somewhere under your source control).

Signatures are based off the unminified source image, so that when the source changes it will be re-minified and re-written to the destination file.

options.sameDest

Type: Boolean Default false

If your source is the same as your destination (images are written over themselves), and you want to use the signature checking feature, set this to true

Note: If your source and destination are the same, it's recommended you use this, and options.sigFile, as it prevents you from continually uploading already compressed images each time you run the task

options.summarize/summarise

Type: Boolean Default: false

Outputs statistics once all images have been handled.

[09:47:43] gulp-tinypng-compress Skipped: 0 images, Compressed: 1 image, Savings: 3.98 KB (ratio: 0.4109)

options.log

Type: Boolean Default: false

Set to true to log errors & messages to the console. Errors are dispatched via events anyway, so plugins like gulp-plumber can handle these for you.

options.parallel

Type: Boolean Default: true

Enables concurrent uploads to the TinyPNG server to speed up total compression time.

(thanks HugoHeneault for this feature suggestion)

options.parallelMax

Type: Integer Default: 5

The amount of concurrent uploads allowed at one time, increase if you/your request limits can handle it - very easy to max out your monthly requests, use with caution!

options.force

Type: Boolean / String Default: false

Force compress images regardless of signature. Value can either be true to force all images, or a glob pattern string to match against the filename(s).

Can also be performed from the command line:

$ gulp png --forceupload 'icon-*.png'

This feature was added as it's impossible to know where the files are being written to at this point in the stream, unless the directory is directly passed into the config (pretty ugly). So the option was added to force certain (or all) files to be compressed when required.

options.ignore

Type: Boolean / String Default: false

Same as options.force except ignores files if the glob is matched

--ignore flag on the command line

Deprecated/non-functional options

options.checkSigs - Removed in favor of options.sigFile

License

MIT © Stan Hutcheon - Bigfork Ltd.

Original license:

MIT © Gaurav Jassal

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].