To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Coding

Coding Help with PHP coding

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 01-14-2008, 08:03 PM   #1
Teach
Senior Member
 
Join Date: Dec 2003
Location: Planet Earth, I hope.
Posts: 297
Image reflection...

Hello guys, I hope you can help me with this

I am trying to add a PHP-serverside image reflection, using the tutorial at http://www.talkphp.com/advanced-php-...tions-php.html

At the moment, we only want to apply it to our staff signatures, and for the reflection to be about 50% the height of the real image (which then fades into the background)...

I tried using the tutorial and putting the relevant lines in, changing jpeg to png (as that's what the rest uses) and only using the header, imagepng and imagedestroy lines once, but I just got tonnes of errors. Can you help me integrating that script into mine to make it work?

Thanks!

PHP Code:
<?php
include_once('/home/site/functions-connectonly.php');
putenv('GDFONTPATH=' . realpath('.'));

if (isset(
$_GET['staffid'])) {
  
$staffid = ($_GET['staffid']);

  
$num_users=mysql_num_rows(mysql_query("Select * from user where account='".mysql_real_escape_string(htmlentities($staffid))."'"));
  if (
$num_users>0) {

    
$ourGroups='';
    
// fetch user from db
    
$user=mysql_fetch_array(mysql_query("Select * from user where account='".mysql_real_escape_string(htmlentities($staffid))."'"));
    
$flag=mysql_fetch_array(mysql_query("Select * from flag where id_flag=".$user['location']));

    
// Group code here (irrelevant)

    
$name = "".$user['account']."";
    if (
strlen($ourGroups)>0) {
       
$text = "\n".$ourGroups."\nhttp://oursite.com";
    } else {
       
$text = "\nNo groups\nhttp://oursite.com";
    }

    
// tell the browser what it's about to recieve
    
header("Content-type: image/png");

    
// import background image
    
$img = @imagecreatefrompng("/home/site/img/sigbg.png");
    
$im = imagecreatetruecolor(185, 58);

    
// font details
    
$font = 'segoe.ttf';

    
// insert the flag
    
$insert = imagecreatefrompng("/home/site/img/flags/".$flag['img']."");

    
// Select the first pixel of the overlay image (at 0,0) and use
    // it's color to define the transparent color

    
imagecolortransparent($insert,imagecolorat($insert,0,0));

    
// Get overlay image width and hight for later use

    
$insert_x = imagesx($insert);
    
$insert_y = imagesy($insert);

    
// Combine the images into a single output image. Some people
    // prefer to use the imagecopy() function, but more often than
    // not, it sometimes does not work. (could be a bug)

    
imagecopymerge($img,$insert,162,5,0,0,$insert_x,$insert_y,100);

    
// text color
    
$white = imagecolorallocate($img, 255, 255, 255);
    
$grey = imagecolorallocate($img, 225, 225, 225);

    
// add the text to the image ,
    
$textarr = explode("\n",$text);
    
$i = 16;
    foreach(
$textarr as $a){
      
imagettftext($img, 10, 0, 52, 16, $white, $font, $name);
      
imagettftext($img, 8, 0, 52, $i, $grey, $font, $a);
      
$i=$i+17;
    }

    
// date in the past, so that the image is not cached by the browser
    
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

    
// create the png image
    
imagepng($img);

    
// clean up
    
imagedestroy($img);

  }
}
?>
__________________
With regards,

Dan.

"Some have been thought brave
because they were too scared to
run away".
Teach is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 02:12 AM.








Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.