Topic: Regarding Image display

Hi,

I would like to create image using php and display on the browser. The text for the image will be taken from database. I created one, but for the next image, i dont know how to proceed. It simply shows only one image. I want to print list of images 1 below the other, Example; List of Albums Names. If anyone know about image creation in PHP, do suggest.


here is my simple code.

<?
    $text="Topic Heading / Sub-Heading";
    $x=10;
    $y=20;
    $w=500;
    $h=27;
    $size=10;
    
    $fontfile="VERDANA.TTF";
    $angle=0;

    header ("Content-type: image/png");
    $im = @imagecreate ($w, $h) or die ("Cannot Initialize new GD image stream");
    
    $background_color = imagecolorallocate ($im, 251, 121, 34);
    $text_color1 = imagecolorallocate ($im, 0, 0 ,  0);
    $text_color2 = imagecolorallocate ($im, 255, 255,  255);
    
    ImageTTFText ($im, $size, $angle, $x+1, $y+1, $text_color2, $fontfile, $text);
    ImageTTFText ($im, $size, $angle, $x, $y, $text_color1, $fontfile, $text);
    imagepng ($im);
    imagedestroy ($im);
?>
God wisely designed the human body so that we can neither pat our own backs nor kick ourselves too easily

Re: Regarding Image display

Also I would like to keep it in function so that can access it anytime i want using the fu name like...

make_image("text-string","width","height");

God wisely designed the human body so that we can neither pat our own backs nor kick ourselves too easily

Re: Regarding Image display

It's been a while since I did image creating, but I remember using imagestring() instead.

And the function is quite easy:

<?php
function make_image($text, $w, $h)
    {
    $text="Topic Heading / Sub-Heading";
    $x=10;
    $y=20;
    $size=10;
    
    $fontfile="VERDANA.TTF";
    $angle=0;

    header ("Content-type: image/png");
    $im = @imagecreate ($w, $h) or die ("Cannot Initialize new GD image stream");
    
    $background_color = imagecolorallocate ($im, 251, 121, 34);
    $text_color1 = imagecolorallocate ($im, 0, 0 ,  0);
    $text_color2 = imagecolorallocate ($im, 255, 255,  255);
    
    ImageTTFText ($im, $size, $angle, $x+1, $y+1, $text_color2, $fontfile, $text);
    ImageTTFText ($im, $size, $angle, $x, $y, $text_color1, $fontfile, $text);
    imagepng ($im);
    imagedestroy ($im);
    }
?>

4 (edited by ameenullah 2006-04-28 05:48)

Re: Regarding Image display

Thank you elbekko, it works fine for me... smile

Do u suggest some good site for GD lib usage...

God wisely designed the human body so that we can neither pat our own backs nor kick ourselves too easily

Re: Regarding Image display

ameenullah wrote:

Do u suggest some good site for GD lib usage...

I can't say anything as to how good it is, but I found this on Stumbleupon yesterday:

http://phpgd.com/

Looking for a certain modification for your forum? Please take a look here before posting.

Re: Regarding Image display

I made this in GD just now, just because I was bored:

http://icstrategy.midgetforhire.com/tests/GDTest.php