How to use the imagemin.jpegtran function in imagemin

To help you get started, we’ve selected a few imagemin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kurtz1993 / ionic-minify / after_prepare / ionic-minify.js View on Github external
imagemin.src(file).dest(file).use(ImageMin.gifsicle({
                interlaced: true
            }));
            break;
        case '.png':
            console.log('Minifying PNG File: ' + file);
            // OptiPNG options https://github.com/imagemin/imagemin#optipng
            imagemin.src(file).dest(file).use(ImageMin.optipng({
                optimizationLevel: 2
            }));
            break;
        case '.jpg':
        case '.jpeg':
            console.log('Minifying JPEG File: ' + file);
            // jpegTran options https://github.com/imagemin/imagemin#jpegtran
            imagemin.src(file).dest(file).use(ImageMin.jpegtran({
                progressive: true
            }));
            console.log('Minifying JPEG File: ' + file);
            break;
        default:
            console.log('Encountered file with ' + ext + ' extension - not compressing.');
            break;
    }
}
github webframes / webframes / lib / util / minify.js View on Github external
function instantiate(type)
{
	var instance;
	
	switch(type)
	{
		case "gif":
		{
			if (!gif) gif = new Imagemin().use( Imagemin.gifsicle({interlaced:true}) );
			instance = gif;
			break;
		}
		case "jpeg":
		{
			if (!jpg) jpg = new Imagemin().use( Imagemin.jpegtran({progressive:true}) );
			instance = jpg;
			break;
		}
		case "png":
		{
			if (!png) png = new Imagemin().use( Imagemin.optipng({optimizationLevel:7}) );	// 0-7
			instance = png;
			break;
		}
		default:
		{
			if (!svg)
			{
				svg = new Imagemin().use( Imagemin.svgo({plugins:[
				{
					collapseGroups: false,
github sourcey / s3-image-optimizer / optimizer.js View on Github external
function process(meta, obj, next) {
      new Imagemin()
        .src(obj.Body)
        .use(Imagemin.jpegtran(imageminOptions))
        .use(Imagemin.gifsicle(imageminOptions))
        .use(Imagemin.optipng(imageminOptions))
        .use(Imagemin.svgo({plugins: imageminOptions.svgoPlugins || []}))
        .run(function(err, files) {
          if(err) return next(err);
          console.log('Optimized! Final file size reduced from ' + obj.Body.length + ' to ' + files[0].contents.length + ' bytes');
          next(null, meta, obj, files[0])
        });
    },
github rincojs / rinco-sg / lib / build.js View on Github external
m.img = function () {

  var Imagemin = require('imagemin');

  new Imagemin()
      .src(fs.path.join(config.IMG_DIR,'*.{gif,jpg,png,svg}'))
      .dest(fs.path.join(config.BUILD_DIR,'assets','img'))
      .use(Imagemin.jpegtran({progressive: true}))
      .use(Imagemin.gifsicle({interlaced: true}))
      .use(Imagemin.optipng({optimizationLevel: 3}))
      .use(Imagemin.svgo())
      .run(function (err, files) {
          files.map(function (file) {
              console.log(file);
              sh.echo('[ok]'.green);
          });
      });
};
github thangngoc89 / blog / old / scripts / imagemin.js View on Github external
import Imagemin from "imagemin"
import { join } from "path"

const distDir = join(__dirname, "../dist/")

new Imagemin()
  .src(distDir + "**/*.{gif,jpg,png}")
  .dest(distDir)
  .use(Imagemin.jpegtran({ progressive: true }))
  .use(Imagemin.optipng({ optimizationLevel: 3 }))
  .use(Imagemin.gifsicle({ interlaced: true }))
  .run((err, files) => {
    console.log("Optimized files: " + files.length)
    if (err) {
      console.error(err)
    }
  })
github react-rally / www / 2015 / imagemin.js View on Github external
var Imagemin = require('imagemin');
var pngquant = require('imagemin-pngquant');

new Imagemin()
  .src('assets/img/**/*.{gif,jpg,jpeg,png,svg}')
  .dest('assets/dist/img')
  .use(Imagemin.jpegtran({progressive: true}))
  .use(pngquant({quality: '65-80', speed: 4}))
  .run(function (err, files) {
    console.log(err, files);
  });
github alex-cory / portfolio / src / apis / github / index.js View on Github external
return new Promise((accept, reject) => {
		let func
		if (path.extname(image) == '.jpg' || path.extname(image) == '.jpeg') {
			func = Imagemin.jpegtran({progressive: true})
		} else if (path.extname(image) == '.png') {
			func = Imagemin.optipng({optimizationLevel: 3})
		} else if (path.extname(image) == '.gif') {
			func = Imagemin.gifsicle({interlaced: true})
		}
		new Imagemin()
			.src(`../../components/Work/Repo/img/${image}`)
			.dest('../../components/Work/Repo/img/')
			.use(func)
			.run(function (err, files) {
				return accept(files)
			})
	})
}

imagemin

Minify images seamlessly

MIT
Latest version published 6 months ago

Package Health Score

79 / 100
Full package analysis