I've just tried to post an anonymous comment five times in a row. I succeeded on the fifth because it was the first time that the captcha module actually put all of the captcha text inside of the graphic. Is this thing actually working for anyone? And, if so, how did you get it working properly? The number of characters displayed seems to range between one and five, but the only time it worked it was five characters.

CommentFileSizeAuthor
#1 textimage.patch_0.txt4.33 KBstefano@tipic.com

Comments

stefano@tipic.com’s picture

StatusFileSize
new4.33 KB

The attached patch fixes the problem with margins and also a problemi with noise (lines, dost, ellipses). It seems that the image create using imagecreatetruecolor() doesn't show noise, I tried imagecreate() and it works.

hyperlogos’s picture

#patch -p0 < textimage.patch_0.txt
(Stripping trailing CRs from patch.)
patching file textimage.module
Hunk #3 FAILED at 48.
Hunk #4 succeeded at 71 with fuzz 2.
Hunk #8 FAILED at 416.
2 out of 8 hunks FAILED -- saving rejects to file textimage.module.rej

What version/release of textimage did you apply your patch to?

I really despise the fact that drupal download filenames (e.g. for modules) don't have a version number in them. Muy estupido.

wundo’s picture

Project: CAPTCHA » Textimage
Version: 4.7.x-1.x-dev » 5.x-2.x-dev
hyperlogos’s picture

# patch -p0 < textimage.patch_0.txt
(Stripping trailing CRs from patch.)
patching file textimage.module
Hunk #2 FAILED at 23.
Hunk #3 FAILED at 48.
Hunk #4 succeeded at 71 with fuzz 2.
Hunk #8 FAILED at 416.
3 out of 8 hunks FAILED -- saving rejects to file textimage.module.rej

This is against CVS, the last one was against 4.7.0, you are either patching an already-patched copy, or the cvs version now on the site is broken. In any case, it seems to be working properly with cvs.

splatEric’s picture

Hi, I found that the reason the patch wasn't applying correctly was because the file from CVS had a mixture of different carriage returns in it. To resolve this, I performed the following regexp in vi:

:%s/^M$//g

note that to get ^M you must use ctrl+v ctrl+m, NOT carrat M.

Once I had done this, the patch command worked fine, and the next captcha attempt I made worked perfectly. Note that I simply had to replace the textimage.module file - there was no need to reapply the module, or update or anything like that.

Of course ymmv, but it worked for me

craines’s picture

I just downloaded and installed textimage and captcha (both CVS) and did have the issue with text appearing outside the boundary of the captcha image -- so it appears as though the CVS (for some reason) doesn't include this patch.

Patching the CVS (dated 25/08/2006) by hand got it to work for us.

SemperFideles’s picture

I cannot, for the life of me, figure out what I'm doing wrong.

Here's what I've done:

1. Tried installing textimage.module from the latest CVS release. Out of bounds problem persists.
2. Tried downloading the original file and then applying the patch in the attached file (textimage.patch_0.txt). The CAPTCHA actually displays correctly but then the settings for textimage do not work properly anymore.

Is there an actual stable, working release of textimage.module that works? I can use the patched version of my file because it displays the image string properly but then I have a problem that I can no longer administer the textimage module.

Steel Rat’s picture

This is still happening in the 2.x dev from the 4.7.x modules page. Is there a reason why the files don't get updated when an "official" patch is put out? A lot of extraneous messages and user pain could be avoided if they were.

peterx’s picture

I added textimage 1.13 and captcha 1.30 to a 5.0 site. Same problem as with a 4.7 site. The adjustment that works on my sites is to replace:

    $imageWidth = 60 + drupal_strlen($string)*$charSpacingMax*.35;
    $imageHeight = 30 + $charJiggleAmount;

with:

      $imageWidth = 100 + drupal_strlen($string)*$charSpacingMax*.35;
      $imageHeight = 50 + $charJiggleAmount;

The 100 and 50 may depend on the font, which means we have to increase both numbers as people report problems. It would be wise to record the reasons for the numbers. I use the default font on a Windows 2000 development system, test, then upload to hosts on unspecified *nux and test again. The settings of 100 and 50 work on my development system and some hosted sites.

hyperlogos’s picture

If the settings depend on the font then textimage will need some SERIOUS updating as you can install multiple fonts. The size of the image needs to be self-tuning if the character spacing etc is going to be based on the font in question.

Steel Rat’s picture

Captcha has been totally un-usable to me because of this issue. When will the download be fixed?

mrb’s picture

Here's a fix to the problem that is a bit more general. Note that it only affects the code for people using the built-in font. I'm not sure if there needs to be any work on the code that uses true-type fonts to build the image.

If the captcha-string is N characters long, the widest that the captcha-string image will be in pixels is:
= (N * max width of a character) + ((N-1) * max gap between characters)
= (N * 10) + ((N-1) * $charSpacingMax))

I am not 100% sure that '10' is the correct max width of a character, but that is what is used in the current code, and it seems to work ok.

So in captcha.inc, function _textimage_captcha_image(), replace the line

    $imageWidth = 60 + drupal_strlen($string)*$charSpacingMax*.35;    

with

    // If the captcha-string is N characters long, the widest that the
    //  captcha-string image will be in pixels is:
    // (N * max width of a character) + ((N-1) * max gap between characters)
    $imageWidth = drupal_strlen($string)*10 + (drupal_strlen($string)-1)*$charSpacingMax;

With the original code, if I displayed ten captcha images, only four of them showed the whole string. After the patch, all the captcha images showed the whole string.

eMPee584’s picture

I also had this problem using a font file called 'skinck__.ttf'.. using the latest (image_captcha.module,v 1.1.4.22 2007/10/11 08:38:25) captcha modudule the following changes to function _image_captcha_generate_image made it look fine (as you can see at http://www.muntu-afrika.de/kontakt):

#392  $width = $character_spacing * $font_size * $character_quantity + 11 * $font_size;
#393  $height = 3.5 * $font_size;

it seems this is heavily dependant on the font you use.. though I don't think we are going to change from skinck as that looks quite cool already (see above).

eMPee584’s picture

Assigned: Unassigned » eMPee584
Priority: Critical » Normal
Status: Active » Fixed

... I have added a configurable space tuning parameter in the patch at http://drupal.org/node/233873, if this approach does not work for anyone reopen this for the captcha module.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.