PNG Hex Color Modifier: Replaces a color in a PNG image by another color

Recommend this page to a friend!
  Info   Documentation   View files (13)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 158 All time: 8,752 This week: 349
Version License PHP version Categories
hexpng 1.1Custom (specified...5PHP 5, Graphics
Description Author

This class can replaces a color in a PNG image by another color.

It takes a given color and replaces it in PNG image by another color.

The class saves back the image PNG file and returns the changed image as a data URL.

Innovation Award
PHP Programming Innovation award winner
August 2016

Prize: One big elePHPant Plush Mascott
Sometimes you need to generate variants of the same image to present it in different colors.

PHP provides a good set of functions that you can use to manipulate images in any way you need. However some kinds of image processing can be very slow to run as PHP scripts.

This class provides a solution to create variants of a PNG image with a different background color, just by reading the PNG file contents and replacing a few bytes in the image file data directly.

Manuel Lemos
Picture of Bruno Henrique Ferreira de Oliveira
  Performance   Level  
Name: Bruno Henrique Ferreira ... <contact>
Classes: 4 packages by
Country: Brazil Brazil
Age: 27
All time rank: 2869212 in Brazil Brazil
Week rank: 713 35 in Brazil Brazil
Innovation award
Innovation award
Nominee: 3x

Winner: 1x


?=============PNG Hex Color Modifier=============


-Paint a png image by hex reflecting in the front.

-Overrides the Hex value of the main PNG image file and make it viewed for the web and S.O.

-The client-side changes are controlled by the javascript.

-Even when reloading the page, the color continues as the last modified because the image file was modified too.


-PHP 5;


-The test.png in the img directory is the PNG that will be modified.

-The main class is in the resources directory.

-The controller is the javascript and it is loaded by the home.html where are the radios buttons for the test.

-Bonus: JPG image HEX color modifier added (experimental stable release), download main image and set it in home.html.

To do.

-Add support for more colors.


-In the custom license file.

File Role Description
doc (3 files)
img (2 files)
public (1 file, 2 directories)
resources (3 files)
LICENSE Lic. License text Doc. Documentation

  Files  /  doc  
File Role Description Doc. Image behavior note in portuguese Lic. Custom License file. Doc. Introduction, requirements, usage, to do.

  Files  /  img  
File Role Description
   test.jpg Data My JPG image test for my bonus.
   test.png Data Main PNG file that will be modified.

  Files  /  public  
File Role Description
js (1 file)
css (1 file)
   home.html Data Client-side reflect.

  Files  /  public  /  js  
File Role Description
   coloRequest.js Data Request and control of the change.

  Files  /  resources  
File Role Description
   ImageHexModJPG.php Class Bonus, JPG Edition of Hex color modifier.
   ImageHexModPNG.php Class PHP class file.
   post.php Example Example script

  Files  /  public  /  css  
File Role Description
   style.css Example Simple css style file.

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,752
This week:349

For more information send a message to info at phpclasses dot org.