cschoenfeld / colorizer
There is no license information available for the latest version (dev-master) of this package.
Generate SVG filters to colorize images via CSS.
dev-master
2016-03-18 16:05 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2026-02-26 06:54:01 UTC
README
Color helper classes.
Generate SVG filters that can be used to apply color overlays
to images in a web page via CSS.
@author Charles Schoenfeld
STEP 1:
To write an SVG filter definition into your HTML, do the following.
<?php
use CSchoenfeld\ColorSpec;
use CSchoenfeld\Colorizer;
try {
/*
In this example, you're trying to apply a 60% tint of orange
to some of the images in your page.
*/
$filterName = 'colorizeOrange';
$colorOrange = new CSchoenfeld\ColorSpec();
$colorOrange->setHex('f16234');
$colorStrength = 60;
$orangeFilter = CSchoenfeld\Colorizer::makeFilter($filterName, $colorOrange, $colorStrength);
echo $orangeFilter;
} catch (Exception $ex) {
// Handle any exceptions here.
}
?>
STEP 2:
Reference this filter in your CSS, for browsers that support it.
.orangeImage {
filter: url(#colorizeOrange);
-webkit-filter: url(#colorizeOrange);
}
And apply that CSS class to the image in your HTML.
<img src="myimage.png" class="orangeImage" alt="orange image">