PHP Classes

Date PNG: Generate a PNG image with a given time

Recommend this page to a friend!
  Info   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 418 All time: 6,418 This week: 455Up
Version License PHP version Categories
datepng 0.9GNU General Publi...5.0PHP 5, Time and Date, Graphics
Description 

Author

This class can be used to generate a PNG image with a given time.

It opens a given template image in PNG format and renders a text with given time in one or more formats.

The font, size, position, angle and color of the text are configurable parameters.

The resulting image is generated in the PNG format as the current script output.

Picture of Buddhika Laknath
Name: Buddhika Laknath <contact>
Classes: 1 package by
Country: Sri Lanka Sri Lanka
Age: 37
All time rank: 34928 in Sri Lanka Sri Lanka
Week rank: 192 Up2 in Sri Lanka Sri Lanka Up

Details

author Laknath (blaknath [at] gmail [dot] com) version 0.9 to see a live demo of this class, check http:hotelotravel.com License ======== DatePNG - Create the png from a given date Copyright (C) 2009 by Buddhika Laknath <blaknath [at] gmail [dot] com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http:www.gnu.org/licenses/>. Functionality: ============== when given a valid timestamp it creates a png image with the given date format and png background template in the designated folder. To optimize the process and avoid having to create pngs every time the site loads it caches created pngs and use them if a given date png already exists. Example: ======== <?php get font ttf path $font = $_SERVER["DOCUMENT_ROOT"].'/Arial.ttf'; png file template that's used as the background $png_path = $_SERVER["DOCUMENT_ROOT"].'/date.png'; create a DatePNG object with the current timestamp and png file template $datePNG = new DatePNG($time(), $png_path); define the folder which the font files should be created (this folder must exist and writable) $datePNG->folder = $_SERVER["DOCUMENT_ROOT"].'/dates'; define the text style and date pattern, each text pattern in each associated array Possible values for the associated array with keys $datePNG->formats = array( array('format'=>'d','font'=> $font, 'size'=>14,'angle'=>0,'x'=>5,'y'=>20,'color'=>'0x666666', 'linespacing' => 1.5), array('format'=>'M','font'=> $font, 'size'=>8,'angle'=>0,'x'=>5,'y'=>37,'color'=>'0x666666', 'upper_case' => true) ); create the png and return the path of the created date png $date_path = $datePNG->create_png(); echo '<img src="'.$date_path.'" alt="date" />' ; ?>

Screenshots (1)  
  • datepng.png
  Files folder image Files (4)  
File Role Description
Image file date.png Photo PNG template
Plain text file DatePNG.inc.php Class DatePNG.class
Plain text file README Doc. README

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:418
This week:0
All time:6,418
This week:455Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:83%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1466