458 Option('bg-color', False, ColorOption(), Defaults.bg_color, None), |
458 Option('bg-color', False, ColorOption(), Defaults.bg_color, None), |
459 Option('line-spacing', False, IntOption(), Defaults.line_spacing, None), |
459 Option('line-spacing', False, IntOption(), Defaults.line_spacing, None), |
460 Option('sharpness', False, FloatOption(), Defaults.sharpness, None), |
460 Option('sharpness', False, FloatOption(), Defaults.sharpness, None), |
461 Option('image-format', False, StringOption(), Defaults.img_format, IMAGE_FORMATS.keys()), |
461 Option('image-format', False, StringOption(), Defaults.img_format, IMAGE_FORMATS.keys()), |
462 Option('seed', False, IntOption(), None, None), |
462 Option('seed', False, IntOption(), None, None), |
463 Option('img_width', False, IntOption(), None, None), |
463 Option('img-width', False, IntOption(), None, None), |
464 Option('img_height', False, IntOption(), None, None), |
464 Option('img-height', False, IntOption(), None, None), |
465 ) |
465 ) |
466 |
466 |
467 def handle_generic (req, img_size=None) : |
467 def handle_generic (req, img_size=None) : |
468 # parse options |
468 # parse options |
469 opts = OPTIONS.parse(req.args) |
469 opts = OPTIONS.parse(req.args) |
476 raise ValueError(opts['font-size']) |
476 raise ValueError(opts['font-size']) |
477 |
477 |
478 if opts['seed'] is None : |
478 if opts['seed'] is None : |
479 opts['seed'] = time.time() |
479 opts['seed'] = time.time() |
480 |
480 |
481 if opts['img_width'] and opts['img_height'] : |
481 if opts['img-width'] and opts['img-height'] : |
482 img_size = (opts['img_width'], opts['img_height']) |
482 img_size = (opts['img-width'], opts['img-height']) |
483 |
483 |
484 if opts['img_width'] > IMG_SIZE_MAX or opts['img_height'] > IMG_SIZE_MAX : |
484 if opts['img-width'] > IMG_SIZE_MAX or opts['img-height'] > IMG_SIZE_MAX : |
485 raise ValueError(img_size) |
485 raise ValueError(img_size) |
486 |
486 |
487 # load/prep resources |
487 # load/prep resources |
488 random.seed(opts['seed']) |
488 random.seed(opts['seed']) |
489 data = build_data(opts['text'], opts['chars'], opts['colors'], opts['random-chars'], opts['random-text'], opts['random-text-char']) |
489 data = build_data(opts['text'], opts['chars'], opts['colors'], opts['random-chars'], opts['random-text'], opts['random-text-char']) |