imgproc
v0.1.1
Published
An experimental and unpolished image processing utility for the command line
Downloads
5
Readme
imgproc
An experimental and unpolished image processing utility for the command line.
Allow to manipulate and combine up to 9 images using a simple SDL limited to channel access and basic functions.
Installing
With npm do:
npm install imgproc -g
SDL
Input variables : r1 is the red channel of the first input image, g2 is the green channel of the second input image, b3 is the blue channel of the third input image, a9 is the alpha channel of the ninth input image, etc.
Numerical constants : 0, 0.001, 1923., -5, etc.
Functions :
- min
- max
- add
- sub
- mul
- div
- avg
- mod
- pow
- rand
- sin
- cos
- floor
- ceil
- mix
Recipes
Limit to a single channel
imgproc img/trees.png -o outputs/red-channel-only.png --red="r1"
Invert colors
imgproc img/trees.png -o outputs/invert-colors.png --red="sub(1,r1)" --green="sub(1,g1)" --blue="sub(1,b1)" --alpha="a1"
Desaturate (crudely)
imgproc img/trees.png -o outputs/desaturate.png --red="avg(r1,g1,b1)" --green="avg(r1,g1,b1)" --blue="avg(r1,g1,b1)" --alpha="a1"
Desaturate by 70 percents
imgproc img/trees.png -o outputs/desaturate-seventy-percents.png --red="mix(r1,avg(r1,g1,b1),0.7)" --green="mix(g1,avg(r1,g1,b1),0.7)" --blue="mix(b1,avg(r1,g1,b1),0.7)" --alpha="a1"
Desaturate all but blue
imgproc img/trees.png -o outputs/desaturate-all-but-blue.png --red="avg(r1,g1,b1)" --green="avg(r1,g1,b1)" --blue="max(b1,avg(r1,g1,b1))" --alpha="a1"
Darken
imgproc img/trees.png -o outputs/darken.png --red="pow(r1,1.3)" --green="pow(g1,1.3)" --blue="pow(b1,1.3)" --alpha="a1"
Lighten
imgproc img/trees.png -o outputs/lighten.png --red="add(0.25,mul(0.8,pow(r1, 0.5)))" --green="add(0.25,mul(0.8,pow(g1, 0.5)))" --blue="add(0.25,mul(0.8,pow(b1, 0.4)))" --alpha="a1"
Gameboy filter
imgproc img/trees.png -o outputs/gameboy.png --red="add(0.07,div(floor(mul(pow(avg(r1,g1,b1),0.7),4)),3.8))" --green="add(0.1,div(floor(mul(pow(avg(r1,g1,b1),0.7),4)),3.3))" --blue="add(0.02,div(floor(mul(pow(avg(r1,g1,b1),0.7),4)),3.8))" --alpha="a1"
Blend two images
imgproc img/trees.png img/mask.png -o outputs/mix.png --red="mix(r1,r2,0.5)" --green="mix(g1,g2,0.5)" --blue="mix(b1,b2,0.5)" --alpha="mix(a1,a2,0.5)"
Use a B/W image as an alpha mask
imgproc img/trees.png img/mask.png -o outputs/mask-alpha.png --red="r1" --green="g1" --blue="b1" --alpha="avg(r2,g2,b2)"
Combine two heightmaps in a single image
imgproc img/trees.png img/mask.png -o outputs/combined.png --red="avg(r1,g1,b1)" --green="avg(r2,g2,b2)" --blue="0.5" --alpha="1"
Mix two images using the multiply blend mode
imgproc img/trees.png img/mask.png -o outputs/multiply.png --red="mul(r1,r2)" --green="mul(g1,g2)" --blue="mul(b1,b2)" --alpha="avg(a1,a2)"
Mix two images using the screen blend mode
imgproc img/trees.png img/mask.png -o outputs/screen.png --red="sub(1,mul(sub(1,r1),sub(1,r2)))" --green="sub(1,mul(sub(1,g1),sub(1,g2)))" --blue="sub(1,mul(sub(1,b1),sub(1,b2)))" --alpha="avg(a1,a2)"
Changelog
0.1.1 (2017.08.13) :
- Add proper credits for example image in readme.
0.1.0 (2017.08.13) :
- First release.
License
MIT
Additional credits
The example image is a picture licensed as CC-BY-NC-SA by pohcao34 on Flickr (see original).