Index: openacs-4/packages/acs-templating/tcl/captcha-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/Attic/captcha-procs.tcl,v diff -u -r1.1.2.3 -r1.1.2.4 --- openacs-4/packages/acs-templating/tcl/captcha-procs.tcl 27 Jan 2022 08:18:47 -0000 1.1.2.3 +++ openacs-4/packages/acs-templating/tcl/captcha-procs.tcl 28 Jan 2022 09:28:29 -0000 1.1.2.4 @@ -9,14 +9,14 @@ namespace eval captcha::image {} ad_proc -private captcha::image::generate { - {-pointsize 40} + {-size 150x50} -text {-background "#ffffff"} {-fill "#000000"} } { Creates a distorted capcha image from a text. - @param pointsize the font size as supported by convert + @param size the size expressed as \{width\}x\{height\} in pixel @param text the text to use for the captcha. When unspecified, a random text will be used. The text can only contain alphanumeric characters and spaces. @@ -35,8 +35,8 @@ error {'convert' command not available.} } - if {![string is integer -strict $pointsize]} { - error {Invalid pointsize} + if {![regexp -nocase {^\d+x\d+$} $size]} { + error {Invalid size} } if {![regexp -nocase {^(\#([0-9]|[a-f]){6}){2}$} ${background}${fill}]} { error {Invalid color} @@ -51,12 +51,14 @@ set path [ad_tmpnam].png + set wavelength [expr {round(rand() * 100) + 100}] + exec $convert \ - -pointsize $pointsize \ + -size $size \ -background $background \ -fill $fill \ label:$text \ - -wave 25%x150% \ + -wave 25%x$wavelength% \ $path if {![file exists $path]} { @@ -103,16 +105,16 @@ } else { set fill #000000 } - if {[info exists element(pointsize)]} { - set pointsize $element(pointsize) + if {[info exists element(size)]} { + set size $element(size) } else { - set pointsize 40 + set size 150x50 } set captcha [captcha::image::generate \ -background $background \ -fill $fill \ - -pointsize $pointsize] + -size $size] set checksum [dict get $captcha checksum] set text [dict get $captcha text] Index: openacs-4/packages/acs-templating/tcl/test/captcha-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/test/Attic/captcha-procs.tcl,v diff -u -r1.1.2.4 -r1.1.2.5 --- openacs-4/packages/acs-templating/tcl/test/captcha-procs.tcl 27 Jan 2022 08:22:56 -0000 1.1.2.4 +++ openacs-4/packages/acs-templating/tcl/test/captcha-procs.tcl 28 Jan 2022 09:28:29 -0000 1.1.2.5 @@ -122,11 +122,21 @@ return } - for {set i 0} {$i < 10} {incr i} { + foreach size { + 50x150 + 100x300 + 200x600 + 400x1200 + 800x2400 + 160x120 + 320x240 + 640x480 + 1024x768 + 1280x960 + } { set text [ad_generate_random_string 5] - set pointsize [expr {round((rand()*80))+20}] set captcha [captcha::image::generate \ - -pointsize $pointsize \ + -size $size \ -text $text] set ocr "" try {