PHP Classes

Nano PHP Stamp: Create images for stamps with custom graphics

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 38 All time: 10,933 This week: 206Up
Version License PHP version Categories
nano-stamp 1.0.2GNU General Publi...5PHP 5, Graphics
Description 

Author

This package can create images for stamps with custom graphics.

It can define the graphics appearing in the stamp image using text messages that can be rendered in different colors and aligned to the left, right, or center of a given point.

The final stamp image can have a square or round shape.

The generated image file can be saved to a file, displayed as the current script output, or served for download.

Picture of Ujah Chigozie peter
  Performance   Level  
Name: Ujah Chigozie peter <contact>
Classes: 28 packages by
Country: Nigeria Nigeria
Age: 33
All time rank: 198810 in Nigeria Nigeria
Week rank: 10 Up1 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 11x

Example

<?php
error_reporting
(E_ALL);
ini_set('display_errors', '1');
require_once
__DIR__ . "/autoload.php";


use
NanoBlockTech\Stamp\Circle;
use
NanoBlockTech\Stamp\Square;
use
NanoBlockTech\Stamp\Colors;
use
NanoBlockTech\Stamp\Stamp;

//$square = new Stamp(new Square(400, 200));
$circle = new Stamp(new Circle(400, 400));
$stamp = $circle->getContainerInstance();

$stamp->setFont(__DIR__ . '/font/industry-bold.ttf');
$stamp->setBackgroundColor(Colors::ALPHA_WHITE);
$stamp->drawBorder(Colors::VIOLET);
/*
$stamp->drawCenterText("My Company Name Here",[
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "right" => 125,
    "top" => -30,
]);
$stamp->drawCenterText("27 Aug 2023", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "right" => 80,
    "top" => 30,
]);
$stamp->drawCenterText("Verified Stamp", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "right" => 80,
    "top" => 90,
]);

$stamp->drawRightText("Vertical", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 110,
    "right" => 55,
]);

$stamp->drawLeftText("27 Aug 2023", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 170,
    "left" => 230,
]);*/



/* Circle */

$stamp->drawRoundText("Round Text Here", 20, Colors::VIOLET, true);
/*$stamp->drawCenterText("Horizontal Text Here", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 200,
    "left" => 60,
]);
$stamp->drawCenterText("27 Aug 2023", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 250,
    "left" => 60,
]);*/


$stamp->drawVerticalText("Vertical Text Here", [
   
"fontSize" => 20,
   
"color" => Colors::VIOLET,
   
"top" => 220,
   
"left" => 10,
]);
$stamp->drawVerticalText("27 Aug 2023", [
   
"fontSize" => 20,
   
"color" => Colors::VIOLET,
   
"top" => 170,
   
"left" => 15,
]);
$stamp->create('stamp_image.png', "S");


Details

Nano Stamp

Nano Stamp is Php Class to create a custom stamp using the GD Graphics Library. It simplifies the process of generating stamps, such as circular and square designs, accompanied by dynamic text and styling.

Installation

Installation is available via Composer:

composer require peterujah/nano-stamp

Example Stamp

<img src="https://raw.githubusercontent.com/peterujah/nano-stamp/main/test/stamp_circle.png" alt="image 1" width="250" /><img src="https://raw.githubusercontent.com/peterujah/nano-stamp/main/test/stamp_circle_vertical.png" alt="image 2" width="250" /><img src="https://raw.githubusercontent.com/peterujah/nano-stamp/main/test/stamp_square.png" alt="image 3" width="250" />

Initialize class

use Peterujah\NanoBlockTech\Stamp\Circle;
use Peterujah\NanoBlockTech\Stamp\Square;
use Peterujah\NanoBlockTech\Stamp\Colors;
use Peterujah\NanoBlockTech\Stamp\Stamp;

To draw a square stamp initialize with a square instance

$shape = new Stamp(new Square(400, 200));

To draw a round stamp initialize with a circle instance

$shape = new Stamp(new Circle(400, 400));

Use your stamp shape container instance

$stamp = $shape->getContainerInstance();

Set your text font path

$stamp->setFont(__DIR__ . '/font/industry-bold.ttf');

Set your background color or use the default transparent background

$stamp->setBackgroundColor(Colors::ALPHA_WHITE);

Drow your border with RGB color array

$stamp->drawBorder(Colors::VIOLET);

For Square Shape Stamp

Adjust the right and top to fit your text

$stamp->drawCenterText("My Company Name Here",[
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "right" => 125,
    "top" => -30,
]); 
$stamp->drawCenterText("27 Aug 2023", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "right" => 80,
    "top" => 30,
]);
$stamp->drawCenterText("Verified Stamp", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "right" => 80,
    "top" => 90,
]);

$stamp->drawRightText("Vertical", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 110,
    "right" => 55,
]);

$stamp->drawLeftText("27 Aug 2023", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 170,
    "left" => 230,
]);

For Circle Shape Stamp

Adjust the left and top to fit your text

Drow round text

$stamp->drawRoundText("Round Text Here", 20, Colors::VIOLET, true);

Drow a center text

$stamp->drawCenterText("Horizontal Text Here", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 200,
    "left" => 60,
]);
$stamp->drawCenterText("27 Aug 2023", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 250,
    "left" => 60,
]);

To draw a vertical center text only available for circle shape stamp

$stamp->drawVerticalText("Vertical Text Here", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 220,
    "left" => 10,
]);
$stamp->drawVerticalText("27 Aug 2023", [
    "fontSize" => 20,
    "color" => Colors::VIOLET,
    "top" => 170,
    "left" => 15,
]);

Now save, download or preview generated stamp Flag D = Download, S = Save, I = Display

$stamp->create('stamp_image.png', "S");

  Files folder image Files (16)  
File Role Description
Files folder imagefont (1 file)
Files folder imagesrc (6 files, 1 directory)
Files folder imagetest (4 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (16)  /  font  
File Role Description
  Accessible without login Plain text file font.txt Data Empty file

  Files folder image Files (16)  /  src  
File Role Description
Files folder imageExceptions (2 files)
  Plain text file Circle.php Class Class source
  Plain text file Colors.php Class Class source
  Plain text file Output.php Class Class source
  Plain text file Square.php Class Class source
  Plain text file Stamp.php Class Class source
  Plain text file StampInterface.php Class Class source

  Files folder image Files (16)  /  src  /  Exceptions  
File Role Description
  Plain text file StampArgumentException.php Class Class source
  Plain text file StampException.php Class Class source

  Files folder image Files (16)  /  test  
File Role Description
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Image file stamp_circle.png Icon Icon image
  Accessible without login Image file stamp_circle_vertical.png Icon Icon image
  Accessible without login Image file stamp_square.png Icon Icon image

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  
 100%
Total:38
This week:0
All time:10,933
This week:206Up