Installation
gem install rmagick # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse
Usage
How to run the script:
ruby img2boxshadow.rb -i <input> -o <output>
For large images, it's best to use an emulated pixel size, which takes n amount of pixels and blends them into one. Your output will be much smaller, but resolution will be lower. The following will combine a 4x4 pixel square into one box shadow statement.
ruby img2boxshadow.rb -i <input> -o <output> -p 4
The demo on CodePen uses the following settings:
ruby img2boxshadow.rb -i img/woman_small.jpeg -o output.css -p 5 -s 3 -b 1 -g '#000'
Options:
-p, --pixel-size 2 emulated pixel size
-s, --pixel-spacing -1 pixel spacing
-b, --blur 0 pixel blur
-g, --background white background color
-i, --input input file
-o, --output output css
-h, --help Show this message
-v, --version Print version