People used to write Greasemonkey scripts or exploit some long-forgotten Gmail Labs extensions… but there's an easier way: just generate images on the fly and refer them in signatures.
Here's my quick-and-dirty way of doing it:
// Set the content-type header('Content-Type: image/png'); // Create the image $image = imagecreatetruecolor(450, 200); // Fill image with white $white = imagecolorallocate($image, 255, 255, 255); imagefilledrectangle($image, 0, 0, 449, 199, $white); // Font settings $font ='./UbuntuMono-R.ttf'; $font_size = 8; $font_color = 0x4A4A4A; // Get the cookie $text = shell_exec('/usr/games/fortune fortune'); $lines = explode('\n', $text); // Starting Y position $y = 12; // Loop through the lines and place them on the image foreach ($lines as $line) { imagettftext($image, $font_size, 0, 12, $y, $font_color, $font, $line); // Increment Y so the next line is below the previous line $y += 12; } // Dump the image on screen imagepng($image); imagedestroy($image);
Tags: