Jump to content

Dynamic Text on an Image to Make Dynamic Headers!!!


natasha_thomas

Recommended Posts

Folks,

 

I need help (Php code ) to generate a Dynamic Text on a Base Image. What i want to do is, to make this Image as header on my Site and to make this Header Specific to a Site, i want to Add the Domain Name on the Lower Left of the Image.

 

Got the Idea?

 

Here is the Image link:

 

 

PHP Variable that holds the Domain name is:

 $domain 

 

All i need the Dynamic PHP Codes that i can put on all my sites to generate this Text on Image (Header) Dynamically...

 

May Anyone Help me with this Please?

 

Cheers

Natasha T.

 

 

Link to comment
Share on other sites

<?php

  // headers
  header('Cache-Control: no-cache');
  header('Pragma: no-cache');
  header("Content-Type: image/jpeg");

// generate image
$image = "http://img27.imageshack.us/i/shoppingheader1.jpg"; 
$font = 'DarkCrystal.ttf'; // can just download a free true type font (.ttf)
$img = imagecreatefromjpeg($image); // create jpeg image from URL supplied
// workout colors
$black = ImageColorAllocate($img, 0, 0, 0);  // black
$red = ImageColorAllocate($img, 255, 0, 0); // red
$white = ImageColorAllocate($img, 255, 255, 255); // white

$TextColor = $black; // use black as the text color

// http://au.php.net/manual/en/function.imagettftext.php
// array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
imagettftext ( $img , 12 , 0 , 15 , 15 , $TextColor , $font , $domain );

// create the image
Imagejpeg($img,'',1);  
ImageDestroy($img); 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.