Created
August 17, 2020 02:16
-
-
Save Alfex4936/9e7747d5defc6b6ebc47f5b434680dab to your computer and use it in GitHub Desktop.
imaginmin-webp plugin converter : img/jpg/gif
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const imagemin = require("imagemin"); | |
const webp = require("imagemin-webp"); | |
const webpGIF = require("imagemin-gif2webp"); | |
let argv = require("minimist")(process.argv.slice(2)); | |
const output = __dirname + "/output"; | |
let quality = 85; | |
if (argv["q"] == "") { | |
quality = 85; | |
} else { | |
quality = argv["q"]; | |
} | |
imagemin(["input/*.{jpg,png}"], { | |
destination: output, | |
plugins: [ | |
webp({ | |
autoFilter: false, // default | |
preset: "default", // default, photo, picture, drawing, icon | |
method: 6, // 4 is default | |
quality: quality, // 75 is default | |
/* resize: { | |
width: 1000, | |
height: 0 | |
} */ | |
}), | |
], | |
}).then(function () { | |
console.log("JPG/PNG converted!"); //완료되었을때 로그 | |
}); | |
imagemin(["input/*.gif"], { | |
destination: output, | |
plugins: [ | |
webpGIF({ | |
mixed: false, | |
method: 6, | |
multiThreading: false, | |
quality: quality, | |
}), | |
], | |
}).then(function () { | |
console.log("GIF converted!"); //완료되었을때 로그 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment