Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page PHP imageline() imagepng() not working
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Junior Member
Asgarnian is on a distinguished road
 
Posts: 3
Join Date: Feb 2012
Default PHP imageline() imagepng() not working - 02-09-2012, 08:55 AM

I have this code:

<html>
<?php
header('Content-type: image/png');
$png_image = imagecreate(150, 150);
imagecolorallocate($png_image, 15, 142, 210);
$black = imagecolorallocate($png_image, 0, 0, 0);
imageline($png_image, 0, 0, 150, 150, $black);
imagepng($png_image);
imagedestroy($png_image);
?>
</html>

And this is the result that webpage shows: http://asgarnian.net78.net/drawimage.php

Why is it not working, I checked this Host Settings and it does have GD support. What am I missing? Are there any settings I need to set?

This is in my php info:

'--with-gd=/usr' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--with-xpm-dir=/usr' '--with-ttf=/usr' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--with-gettext=/usr' '--with-gmp=/usr'

so I guess it should work? also the Php code was directly copied from some php tutorial site...

Last edited by Asgarnian; 02-09-2012 at 09:30 AM. Reason: failed to do the[URL]Correctly xD
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Junior Member
Asgarnian is on a distinguished road
 
Posts: 3
Join Date: Feb 2012
Default 02-09-2012, 10:52 AM

Well i got it to work, but doesn't work ok. There Must be no empty Lines before <?php.
Also it doesn't work if I put HTML tags inside. it also doesn't work if I put anything before that header( ). it works if I put echo "blablabla"; after the abbove code, but the "blablabla" doesn't get echoed.

Does anyone knows how to get around it? I want to display certain php drawn images in the middle of other context on my page.
Reply With Quote
(#3 (permalink))
Old
Junior Member
biazzotto is on a distinguished road
 
Posts: 2
Join Date: Feb 2012
Lightbulb Create two files - 02-09-2012, 12:51 PM

Hi Asgarnian,

You can create two files, one will be the webpage and the other will be the image.

Example:

index.php
<html>
<body>
<?php echo "blablabla"; ?>
<img src="image.php">
</body>
</html>

image.php
<?php
header('Content-type: image/png');
$png_image = imagecreate(150, 150);
imagecolorallocate($png_image, 15, 142, 210);
$black = imagecolorallocate($png_image, 0, 0, 0);
imageline($png_image, 0, 0, 150, 150, $black);
imagepng($png_image);
imagedestroy($png_image);
?>
Reply With Quote
(#4 (permalink))
Old
Junior Member
Asgarnian is on a distinguished road
 
Posts: 3
Join Date: Feb 2012
Default 02-09-2012, 01:40 PM

Yes I have figured it out thanks to this post: http://stackoverflow.com/questions/3...ontains-errors, just a few minutes before your Reply biazzotto.

Thanks a lot anyway! The Solution works perfectly
Reply With Quote
Reply

Tags
php imageline imagepng

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com