From 16fbdaec26f5fda51e860cf14a9b8cbcc473126c Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Wed, 26 Sep 2007 10:56:55 +0000 Subject: [PATCH] fix unreadable captcha with Image::Magick --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Storage/Image.pm | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 0ad32dde9..d65300ce1 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -2,6 +2,7 @@ - fix: Syndicated Content doesn't display all items with multiple feeds in interleaved mode - fix: SQLForm file upload broken - fix: Newsletter can contain duplicate threads + - fix: Captcha unreadable when using Image::Magick 7.4.7 - fix: misspelled i18n in webgui password recovery diff --git a/lib/WebGUI/Storage/Image.pm b/lib/WebGUI/Storage/Image.pm index 76e877774..008a6ed6c 100644 --- a/lib/WebGUI/Storage/Image.pm +++ b/lib/WebGUI/Storage/Image.pm @@ -89,11 +89,13 @@ sub addFileFromCaptcha { if($error) { $self->session->errorHandler->warn("Error adding noise: $error"); } - $error = $image->Annotate(font=>$self->session->config->getWebguiRoot."/lib/default.ttf", pointsize=>30, skewY=>0, skewX=>0, gravity=>'center', fill=>'#666666', antialias=>'true', text=>$challenge); + # AddNoise generates a different average color depending on library. This is ugly, but the best I can see for now + my $textColor = $graphicsPackage eq 'Image::Magick' ? '#222222' : '#666666'; + $error = $image->Annotate(font=>$self->session->config->getWebguiRoot."/lib/default.ttf", pointsize=>30, skewY=>0, skewX=>0, gravity=>'center', fill=>$textColor, antialias=>'true', text=>$challenge); if($error) { $self->session->errorHandler->warn("Error Annotating image: $error"); } - $error = $image->Draw(primitive=>"line", points=>"0,5 105,21", stroke=>'#666666', antialias=>'true', strokewidth=>2); + $error = $image->Draw(primitive=>"line", points=>"0,5 105,21", stroke=>$textColor, antialias=>'true', strokewidth=>2); if($error) { $self->session->errorHandler->warn("Error drawing line: $error"); }