Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    13

    Unanswered: drawing text on an image

    Hi
    i have a jpeg image and i wanted to write a text over that jpeg image
    I can write text over a image with imagestring function but text is in black color i cannot change text color ,

    when i use the same funciton without a jpeg image it changes the font color
    PHP Code:
    <?php
       header
    ("Content-type: image/jpeg");
       
    // option one 
      // create a 100*30 image
      
    $im imagecreate(400100);
      
    // option two 
      // creating a image from jpeg 
      
    $im = @imagecreatefromjpeg("../../../images/home/tower.jpg"
      or die(
    "Cannot Initialize new GD image stream");

      
    // white background and blue text
      
    $bg imagecolorallocate($im255255255);
      
    $textcolor imagecolorallocate($im00255);
      
      
    // write the string at the top left
      
    imagestring($im500"Hello world!"$textcolor);
      
      
    // output the image
       
    imagejpeg($im);
      
    ImageDestroy ($im);
    ?>
    both does work but if i use option two the font colro remains black , and if i use option one it changes to blue

    any one can help ....

    Thanks
    Last edited by rhs98; 01-23-04 at 11:29.
    Manish Khanna
    manish@i4u.com.au

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Please use [ php ] some code [ / php ] tags in future...


    Have you read the GD documentation?

    http://www.php.net/manual/en/ref.image.php

  3. #3
    Join Date
    Oct 2003
    Posts
    13

    drawing text on image

    Hi
    I am not that good in reading documentation , but still i think i had a look at that , so far it tells about GD library.

    which explains about the functions with php integrated GD lib in 4.3
    and installation and stuff

    please explain what you mean by
    " Have you read the GD documentation? "

    and if you can ellaborate what you want me to read ..

    i had a simple problem which is resolved by imagemagic tool, but still i want to know how to do that with PHP

    i had explained one code changes the color of text and another doesnt , i dont knwo why ?
    code 1
    PHP Code:
    <?php
       header
    ("Content-type: image/jpeg");
       
    // option one 
      // create a 100*30 image
      
    $im imagecreate(400100);
      
    // white background and blue text
      
    $bg imagecolorallocate($im255255255);
      
    $textcolor imagecolorallocate($im00255);
      
      
    // write the string at the top left
      
    imagestring($im500"Hello world!"$textcolor);
      
      
    // output the image
       
    imagejpeg($im);
      
    ImageDestroy ($im);
    ?>

    Code 2
    this does work
    PHP Code:
    <?php
       header
    ("Content-type: image/jpeg");
      
    // option two 
      // creating a image from jpeg 
      
    $im = @imagecreatefromjpeg("../../../images/home/tower.jpg"
      or die(
    "Cannot Initialize new GD image stream");

      
    // white background and blue text
      
    $bg imagecolorallocate($im255255255);
      
    $textcolor imagecolorallocate($im00255);
      
      
    // write the string at the top left
      
    imagestring($im500"Hello world!"$textcolor);
      
      
    // output the image
       
    imagejpeg($im);
      
    ImageDestroy ($im);
    ?>
    This doesnt work

    if you can help , thanks

    Manish
    Manish Khanna
    manish@i4u.com.au

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •