Using mozjpeg to compress pictures will result in errors!
See original GitHub issue- Node Version: 11.15.0
- Imagemin Version: 7.0.1
- Gulp-Imagemin Version: 7.0.0 Imagemin 7.0.0 ^ compress JPEG pictures with mozjpeg。 When I use mozjpeg to compress JPEG images, the tool throws an exception. But pictures in other formats are normally compressed.
import imagemin from 'gulp-imagemin';
const ImageTask = () => {
return src(['src/images/*.{png,jpg,jpeg,svg,gif}'])
.pipe(imagemin(
[
imagemin.gifsicle({
interlaced: true,
optimizationLevel: 3,
}),
imagemin.mozjpeg({
quality: 75,
progressive: true
}),
imagemin.optipng({ optimizationLevel: 5}),
imagemin.svgo(),
], {
silent: false
}
))
.pipe(dest('dist/images'))
}
The details of the error are as follows
Message:
spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg ENOENT
Details:
errno: ENOENT
code: ENOENT
syscall: spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
path: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
spawnargs:
stdout:
stderr:
failed: true
signal: null
cmd: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
timedOut: false
killed: false
fileName: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/src/images/20171219195409_ez4Vu.jpeg
domainEmitter: [object Object]
domainThrown: false
I try to use mozjpeg command directly,like this
npx mozjpeg --help
Exception will still be thrown.
spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg ENOENT
When I reduce imagemin to 6.2.0,Imagemin 6.2.0 compress JPEG pictures with jpegtran, and there’s no problem with jpegtran.
I hope this problem can be solved.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Compress in mozjpeg - Rust
Struct mozjpeg::Compress ... Compress image using input in this colorspace. ... By default errors cause unwind (panic) and unwind through the C code, ......
Read more >Using mozjpeg to Create Efficient JPEGs
I'm excited to start using mozjpeg. This article is really helpful to get me going. You suggest doing some experimenting with the quality...
Read more >Unable to compress large file with imageminMozjpeg?
I have been making a server on node which can take image files and upload on disk after compressing it. However, image with...
Read more >How Image Optimization Decreased my Website's Page ...
Compress JPEGs with MozJPEG. To compress JPEG images, I used the MozJPEG tool from Mozilla which is available as an Imagemin plugin via...
Read more >How to Resize an Image without Losing Quality
High-quality images are larger in file size, which can result in slow ... chosen your compression method (we're going to stick with MozJPEG...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In my case, the problem occurred after I upgrade
npm
to latest version(7.10.0). At first, I runrm -rf node_modules && npm install
but it does’t work at all…Then I try to check the mozjpeg folder and I found there was no
vender/cjpeg
. So I try to install packages whithyarn install
and at last it worksFor more details: https://github.com/npm/cli/issues/1905 https://github.com/npm/cli/issues/3100
This seems to be an error with
npm >= 7
, we were able to get past this withnpm install -g npm@6
although really not sure why