Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Adding Text to Image - Resizing Text etc... (Image Chef)

    I'm trying to make an Image-Chef like PHP function. Currently I have this


    <?php

    header("Content-type: image/png");
    $string = $_GET['text'];
    $im = imagecreatefrompng("Egypt.png");
    $orange = imagecolorallocate($im, 219, 181, 1);
    $black = imagecolorallocate($im, 0, 0, 0);
    $px = (imagesx($im) + 16 * strlen($string)) / 2;
    imagestring($im, 26, $px, 48, $string, $black);
    imagestring($im, 25, $px, 47, $string, $orange);
    imagepng($im);
    imagedestroy($im);

    ?>


    This allows the production of an image with the text I input in the Url (in fore color and with a shadow) lying over the base image provided. The intention is just a small thing similar to imagechef.com where I can enter small amounts of text and incorporate it directly onto the image. The thing I am struggling with primarily is resizing the text based on the length of the string.

    Basically, on image chef, there is a defined width that the text can occupy. If the text occupies more that this width it is scrunched together to fit. Is it possible to do this here? Any suggestions on improvement?



    Thanks.

  • #2
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anyone have any ideas?

    Thanks


  •  

    Posting Permissions

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