susros/colorbarcoder

ColorbarCoder is PHP class for encoding and decoding color barcode image.

v1.0.2 2018-11-20 07:02 UTC

This package is auto-updated.

Last update: 2024-08-20 22:26:01 UTC


README

ColorbarCoder

ColorbarCoder

ColorbarCoder encodes the original text string to color codes and decode color codes from color bar image into its original text.

Documentation

Full documentation: Here

Installation

ColorbarCoder can be downloaded manually or cloneed by using:

git clone git@github.com:Susros/ColorbarCoder.git

ColorbarCoder is also availabe on Packagist. To install it with Composer, add this line to your composer.json file:

"susros/colorbarcoder" : "~1.0.2"

or run

composer require susros/colorbarcoder

Basic Usage

Include ColorbarCoder if you are not using autoload.

include_once "path/to/ColorbarCoder.php";
use ColorbarCoder\ColorbarCoder;

Instantiate ColorbarCoder

$colorbarCoder = new ColorbarCoder();

Encode the text,

// Original text 
$text = "This is awesome!"; 

// Encode the text
$colorbarCoder->encode($text);

Print the colorbar image,

$colorbarCoder->printColorbarImage(500, 500);

This will print out image with 500 x 500 dimention. The default image extension is PNG. JPG format can be created by declaring JPG in the parameter. However, only PNG works for decoding the color bar as JPG will reduce the quality and result in different color code. Therefore, the original text will not be accurate. It is recommended to use PNG instead.

alt text

Decode the color bar image,

// Image file
$image = "./img/colorbar.png";

// Decode the image
$colorbarCoder->decode($image);

Print the decoded text,

echo $colorbarCoder->getText();

Output

This is awesome!

For more usages: See here