Main procedure ----------------
| 52 | // Main procedure |
| 53 | //---------------- |
| 54 | int main(int argc,char **argv) { |
| 55 | |
| 56 | // Read command line parameters |
| 57 | //------------------------------ |
| 58 | cimg_usage("Simple captcha generator."); |
| 59 | const char *file_o = cimg_option("-o",(const char*)0,"Output image file"); |
| 60 | const bool add_border = cimg_option("-b",true,"Add border to captcha image"); |
| 61 | const bool visu = cimg_option("-visu",true,"Enable visualization if no output file"); |
| 62 | |
| 63 | // Generate captcha text (6 char max). |
| 64 | //------------------------------------ |
| 65 | const char *predef_words[] = { |
| 66 | "aarrgh", "abacas", "abacus", "abakas", "abamps", "abased", "abaser", "abases", "abasia", "abated", "abater", |
| 67 | "abates", "abatis", "abator", "baobab", "barbal", "barbed", "barbel", "barber", "barbes", "barbet", "barbie", |
| 68 | "barbut", "barcas", "barded", "bardes", "bardic", "barege", "cavies", "cavils", "caving", "cavity", "cavort", |
| 69 | "cawing", "cayman", "cayuse", "ceased", "ceases", "cebids", "ceboid", "cecity", "cedarn", "dicast", "dicers", |
| 70 | "dicier", "dicing", "dicker", "dickey", "dickie", "dicots", "dictum", "didact", "diddle", "diddly", "didies", |
| 71 | "didoes", "emails", "embalm", "embank", "embark", "embars", "embays", "embeds", "embers", "emblem", "embody", |
| 72 | "emboli", "emboly", "embosk", "emboss", "fluffy", "fluids", "fluish", "fluked", "flukes", "flukey", "flumed", |
| 73 | "flumes", "flumps", "flunks", "flunky", "fluors", "flurry", "fluted", "genome", "genoms", "genres", "genros", |
| 74 | "gentes", "gentil", "gentle", "gently", "gentry", "geodes", "geodic", "geoids", "gerahs", "gerbil", "hotter", |
| 75 | "hottie", "houdah", "hounds", "houris", "hourly", "housed", "housel", "houser", "houses", "hovels", "hovers", |
| 76 | "howdah", "howdie", "inland", "inlays", "inlets", "inlier", "inmate", "inmesh", "inmost", "innage", "innate", |
| 77 | "inners", "inning", "inpour", "inputs", "inroad", "joypop", "jubbah", "jubhah", "jubile", "judder", "judged", |
| 78 | "judger", "judges", "judoka", "jugate", "jugful", "jugged", "juggle", "jugula", "knifer", "knifes", "knight", |
| 79 | "knives", "knobby", "knocks", "knolls", "knolly", "knosps", "knotty", "knouts", "knower", "knowns", "knubby", |
| 80 | "legate", "legato", "legend", "legers", "legged", "leggin", "legion", "legist", "legits", "legman", "legmen", |
| 81 | "legong", "legume", "lehuas", "mammal", "mammas", "mammee", "mammer", "mammet", "mammey", "mammie", "mammon", |
| 82 | "mamzer", "manage", "manana", "manats", "manche", "manege", "nihils", "nilgai", "nilgau", "nilled", "nimble", |
| 83 | "nimbly", "nimbus", "nimmed", "nimrod", "ninety", "ninjas", "ninons", "ninths", "niobic", "offish", "offkey", |
| 84 | "offset", "oftest", "ogdoad", "oghams", "ogival", "ogives", "oglers", "ogling", "ogress", "ogrish", "ogrism", |
| 85 | "ohmage", "papaws", "papaya", "papers", "papery", "pappus", "papula", "papule", "papyri", "parade", "paramo", |
| 86 | "parang", "paraph", "parcel", "pardah", "quasar", "quatre", "quaver", "qubits", "qubyte", "queans", "queasy", |
| 87 | "queazy", "queens", "queers", "quelea", "quells", "quench", "querns", "raised", "raiser", "raises", "raisin", |
| 88 | "raitas", "rajahs", "rakees", "rakers", "raking", "rakish", "rallye", "ralphs", "ramada", "ramate", "savory", |
| 89 | "savour", "savoys", "sawers", "sawfly", "sawing", "sawlog", "sawney", "sawyer", "saxony", "sayeds", "sayers", |
| 90 | "sayest", "sayids", "tondos", "toneme", "toners", "tongas", "tonged", "tonger", "tongue", "tonics", "tonier", |
| 91 | "toning", "tonish", "tonlet", "tonner", "tonnes", "uredia", "uredos", "ureide", "uremia", "uremic", "ureter", |
| 92 | "uretic", "urgent", "urgers", "urging", "urials", "urinal", "urines", "uropod", "villus", "vimina", "vinals", |
| 93 | "vincas", "vineal", "vinery", "vinier", "vinify", "vining", "vinous", "vinyls", "violas", "violet", "violin", |
| 94 | "webfed", "weblog", "wechts", "wedded", "wedder", "wedeln", "wedels", "wedged", "wedges", "wedgie", "weeded", |
| 95 | "weeder", "weekly", "weened", "xystoi", "xystos", "xystus", "yabber", "yabbie", "yachts", "yacked", "yaffed", |
| 96 | "yagers", "yahoos", "yairds", "yakked", "yakker", "yakuza", "zigged", "zigzag", "zillah", "zinced", "zincic", |
| 97 | "zincky", "zinebs", "zinged", "zinger", "zinnia", "zipped", "zipper", "zirams", "zircon" }; |
| 98 | cimg::srand(); |
| 99 | const char *const captcha_text = predef_words[std::rand()%(sizeof(predef_words)/sizeof(char*))]; |
| 100 | |
| 101 | // Create captcha image |
| 102 | //---------------------- |
| 103 | |
| 104 | // Write colored and distorted text |
| 105 | CImg<unsigned char> captcha(256,64,1,3,0), color(3); |
| 106 | char letter[2] = { 0 }; |
| 107 | for (unsigned int k = 0; k<6; ++k) { |
| 108 | CImg<unsigned char> tmp; |
| 109 | *letter = captcha_text[k]; |
| 110 | if (*letter) { |
| 111 | cimg_forX(color,i) color[i] = (unsigned char)(128 + (std::rand()%127)); |
nothing calls this directly
no test coverage detected