/    Sign up×
Community /Pin to ProfileBookmark

a bit of trouble with imageRectangle()

Hi,

I have been practising with the gd after I got it implemented
(thanks for your helps).

But i must be doing something wrong because it does’t seem to work that well !

Here is my coding:
I got the function from php manual which is very neat !

<?php
function fromhex($string){
GLOBAL $img1;
sscanf($string, “%2x%2x%2x”, $red, $green, $blue);
return ImageColorAllocate($img1,$red,$green,$blue);
}

$img1 = imagecreate(400,500);
$words = “No Photo”;
imageRectangle( $img1, 40,40,150,150, fromhex(‘000000’) );
imageFilledRectangle ( $img1, 250, 350, 300, 400,fromhex(’77bb99′));
imageLine ($img1, 20,130, 300, 150,fromhex(‘000000’) );
imageEllipse( $img1, 300, 200, 120, 40,fromhex(‘fff444’));
imageString ( $img1, 200, 50,5, $words,fromhex(‘660044’));

header(“Content-type: image/jpeg”);
imagejpeg($img1);
imageDestroy($img1);
?>

The problems I am having are:

1) imageRectangle command just puts the color into the whole image and I don’t get
any rectangle.

2) imageString is supposed to draw the text according to the font size, in this case 5, but it is no bigger than when I put 2 in that place.

3) when I try to save the file using imagejpeg($img1, xxx.jpeg, 100);
I get a message saying that my image has errors – but it display ok if i output it directly to the screen.

Any help is most appreciated.

Thanks
David.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@DaveinLondonauthorJan 12.2005 — No answers !

! wow !

Does no-one know ? !!
Copy linkTweet thisAlerts:
@purefanNov 01.2005 — i dont ?

but I found this about image creation:

http://www.php-mysql-tutorial.com/user-authentication/image-verification.php

might come in handy to some of us
Copy linkTweet thisAlerts:
@SpectreReturnsNov 01.2005 — I would try this on truecolor mode, because it might just be giving you a color index. Using imagefilledrectangle will fill the rectangle, as well.
×

Success!

Help @DaveinLondon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...