note 99204 added to function.imagettftext

From: Date: Tue, 03 Aug 2010 11:46:15 +0000
Subject: note 99204 added to function.imagettftext
Groups: php.notes 
Request: Send a blank email to php-notes+get-171351@lists.php.net to get a copy of this message
Just created a HTML5 Video Poster Image generator in PHP - code is below if anyone wants to use. It's heavily commented, so you should be able to adjust it easily. It puts a transparent black bar along the top of an image, and writes some text in white over it - easily readable and applicable to most images. <?php // PHP File used to quickly put some text over a poster image - for video or other. // To use: Use this file as the source file of an image. Pass it two GET variables: pat=path of image&text=text to overlay header("Content-Type: image/jpeg"); // Open the image: $image = imagecreatefromjpeg($_SERVER['DOCUMENT_ROOT'] . $_GET['path']); $width = imagesx($image); // Gets the width - better to use imagesx here as we don't need to feed it a path, just a handle. $rectCol = imagecolorallocatealpha($image, 0, 0, 0, 40); // Create a black colour, slightly transparent $textCol = imagecolorallocate($image, 255, 255, 255); // Create a white colour // Fill the top of the image with this rectangle... imagefilledrectangle($image, 0, 0, $width, 50, $rectCol); $textX = 10; $textY = 32; // X and Y values for the text generation $font = $_SERVER['DOCUMENT_ROOT'] . '/site/fonts/Verdana.ttf'; // Replace this with the path to your font file. // Write Text: imagettftext($image, 18, 0, $textX, $textY, $textCol, $font, $_GET['text']); // Now we're done editing... output the final image: imagejpeg($image); // Free up some space: imagedestroy($image); ?> ---- Server IP: 89.36.197.2 Probable Submitter: 87.113.102.11 ---- Manual Page -- http://www.php.net/manual/en/function.imagettftext.php Edit -- https://master.php.net/note/edit/99204 Del: integrated -- https://master.php.net/note/delete/99204/integrated Del: useless -- https://master.php.net/note/delete/99204/useless Del: bad code -- https://master.php.net/note/delete/99204/bad+code Del: spam -- https://master.php.net/note/delete/99204/spam Del: non-english -- https://master.php.net/note/delete/99204/non-english Del: in docs -- https://master.php.net/note/delete/99204/in+docs Del: other reasons-- https://master.php.net/note/delete/99204 Reject -- https://master.php.net/note/reject/99204 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171351) next »