jimpで遊ぶ
ここをみる使い方がわかる
実験中に使ったrepository
code:script.js
const jimp = require('jimp')
main()
async function main() {
const image = await jimp.read('./src/yutaro.jpg')
image.sepia()
.write('./image/sepia.png')
}
いろんなケースを検証する
code:script.js
const jimp = require('jimp')
main()
async function main() {
const image = await jimp.read('./src/yutaro.jpg')
const processes = {
resize: img => img.resize(255, 255),
sepia: img => img.sepia(),
}
for (let i = -90; i <= 90; i += 10) {
processes[hue/${i}] = img => img.color(apply: 'hue', params: i }) processes[saturate/${i}] = img => img.color(apply: 'saturate', params: i }) processes[lighten/${i}] = img => img.color(apply: 'lighten', params: i }) processes[darken/${i}] = img => img.color(apply: 'darken', params: i }) }
for( const label in processes ) {
process(image, label, processeslabel) }
}
async function process(image, label, callback) {
const img = image.clone()
callback(img)
.write(./image/${label}.png)
}
結果
resize 256 256
https://gyazo.com/434c9736f611b3f010ced6a1576237dd
sepia
https://gyazo.com/3d3f165bab274b6e272042424d88bad4
satulate +50
https://gyazo.com/bcb941f6a0d7eef357183ae99627e7aa
lighten +50
https://gyazo.com/50ebff940e8502d67aa9ec2fa5405dd3
hue +50
https://gyazo.com/b5895c35cb5081548ccff520929ab7e9
darken +50
https://gyazo.com/bbc0eea2660b88107bf12c487b3501c7