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.

 

 

<?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); 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.