GD2 Apparently not working?

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
JohnnyK
Forum Newbie
Posts: 7
Joined: Tue Jul 03, 2007 1:44 pm

GD2 Apparently not working?

Post by JohnnyK »

Hi everyone, I have searched all over for this answer and hopefully you can help me here.

I am attempting to use a script which utilizes GD2 to display a secure image for registration stopping spam bots.

The image does not display and only shows up as a one of those boxes with a red X.

Here is the info I got from running info on my php application:


PHP Version 5.0.4

Server API Apache 2.0 Handler


GD

GD Support enabled
GD Version bundled (2.0.28 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

I am using a godaddy virtual dedicated server. I have tried modifying the php.ini by adding the line extension=gd.so which did not work.

I have been banging my head off the desk for about a week and the picture still doesn’t show up. I had hoped that the “head banging” would somehow magically fix this.

:banghead:

BTW: I am a noob so if you could provide as many details as possible I would greatly appreciate it.


Thanks,
John
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

GD is already loaded as evidenced by the information you found in your information page. I would suspect the script you are using to generate the image is having a problem. I would guess it's a short tags or register_globals issue more than anything.
JohnnyK
Forum Newbie
Posts: 7
Joined: Tue Jul 03, 2007 1:44 pm

Post by JohnnyK »

I tried to turn on register_globals but I still have the problem. I also tried two different security codes to see if it was the specific code. I get the same error with each script.

Here is a link to one of the scripts I am attempting to use:

http://www.neoprogrammers.com/

it is called: Securimage PHP

While posting the information above I realized that most likely both scripts were written for php 4. Will this cause the problem? If so can you point me in the right direction?


:crazy: :banghead:

Thanks again,
John
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What does directly accessing the image links show?
JohnnyK
Forum Newbie
Posts: 7
Joined: Tue Jul 03, 2007 1:44 pm

Post by JohnnyK »

I did as you suggested and opened the php “page” that was supposed to display the picture. In doing so I found an undefined variable. Once I fixed this variable it worked!

My other script in which I was originally attempting to get to work was also written in php 4. Now that I proved GD2 is working correctly I can only assume that there is an error in my other code. Is there a difference in how php4 handles GD2 as compared to php5? Because I think this (original script) worked in php4?

BTW: When I right click on the image, that is still not working, I get: security.php?476 and when I open that php file I still just get the red x.

Thanks again for the help

John
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

JohnnyK wrote:Is there a difference in how php4 handles GD2 as compared to php5?
Not that I'm aware of.
JohnnyK wrote:BTW: When I right click on the image, that is still not working, I get: security.php?476 and when I open that php file I still just get the red x.
If you temporarily edit the script to remove header() calls, what does it output now?
JohnnyK
Forum Newbie
Posts: 7
Joined: Tue Jul 03, 2007 1:44 pm

Post by JohnnyK »

This is what I got:

?JFIF?CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75 ? $.' ",#(7),01444'9=82<.342? 2!!22222222222222222222222222222222222222222222222222?d"? ?}!1AQa"q2???#B??RѰ$3br? %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz???????????????????????????????????&#131;ąƇȉʒӔՖטٚᢣ䥦稩걲&#56211;&#56694;?? ?w!1AQaq"2?B????#3R&#55318;&#56498;ъ$4ᥱ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz????????????????????????????????????&#131;ąƇȉʒӔՖטٚ⣤妧詪&#55951;&#56629;?????&#55644;&#56814;?#?[궲ރ?쩲?&#56167;&#56604;皳?r9??P?{1?CCԼ3?[薚???t˃,Ig?^[G?q?r dbFr??5?h?Pؙ>๝c-&#56293;&#56939;&#55656;&#56956;I,V&#55781;&#57024;ʨr??Hд?u\???!xc?&#56180;>Tc??? O ?Ii ?L?&#55686;&#56518;鰰sЮ ?9?ǐ&#55640;&#57317;붚%ѕu?$?걐u먩ڷ?t? ۅ>?e?Y?dK??Ȟ?? ??xqִ_&#56268;??Unu*M˧ܤCШ믫?׿&#55547;&#56746;熞 ?È??&#56303;&#57156;0J?pm݂??dc??o?x?Kִq?if3??uι"?ݶ??E?K/??%?-?gݜ??2Ef?<_ὌIi?ͷpڔaF؍¡Z<ڲ?? ᕷ?uO Y?????uQ|?[F؂????Ǽ??С&#55451;&#56552;߽?]??X˭Ϭ_n⥿\ǡmWZ?Ú??XD&#55791;&#57026;ʕwu?XxSׯ?Ǣ;?&O쫻+???yϼgr?;??jWڗ?~뺓ꑋ,?lU?ɕJ????xϙ?????ј]?r?N???lț8=+??I뉼E૏?&#57042;MCNH䆪Käw ?'ܪA?zu?[ӯ^&#56055;&#56697;?/*I?I3?@ ?I諾h??9???p&#55369;&#57157;?8ڀ??&#55361;&#57282;???@&#55545;&#57318;x{[?ҭ?-'?K?B+?&#56483;鵱?'?N?봐?O㛝\\h??Iϲɯ?$R{qΡ푸+·??O?ݜ_݉{u]щ??A춏ƻ?(?&#55708;&#56486;֮tl⓭?u(?$,y??ʰ;?zկ?4?w?vz??Mo?x˃4MΆ??Ȣ??(?&#55388;&#56693;]?+뻽cW?易b"?턀{z??zVL?=K춚ߊ? SG?A"؏?y??$?q??9x_T֮쯬5??&?܇????ѶT??xs?@?Ӝiꚑ??`.@$`?v4P?ۼ(ѭ?Y???=䏫繑??Ϣ???W(? 韴Ɗ?E



I have no idea what this is?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

It's binary data, and would imply that the image is, in fact, being created. Getting a red x usually implies that an image doesn't exist, which may mean that the data is invalid or is given a file type header that it doesn't actually follow.

What header() call did you have?
JohnnyK
Forum Newbie
Posts: 7
Joined: Tue Jul 03, 2007 1:44 pm

Post by JohnnyK »

Header("Content-Type: image/jpeg");

Thanks,
John
User avatar
dbevfat
Forum Contributor
Posts: 126
Joined: Tue Jun 28, 2005 2:47 pm
Location: Ljubljana, Slovenia

Post by dbevfat »

It's a long shot but it may be a problem with your browser (I presume you use IE, because you get a red cross). Sometimes IE has problems with opening files without extension (regardless of the content-type header), so try adding a bogus name and extension to your URL, so that it will look like this: "security.php?476&bogus_image_name.jpg". I've had problems like this with pdf files that didn't get recognized by IE.
JohnnyK
Forum Newbie
Posts: 7
Joined: Tue Jul 03, 2007 1:44 pm

Post by JohnnyK »

I decided to substitute the script that worked with the script which didn’t. I am not sure what was wrong with my php but it didn’t like something.

Thank you for the help.
Post Reply