1
zyspec
PHP image rendering in a custom block
  • 2006/2/20 21:54

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


What I'm attempting to do is use the php imagestring functions. Below is a simplified version of the code I'd like to use but I can't get it to render in a custom block (even with content type set to PHP Script).
$im = @imagecreate(12030);
$background_color imagecolorallocate($im255255255);
$text_color imagecolorallocate($im00153);
imagestring($im155,  "A Simple Text String"$text_color);

if (
function_exists("imagegif")) {
  
header("Content-type: image/gif");
  
imagegif($im);
  
imagedestroy($im);
} else {
   die(
"No image support in this PHP server");
}


This code renders fine outside of XOOPS but it won't display inside a custom block... It looks like the output is converted to ASCII text - any ideas?

2
Dave_L
Re: PHP image rendering in a custom block
  • 2006/2/20 22:23

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Quote:
header("Content-type: image/gif");


That won't work, because the HTTP headers have already been output.

The only way I can think of doing this is to use a separate script to generate the image, and then load that script in the custom block with an < img > tag.

3
zyspec
Re: PHP image rendering in a custom block
  • 2006/2/20 22:29

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Thanks... That's probably what I'll do. I had previously thought about using a seperate script to save the image file and then just display it in the custom block like you suggest (using <img> tags). I was just hoping I could do it all "on the fly" without having to thrash my disk with the temporary image creation.

4
Dave_L
Re: PHP image rendering in a custom block
  • 2006/2/20 22:35

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


You don't need to save the image as a file. Just put the code you posted in the separate script, and reference that script in the < img > tag:

<img src='script.php' width='xxx' height='xxx' alt='xxx' />

5
zyspec
Re: PHP image rendering in a custom block
  • 2006/2/21 2:10

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Of course - I don't know why I didn't think of that. Thanks Dave_L

Login

Who's Online

142 user(s) are online (82 user(s) are browsing Support Forums)


Members: 0


Guests: 142


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits