allbitsnbytes / gulp-imageoptim Goto Github PK
View Code? Open in Web Editor NEWGulp plugin to optimize images using ImageOptim
License: Other
Gulp plugin to optimize images using ImageOptim
License: Other
Hi!
I really love your tool and it works really well, but if possible, I'd also like optional support for JPEGmini as that's the one feature I feel missing.
Are there any plans on integrating that?
Should ImageAlpha be used alongside ImageOptim?
Ive ran a test gulp task and manual process on the same images and i get a better result from the manual process (ImageAlpha > ImageOptim). This makes me think ImageAlpha isn't running in the gulp task.
Is there an option to set lossy vs lossless, and set the target quality?
How do I optimize images simultaneously?
Right now they optimizing one by one which takes very long time.
I run the following task from my gulpfile.js:
// `gulp imageoptim` - Run lossless compression on all the images.
gulp.task('imageoptim', function() {
return gulp.src(globs.images)
.pipe(imageOptim.optimize())
.pipe(gulp.dest(path.dist + 'images'))
.pipe(browserSync.stream());
});
Handing over a resized imaged to imageOptim (in the same stream) don't seem to work (example below works fine with imagemin). Any suggestions how to resolve this? Or should I look into task dependency?
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(imageResize({
width: "50%"
}))
.pipe(imageOptim.optimize())
.pipe(gulp.dest('build/images'));
});
Hey,
It seems that the script fails to work when the image in question has brackets in the name. Here's the log:
Error: Command failed: /bin/sh -c find /Applications/MAMP/htdocs/frontend-framework/assets/dist/img/imgOptim-Screen Shot 2015-05-27 at 14.22.38 (2).png | sh ./node_modules/gulp-imageoptim/node_modules/.bin/imageOptim -a -c -q | grep TOTAL
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `find /Applications/MAMP/htdocs/frontend-framework/assets/dist/img/imgOptim-Screen Shot 2015-05-27 at 14.22.38 (2).png | sh ./node_modules/gulp-imageoptim/node_modules/.bin/imageOptim -a -c -q | grep TOTAL '
As soon as I took out the brackets it worked. While I appreciate that you shouldn't have brackets or spaces (etc) in your file names, it could still do with being fixed?
I have setup to use imageOptim in my gulp project.
Each time I run this I am getting the following errors;
crypto.js:67
this._handle.update(data, encoding);
^
TypeError: Data must be a string or a buffer
at TypeError (native)
at Hash.update (crypto.js:67:16)
....
Any ideas on what is causing this or how to resolve it?
Hi there! Thanks for the extremely useful plugin.
My issue is that when no images are passed through to this plugin (for example, filtering via newer after a delete event), I get a console error:
{ Error: Command failed: bash node_modules/gulp-imageoptim/scripts/optimize.bash 06962c9b44b38b68736f1c7e7d8d2b81
at ChildProcess.exithandler (child_process.js:205:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at maybeClose (internal/child_process.js:899:16)
at Socket.<anonymous> (internal/child_process.js:342:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at Pipe._handle.close [as _onclose] (net.js:511:12)
killed: false,
code: 1,
signal: null,
cmd: 'bash node_modules/gulp-imageoptim/scripts/optimize.bash 06962c9b44b38b68736f1c7e7d8d2b81 ' }
Gulp does not exit and subsequent watch events execute properly, so functionally, everything is working fine. Just wondering if this error can be accounted for so my users don't get alarmed by scary-looking errors in their consoles. Or, if there's a way I should be handling this error on my side, let me know.
edit: for reference, I am using pump
in place of pipe
. Here's my imageOptim task:
let out = 'dist/images';
pump(
[
gulp.src(imageFiles),
newer(out),
imageOptim.optimize(),
gulp.dest(out)
],
done
);
Every time I use gulp watch with ImageOptim, it multiply the length of files by itself. For example:
It only work well with one file per time.
My task:
gulp.watch(['src/images/**/*'], function(event) {
return gulp
.src('./src/images/**/*.{png,gif,jpg}')
.pipe(imageOptim.optimize())
.on('error', function (error) {
console.error(String(error));
})
.pipe(gulp.dest('./dist/img'));
});
Would you find out what it can be?
Thanks!
Iโm getting the following error when I try to run my images gulp task
{ [Error: Command failed: bash node_modules/gulp-imageoptim/scripts/optimize.bash b7548d98bb65523ae6d042877f679cec --jpegmini
]
killed: false,
code: 1,
signal: null,
cmd: 'bash node_modules/gulp-imageoptim/scripts/optimize.bash b7548d98bb65523ae6d042877f679cec --jpegmini' }
My gulp task looks like this:
gulp.task('images', () => {
return gulp.src('dist/media/**/*')
.pipe($.imageoptim.optimize({
jpegmini: true
}))
.pipe(gulp.dest('shared/media'))
});
Any thoughts on how I could debug the issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.