Answer the question
In order to leave comments, you need to log in
How to process a large number of files in javascript?
You need to process a large number of pictures that are in one folder.
I use the imagemin library and the code:
const imagemin = require('imagemin');
const imageminMozjpeg = require('imagemin-mozjpeg');
(async () => {
const files = await imagemin(['../imported/imported_fvalencia/*.{jpg,jpeg}'], {
destination: 'build/images',
plugins: [
imageminMozjpeg({
quality: 80
})
]
});
//console.log(files);
//=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
})();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question