Coder Social home page Coder Social logo

imagemin-jpegoptim's Introduction

imagemin

Minify images seamlessly





Install

$ npm install imagemin

Usage

import imagemin from 'imagemin';
import imageminJpegtran from 'imagemin-jpegtran';
import imageminPngquant from 'imagemin-pngquant';

const files = await imagemin(['images/*.{jpg,png}'], {
	destination: 'build/images',
	plugins: [
		imageminJpegtran(),
		imageminPngquant({
			quality: [0.6, 0.8]
		})
	]
});

console.log(files);
//=> [{data: <Buffer 89 50 4e …>, destinationPath: 'build/images/foo.jpg'}, …]

API

imagemin(input, options?)

Returns Promise<object[]> in the format {data: Buffer, sourcePath: string, destinationPath: string}.

input

Type: string[]

File paths or glob patterns.

options

Type: object

destination

Type: string

Set the destination folder to where your files will be written. If no destination is specified, no files will be written.

plugins

Type: Array

Plugins to use.

glob

Type: boolean
Default: true

Enable globbing when matching file paths.

imagemin.buffer(buffer, options?)

Returns Promise<Buffer>.

buffer

Type: Buffer

Buffer to optimize.

options

Type: object

plugins

Type: Array

Plugins to use.

Related

imagemin-jpegoptim's People

Contributors

1000ch avatar kevva avatar philipbordallo avatar romellem avatar shinnn avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagemin-jpegoptim's Issues

"errorMessage": "spawn /var/task/node_modules/jpegoptim-bin/vendor/jpegoptim ENOENT",

Hi i am using imagemin compression on aws lambda, with imagemin-jpegoptim plugin . i am getting below error.

"errorMessage": "spawn /var/task/node_modules/jpegoptim-bin/vendor/jpegoptim ENOENT",
"errorType": "Error",
"stackTrace": [
"exports._errnoException (util.js:870:11)",
"Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)",
"onErrorNT (internal/child_process.js:344:16)",
"nextTickCallbackWith2Args (node.js:437:9)",
"process._tickDomainCallback (node.js:392:17)"

can anyone help on this

Update binaries

Older binaries doesn't support --stdin and --stdout options.

Got an error when used with gulp-imagemin v1.1.0

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
  at DestroyableTransform.addListener (events.js:160:15)
  at DestroyableTransform.once (events.js:185:8)
  at DestroyableTransform.Readable.pipe (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:581:8)
  at recurse (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/stream-combiner/index.js:27:16)
  at recurse (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/stream-combiner/index.js:28:5)
  at recurse (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/stream-combiner/index.js:28:5)
  at recurse (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/stream-combiner/index.js:28:5)
  at recurse (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/stream-combiner/index.js:28:5)
  at module.exports (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/stream-combiner/index.js:31:3)
  at Imagemin.run (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/index.js:82:13)
  at DestroyableTransform.percent (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/index.js:57:13)
  at Object.immediate._onImmediate (timers.js:363:16)
  at processImmediate [as _immediateCallback] (timers.js:345:15)


/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/each-async/node_modules/onetime/index.js:15
                throw new Error(fnName + ' can only be called once.');
                      ^
Error: callback() can only be called once.
  at /Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/each-async/node_modules/onetime/index.js:15:11
  at DestroyableTransform.<anonymous> (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/index.js:59:6)
  at Stream.emit (events.js:117:20)
  at DestroyableTransform.reemit (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/stream-combiner/node_modules/duplexer/index.js:85:16)
  at DestroyableTransform.emit (events.js:117:20)
  at writeAfterEnd (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:146:10)
  at DestroyableTransform.Writable.write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:192:5)
  at write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
  at flow (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
  at DestroyableTransform.pipeOnReadable (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
  at DestroyableTransform.emit (events.js:92:17)
  at emitReadable_ (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
  at emitReadable (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
  at readableAddChunk (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)
  at DestroyableTransform.Readable.push (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:149:10)
  at DestroyableTransform.Transform.push (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:145:32)
  at afterTransform (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:101:12)
  at TransformState.afterTransform (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
  at DestroyableTransform._transform (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-svgo/index.js:29:4)
  at DestroyableTransform.Transform._read (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
  at DestroyableTransform.Transform._write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
  at doWrite (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
  at writeOrBuffer (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
  at DestroyableTransform.Writable.write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
  at write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
  at flow (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
  at DestroyableTransform.pipeOnReadable (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
  at DestroyableTransform.emit (events.js:92:17)
  at emitReadable_ (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
  at emitReadable (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
  at readableAddChunk (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)
  at DestroyableTransform.Readable.push (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:149:10)
  at DestroyableTransform.Transform.push (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:145:32)
  at afterTransform (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:101:12)
  at TransformState.afterTransform (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
  at DestroyableTransform._transform (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/index.js:30:4)
  at DestroyableTransform.Transform._read (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
  at DestroyableTransform.Transform._write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
  at doWrite (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
  at writeOrBuffer (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
  at DestroyableTransform.Writable.write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
  at write (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
  at flow (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
  at DestroyableTransform.pipeOnReadable (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
  at DestroyableTransform.emit (events.js:92:17)
  at emitReadable_ (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
  at emitReadable (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
  at readableAddChunk (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)
  at DestroyableTransform.Readable.push (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:149:10)
  at DestroyableTransform.Transform.push (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:145:32)
  at afterTransform (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:101:12)
  at TransformState.afterTransform (/Users/Steve/Git/spuul-website/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
  at ChildProcess.<anonymous> (/Users/Steve/Git/spuul-website/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/index.js:65:4)
  at ChildProcess.emit (events.js:98:17)
  at maybeClose (child_process.js:756:16)
  at Process.ChildProcess._handle.onexit (child_process.js:823:5)

The error did not occur if I removed use: [jpegoptim()] from gulp task.

jpegoptim: invalid argument for option -d, --dest.

I have tried to use the jpegoptim plugin in my imagemin config but it fails with the following error:

Warning: Command failed: jpegoptim: invalid argument for option -d, --dest.

This is the configuration block I am using:

    imagemin: {
      dist: {
        options: {
          use: [jpegoptim({ progressive: true })]
        },
        files: [{
          expand: true,
          cwd: '<%= config.dist %>/assets/images/',
          src: ['**/*.{png,jpg,gif}'],
          dest: '<%= config.dist %>/assets/images/'
        }]
      }
    }

At the top of the Gruntfile I have:

var jpegoptim = require('imagemin-jpegoptim');

I'm not quite sure what causes the issue.

Error When Running Readme.md Example

When I run the example form readme.md, I get the following error:

[09:05:10] TypeError: Object function (file, imagemin, cb) {
        if (!isJpg(file.contents)) {
            cb();
            return;
        }

        var args = ['--strip-all', '--strip-iptc', '--strip-icc'];
        var exec = new ExecBuffer();

        if (opts.progressive) {
            args.push('--all-progressive');
        }

        mkdir(exec.dest(), function (err) {
            if (err) {
                cb(err);
                return;
            }

            exec.use(jpegoptim, args.concat(['--dest=' + exec.dest(), exec.src()]));
            exec.dest(path.join(exec.dest(), path.basename(exec.src())));
            exec.run(file.contents, function (err, buf) {
                    if (err) {
                        cb(err);
                        return;
                    }

                    file.contents = buf;
                    cb();
                });
        });
    } has no method 'on'
    at DestroyableTransform.Readable.pipe (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:516:8)
    at Gulp.<anonymous> (/Users/andrewjmead/code/dw-examples/image-optimization/gulpfile.js:6:6)
    at module.exports (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:121:20
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)

As a reference, the Gulpfile contents.

var gulp = require('gulp');
var jpegoptim = require('imagemin-jpegoptim');

gulp.task('default', function () {
  return gulp.src('public/images/*.jpg')
    .pipe(jpegoptim())
    .pipe(gulp.dest('build/images'));
});

Any idea what's going on here? It looks like imagemin-jpegoptim is no longer compatible with gulp.

Edit

The same error occurs when I use this plugin outside of gulp:

var Imagemin = require('imagemin');
var jpegoptim = require('imagemin-jpegoptim');

var imagemin = new Imagemin()
  .src('images/*.jpg')
  .dest('build/images')
  .use(jpegoptim());

imagemin.run(function (err, files) {
  if (err) {
    throw err;
  }

  console.log('Files optimized successfully!');
});

Error is:

/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/imagemin/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:516
  dest.on('unpipe', onunpipe);
       ^
TypeError: Object function (file, imagemin, cb) {
        if (!isJpg(file.contents)) {
            cb();
            return;
        }

        var args = ['--strip-all', '--strip-iptc', '--strip-icc'];
        var exec = new ExecBuffer();

        if (opts.progressive) {
            args.push('--all-progressive');
        }

        mkdir(exec.dest(), function (err) {
            if (err) {
                cb(err);
                return;
            }

            exec.use(jpegoptim, args.concat(['--dest=' + exec.dest(), exec.src()]));
            exec.dest(path.join(exec.dest(), path.basename(exec.src())));
            exec.run(file.contents, function (err, buf) {
                    if (err) {
                        cb(err);
                        return;
                    }

                    file.contents = buf;
                    cb();
                });
        });
    } has no method 'on'
    at DestroyableTransform.Readable.pipe (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/imagemin/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:516:8)
    at recurse (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/imagemin/node_modules/stream-combiner/index.js:27:16)
    at module.exports (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/imagemin/node_modules/stream-combiner/index.js:31:3)
    at Imagemin.run (/Users/andrewjmead/code/dw-examples/image-optimization/node_modules/imagemin/index.js:82:13)
    at Object.<anonymous> (/Users/andrewjmead/code/dw-examples/image-optimization/gulpfile.js:9:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Error: write EOF

Hi,

I'm getting the following error when using imagemin-jpegoptim:

events.js:72
throw er; // Unhandled 'error' event
^
Error: write EOF
at errnoException (net.js:904:11)
at Object.afterWrite (net.js:720:19)


Here is my gulpfile:

var gulp = require('gulp');

var sass      = require('gulp-ruby-sass'),
    jpegoptim = require('imagemin-jpegoptim'),
    pngquant  = require('imagemin-pngquant'),
    imagemin  = require('gulp-imagemin');

var paths = {
    imgSrc:  'html/src/img/**/*.{png,jpg,jpeg}',
    imgDst:  'html/img/'
};

// optimize images
gulp.task('images', function() {

    return gulp.src(paths.imgSrc)
        .pipe(imagemin({
            progressive: true,
            use: [pngquant(),jpegoptim({ progressive: true, max: 50})]
        }))
        .pipe(gulp.dest(paths.imgDst));

});

...


I hope someone can give me a hint how to fix this. :)

Thanks,
Martin

TypeError: Bad argument

Hello,

When I add jpegoptim in the use array, I get an error, but I can use the rest of the imagemin plugins.

This is the code:

var gulp = require('gulp');

var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var jpegoptim = require('imagemin-jpegoptim');
var jpegtran = require('imagemin-jpegtran');

gulp.task('optimg', () => {
    return gulp.src('public/assets/img/*')
        .pipe(imagemin({
            progressive: true,
            optimizationLevel: 4,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant(),jpegoptim()] // <-- with jpegtran() there is no problem
        }))
        .pipe(gulp.dest('public/assets/img'));
});

This is the error:

internal/child_process.js:274
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:274:26)
    at exports.spawn (child_process.js:339:9)
    at Through2._transform (/usr/local/lib/node_modules/imagemin-jpegoptim/index.js:51:12)
    at Through2.Transform._read (/usr/local/lib/node_modules/imagemin-jpegoptim/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Through2.Transform._write (/usr/local/lib/node_modules/imagemin-jpegoptim/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/usr/local/lib/node_modules/imagemin-jpegoptim/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/usr/local/lib/node_modules/imagemin-jpegoptim/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at Through2.Writable.write (/usr/local/lib/node_modules/imagemin-jpegoptim/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at Through2.ondata (/usr/local/lib/node_modules/imagemin-pngquant/node_modules/readable-stream/lib/_stream_readable.js:581:20)

Am I doing something wrong, or is it a bug?

Thank you very much.

Stripping ICC Color Profiles leads to some browsers rendering image differently

I noticed an issue when using jpegoptim that sometimes my images didn't always appear to be "losslessly" compressed depending on the browser I was using.

After some fiddling around with the binary and running it with my own command-line flags, I determined that stripping the ICC Color Profile Markers from the JPG didn't guarantee consistent rendering across browsers. Doing a quick google search shows other people reporting this problem (e.g., here, here, and here).

See example:
icc_stripped_example

However, currently this module doesn't let you control what image markers to strip and instead always passes in the --strip-all flag.

The the markers could be individually set, with the default of stripping all, this issue could be resolved.

Question: Regarding image size

Thanks for creating this plugin. I am using imagemin-cli and wanted to get your feedback regarding how to use the size option. I am attempting to use the desired file size over percent but am not seeing the final file size reduced to (in this case) 100 kb. Perhaps I am not using it correctly. While I am not getting errors in the console, I am also not seeing it reduced to the target size. Greatly appreciate your feedback when you have a moment.
Details of my setup:

"imagemin-cli": "^7.0.0",
"imagemin-jpegoptim": "^8.0.0",
"imagemin-pngquant": "^9.0.2",

I have this in my package.json. The find command fixes the issues whereby I keep my assets directory structure (they have a new feature that hasn 't been merged yet that addresses this). I have tried dropping the curly brackets as well.:

"_optimize-images": "find ./assets/src/ -type f | xargs -I % sh -c 'imagemin --plugin.jpegoptim.size={100} --plugin.pngquant.quality={0.1,0.2} % -o ../build/$(dirname %)'"

That resulting image is 3 kb less than the original: 161 kb. Thanks for your help in advance.

TypeError: stream.on is not a function

This happens when I try to use to use jpegoptim on Linux.

TypeError: stream.on is not a function
    at Readable.wrap (/home/***/node_modules/readable-stream/lib/_stream_readable.js:753:10)
    at wrap (/home/***/node_modules/stream-combiner2/index.js:67:29)
    at combine (/home/***/node_modules/stream-combiner2/index.js:29:18)
    at Function.module.exports.obj (/home/***/node_modules/stream-combiner2/index.js:22:10)
    at Imagemin.createStream (/home/***/node_modules/imagemin/index.js:103:24)
    at Imagemin.run (/home/***/node_modules/imagemin/index.js:77:20)
    at DestroyableTransform.through.obj.percent (/home/***/node_modules/gulp-imagemin/index.js:56:12)
    at DestroyableTransform._transform (/home/***/node_modules/through2-concurrent/through2-concurrent.js:30:15)
    at DestroyableTransform.Transform._read (/home/***/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Transform._write (/home/***/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)

Gulp task:

  var path = require('path');
  var gulpif = require('gulp-if');
  var pngquant = require('imagemin-pngquant');
  var jpegoptim = require('imagemin-jpegoptim');

  gulp.task('imagemin', function() {
    return gulp.src(path.join(dirs.source, dirs.images, '**/*.{jpg,jpeg,gif,svg,png}'))
      .pipe(plugins.changed(dest))
      .pipe(gulpif(args.production, plugins.imagemin({
        progressive: true,
        svgoPlugins: [{removeViewBox: false}],
        use: [
          pngquant({ speed: 10 }),
          jpegoptim({max:90})
        ]
      })))
      .pipe(gulp.dest(dest));
  });

Spawn - ENOENT error

I'm currently trying to build one of our packages(https://github.com/Lostmyname/lmn-gulp-tasks/blob/master/tasks/responsive-images.js) on a new machine but I get stuck on this error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1011:11)
    at Process.ChildProcess._handle.onexit (child_process.js:802:34)

I think I have managed to track it down to this line of code:
https://github.com/imagemin/imagemin-jpegoptim/blob/master/index.js#L11

At this point, the through variable is defined, so I'm not sure what could be triggering this.

Any help would be greatly appreciated!

error on install

I'm getting this when i try npm install --save imagemin-jpegoptim

⚠ The `jpegoptim` binary doesn't seem to work correctly
⚠ jpegoptim pre-build test failed
ℹ compiling from source

Empty image as result

Hi! I'm currently using jpegoptim as a imagemin-plugin through gulp and when I run the gulp-task all my jpegs are empty. The PNGs are not and the GIF are not as well, which indicates that the jpegoptim is the problem. I once again tried to compress one image, but this time through the CLI running

cat house.jpg | node_modules/imagemin-jpegoptim/node_modules/jpegoptim-bin/vendor/jpegoptim --stdin --stdout > /tmp/$$.jpg; open /tmp/$$.jpg

I get as a response:

yld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /Users/olov/Sites/spaces/node_modules/imagemin-
jpegoptim/node_modules/jpegoptim-bin/vendor/jpegoptim
Reason: image not found
Trace/BPT trap: 5

Looking in /usr/local/lib/ I found that there isn't any library there called libjpeg. It seems like I miss a important low-level dependency, but why isn't this included in the installation?

PS.
I'm running Mac OSX El Capitan 10.11.6 on an iMac from 2015

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.