my captcha_image module failes to generate the images.
From http://drupal.org/node/205525, i get some code to check imagegd2 module.
if (function_exists('imagegd2')) {
var_export(gd_info());
}
$fs = array('imagejpeg', 'imagecreatetruecolor', 'imagedestroy',
'imagecolorallocate', 'imagefilledrectangle', 'imagecolorat', 'imagesetpixel',
'imageline', 'imagefontwidth', 'imagettfbbox', 'imagestring', 'imagettftext',
);
foreach($fs as $f) {
print "$f: ". var_export(function_exists($f), TRUE) .'<br />';
}
then, the output is
array ( 'GD Version' => 'bundled (2.0.34 compatible)', 'FreeType Support' => true, 'FreeType Linkage' => 'with freetype', 'T1Lib Support' => true, 'GIF Read Support' => true, 'GIF Create Support' => true, 'JPG Support' => true, 'PNG Support' => true, 'WBMP Support' => true, 'XPM Support' => false, 'XBM Support' => true, 'JIS-mapped Japanese Font Support' => false, )imagejpeg: true
imagecreatetruecolor: true
imagedestroy: true
imagecolorallocate: true
imagefilledrectangle: true
imagecolorat: true
imagesetpixel: true
imageline: true
imagefontwidth: true
imagettfbbox: true
imagestring: true
imagettftext: true
seems everything is fine, then what's the problem?
thanks.
Comment | File | Size | Author |
---|---|---|---|
#10 | 677687229.jpg | 5.73 KB | gnosis.kv |
#6 | 2008-06-20_152011.png | 15.47 KB | gnosis.kv |
#1 | Picture 1.png | 114.82 KB | soxofaan |
Comments
Comment #1
soxofaan CreditAttribution: soxofaan commentedDo you get an image on the image CAPTCHA settings page (like in attached screenshot)?
Also, does the math CAPTCHA work, including blocking on wrong answer?
Comment #2
gnosis.kv CreditAttribution: gnosis.kv commentedthe math captcha works well, but i did not get the pic in the admin either.
Comment #3
soxofaan CreditAttribution: soxofaan commentedPlease try the following:
disable line 390 in image_captcha.module (v 5.x-3.1):
This makes it possible to request the image more than one time, which makes debugging easier
Now go to a form or the admin page where a CAPTCHA image should show up. Try to find out the url of the image, you can do this for example by looking in the html source or right clicking on the image and chose something as "view image" (depending on which browser you use). The url should be something like http://example.com/?q=image_captcha/715730387 .
Load this url by pasting it in the address bar of your browser and report the error message if any.
Comment #4
gnosis.kv CreditAttribution: gnosis.kv commentedthansk soxofaan,
i tried, but it still does not work. i tried open the imgage directly like http://example.com/?q=image_captcha/715730387 , then i got an "red cross"(empty image).
i tried image_captcha on another server, still end up with the same problem.
Comment #5
soxofaan CreditAttribution: soxofaan commentedThe red cross is with Internet Explorer, I presume? Can you try a different browser (Firefox, opera, ...)?
What happens if you replace that line 390 with
and again open a CAPTCHA image directly with the URL?
Can you also check your watchdog log (at example.com/?q=admin/logs/watchdog) for (image) CAPTCHA related error messages?
Comment #6
gnosis.kv CreditAttribution: gnosis.kv commentedI tried to do
in the line 390. it returns me the code genereted by captcha.
i also checked watchdog, there is no error for captcha.
screen shot attached. here.
Comment #7
gnosis.kv CreditAttribution: gnosis.kv commentedi tried to download the image file from
http://example.com/?q=image_captcha/715730387
then manually rename it as 715730387.jpg.
the jpg file can be viewed and edited in Photoshop CS, but it cannot be opened in "Windows Picture and Fax viewer".
Comment #8
soxofaan CreditAttribution: soxofaan commentedI don't think there is something wrong with
but maybe removing
helps for you?
Comment #9
soxofaan CreditAttribution: soxofaan commentedCan you view it in your web browser?
Please attach that file.
Comment #10
gnosis.kv CreditAttribution: gnosis.kv commentedit cannot be viewed in broswer (either ie or ff).
file attached.
Comment #11
gnosis.kv CreditAttribution: gnosis.kv commentedi guess there is sth wrong with my GD.
Comment #12
soxofaan CreditAttribution: soxofaan commentedI think I found the problem.
If you look at the binary content of that file, you'll see that it starts with four bytes of newlines, before the JPEG data. Most viewers will fail on this.
The reason: you probably have a module or include file in your setup that ends with "?>" followed by two new lines. These new lines are always emitted on every request before any real content.
It is recommended in php to not use a closing "?>" at the end of the file (also see http://drupal.org/node/247058#comment-875378)
The problem is probably in a custom module because Drupal core and most contrib modules don't use a closing "?>".
Comment #13
soxofaan CreditAttribution: soxofaan commentedComment #14
gnosis.kv CreditAttribution: gnosis.kv commentedthanks so much, soxofaan.
i have removed the all the "?>" from all the module files. (suprisely, quite a lot of contrib module got this ending ?>), but the the problem is still there.
anyway, i think the direction you pointed is correct, i am trying to disable the modules one by one to find the root cause.
any other suggestion??
Comment #15
gnosis.kv CreditAttribution: gnosis.kv commentedfinally, find out the reason. In of my customized module file, i mistakelly added 2 new lines at a beginning.
a BIG lesson for me. thanks soxofaan .
Comment #16
soxofaan CreditAttribution: soxofaan commentedyou're welcome
indeed, whitespace before the opening "<?php" is equally evil, but that doesn't happen as often as trailing whitespace after the closing "?>" so I didn't mention it.
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #18
matheusgorino CreditAttribution: matheusgorino commentedI searched for "?>" and "{space}<?php" in all my .module and .inc files and didn't find any error.
Not sure how warm it is, but I fixed the issue by calling ob_clean() before rendering the image, on the line 26 of the image_captcha.user.inc file.
Comment #19
jaddamo CreditAttribution: jaddamo commentedI know that issue is closed but maybe this information helps someone else.
matheusgorino, THANKS!!!
I had the same problem. When installing the module CAPTCHA worked fine, but after installing another module could verify that stopped working. I don't remember which module installed first.
I changed the line 26 with the function ob_clean() and the image will display correctly. Thanks for writing the solution as I have been reading for days the forum and had not found anything.
I'm using Drupal v.7 on a server Debian 5.0.7.
Modules installed:
- Captcha
- Views
- Chaos tools suite
- Calendar
- Date
- Media
- Entity API
- Rules
- Services
- Services authentication
- Userpoints
Thank again!!
Juan
Comment #20
goldengalaxy CreditAttribution: goldengalaxy commentedThanks a lot matheusgorino, your solution did solve the issue. It really saved me from drowning as I was having the issue on live site.
Note - Later I realized that this is taken care in the latest version of captcha module. I was using 6.x-2.4 version of the module and the fix is implemented in 6.x-2.5 version of the module.
Comment #21
yogen.prasad CreditAttribution: yogen.prasad commentedThanks a lot soxofaan , one of my custom .module file had a space before <?php.