Created
December 8, 2009 00:13
-
-
Save gerardpaapu/251282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-captcha text filename width height) | |
(let* ((img (car (gimp-image-new width height RGB))) | |
(bg (car (gimp-layer-new img width height RGBA-IMAGE "bg" 100 NORMAL-MODE))) | |
(noise-layer (car (gimp-layer-new img width height RGBA-IMAGE "noise" 100 NORMAL-MODE))) | |
(text-layer (car (gimp-text-fontname img -1 30 50 text 0 TRUE 60 PIXELS "FreeMono Bold")))) | |
(gimp-display-new img) | |
(gimp-image-add-layer img bg 0) | |
(gimp-image-lower-layer-to-bottom img bg) | |
(gimp-drawable-fill bg 2) | |
(gimp-image-add-layer img noise-layer -1) | |
(gimp-drawable-set-visible noise-layer FALSE) | |
(plug-in-solid-noise TRUE img noise-layer FALSE TRUE (random 120) 1 1.5 1.5) | |
(let ((bottom (car (gimp-image-merge-visible-layers img 1)))) | |
(plug-in-displace TRUE img bottom | |
50 50 TRUE TRUE noise-layer noise-layer 1) | |
(plug-in-autocrop FALSE img bottom)) | |
(gimp-image-flatten img) | |
(file-png-save-defaults FALSE img img filename filename) | |
(gimp-image-delete img))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment