gm-captcha
a node captcha library using the gm module
gm is the GraphicsMagick and ImageMagick for node
Getting started
First download and install GraphicsMagick or ImageMagick. In Mac OS X, you can simply use Homebrew and do:
brew install imagemagick
brew install graphicsmagick
then either use npm:
npm install gm-captcha
Usage
var gmCaptcha = ;var options = width: 100 height: 50 text: '1024'// Other configurations using default parametersvar captcha = ;var gmObj = captcha; // return a gm objectcaptcha;
Options
filed | description | default |
---|---|---|
width | image width | 100 |
height | image height | 50 |
background | image background, support rgb or hex | #fff |
colorCount | the maximum color count of the point and line displayed | 20 |
text | the text you want to display | Random four digit |
maxTextWidth | the max font weight you want to display | 3 |
textColorCount | the max color count of the text displayed | 20 |
textColor | text color, support rgb or hex | random color between 0 and 20 |
textIndent | indent, left margin of text | 0 |
wordSpacing | word space | 25 |
maxSwirl | the maximum degree of the picture center swirl | 20 |
maxShear | the maximum degree of the picture shear | 30 |
lineCount | the maximum count of line | 20 |
lineWidth | the width of line | 1 |
pointCount | the maximum count of point | 500 |
font | font path | DroidSansFallback |
fontSize | font size | 50 |
License
MIT License
Copyright (c) [2016] [eidonjoe]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.