2017-04-19 7 views
0

私はノードjsに新しいので、ネイティブノードjsライブラリを使用してpng画像を純粋な白黒(グレースケールではない)画像に変換したいと思います。私は白黒イメージのビット深度が1であるべきことを知っています。どんな助けもありがとうございます。ノードJSでの画像操作

答えて

1

あなたは2つのオプション、

https://www.npmjs.com/package/gm

ドキュメント同じパッケージと両方持っている:http://aheckmann.github.io/gm/docs.html

オプション1

モノクロ

gm("img.png").monochrome() 
に画像を変換します

手動黒と純粋な白に変換される範囲

//pixels below `threshold` become black. 
gm("img.png").blackThreshold(red ,green , blue , opacity) 

//pixels above the threshold become white 
gm("img.png").whiteThreshold(red, green, blue, opacity) 

ドキュメント個人

http://aheckmann.github.io/gm/docs.html#blackThreshold http://aheckmann.github.io/gm/docs.html#whiteThreshold

を指定するオプション2

使用黒と白のしきい値私はオプション2があなたのニーズに最も適していると思います。