PHP Classes

PHP Image Overlay Text: Render multiple texts over an image

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 74%Total: 278 This week: 1All time: 7,633 This week: 560Up
Version License PHP version Categories
image-overlayer 1.0.0GNU General Publi...5PHP 5, Graphics, Text processing
Description 

Author

This class can render multiple texts over an image.

It can take a given image and renders one or more texts on the top of the image.

The text, coordinates, font, color of the texts and the size of the resulting image are configurable parameters.

The image with overlay texts may be returned in PNG or JPEG format as a string of a data URL.

This package requires the GD and EXIF extensions.

Picture of Alexandre Sinício
  Performance   Level  
Name: Alexandre Sinício <contact>
Classes: 7 packages by
Country: Brazil Brazil
Age: 39
All time rank: 2095136 in Brazil Brazil
Week rank: 416 Up36 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php
require '../imageOverlayer.php';

use
alesinicio\imageOverlayer;

//SETS THE CONFIGURATION FILE.
//SEE THE FILE FOR MORE INFORMATION.
$configurationFile = "overlay_config.php";

try {
   
$imgOutput = imageOverlayer::overlay($configurationFile); //CREATES AN IMAGE WITH THE OVERLAY.
   
$base64 = imageOverlayer::imgToBase64($imgOutput); //BASE64 ENCODING SO WE AVOID SAVING FILES TO DISK.
   
echo "<img src='$base64'>";
} catch (
Exception $e) {
    echo
$e->getMessage();
}


Details

alesinicio/imageOverlayer

The alesinicio/imageOverlayer class allows the easy creation of multiple text overlays in images.

The usage is very simple. You will need: - the class source (imageOverlayer.php); - the image file which will be overlayed; - a configuration file which tells how the overlaying will be done; - the font files (TTF) you will use.

<h2>Basic usage</h2>

use alesinicio\imageOverlayer;

$configurationFile = "overlay_config.php";

$imgOutput			= imageOverlayer::overlay($configurationFile);	//CREATES AN IMAGE WITH THE OVERLAY.
$base64				= imageOverlayer::imgToBase64($imgOutput);		//BASE64 ENCODING SO WE AVOID SAVING FILES TO DISK.
echo "<img src='$base64'>";

<h2>Advantages</h2> You can setup multiple overlays. Suppose you want to create both a "Happy Birthday" card and a "Happy Halloween" card. You will then get two images (the templates) and create two configuration files, which will tell the class where the overlays should be placed, and which data.

<h2>Flexible</h2> The data you will use is configurable. Maybe it will come from a database, maybe from a form, maybe it is hard-coded... it is your choice!

<h2>Requirements</h2> Your PHP must be compiled with FreeType support.


  Files folder image Files  
File Role Description
Files folder imageexample (3 files, 1 directory)
Plain text file imageOverlayer.php Class Class source
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  example  
File Role Description
Files folder imageimages_src (1 file)
  Accessible without login Plain text file example.php Example Example script
  Accessible without login Image file example_output.jpg Photo Output of the example script
  Accessible without login Plain text file overlay_config.php Conf. Configuration script

  Files folder image Files  /  example  /  images_src  
File Role Description
  Accessible without login Image file template.jpg Icon Icon image

 Version Control Unique User Downloads Download Rankings  
 100%
Total:278
This week:1
All time:7,633
This week:560Up
User Ratings User Comments (1)
 All time
Utility:91%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:74%StarStarStarStar
Rank:110