Source for file Utils.php
Documentation is available at Utils.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */
* This file contains the Image_Tools_Utils class.
* Copyright (c) 2008 Firman Wandayandi <firman@php.net>
* This source file is subject to the BSD License license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.opensource.org/licenses/bsd-license.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to pear-dev@list.php.net so we can send you a copy immediately.
* @author Firman Wandayandi <firman@php.net>
* @copyright Copyright (c) 2008 Firman Wandayandi <firman@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php
* @version $Id: Utils.php,v 1.1 2008/05/26 05:03:59 firman Exp $
* @since File available since Release 1.0.0RC1
* Image tools utilities class.
* @author Firman Wandayandi <firman@php.net>
* @copyright Copyright (c) 2008 Firman Wandayandi <firman@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php
* @version Release: 1.0.0RC1
* @since Class available since Release 1.0.0RC1
* Convert various color format to RGBA array.
* @param mixed $color Color value (array, string or integer)
* @return array|FALSEAn RGBA array or FALSE on failure
if (isset ($color['r']) && isset ($color['g']) && isset ($color['b'])) {
$color['a'] = isset ($color['a']) ? $color['a'] : 0;
} else if (isset ($color[0 ]) && isset ($color[1 ]) && isset ($color[2 ])) {
$color[3 ] = isset ($color[3 ]) ? $color[3 ] : 0;
$regex = '/^[#|]?([a-f0-9]{2})?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/i';
'a' => !empty ($matches[1 ]) ? hexdec($matches[1 ]) : 0
'r' => ($color >> 16 ) & 0xff ,
'g' => ($color >> 8 ) & 0xff ,
'b' => ($color >> 0 ) & 0xff ,
'a' => ($color >> 24 ) & 0xff
* Get the loaded GD version.
if (preg_match('/\((.+)\)/', $info['GD Version'], $matches)) {
// {{{ compareGDVersion()
* Compare the "PHP-standardized" version number string with the
* @param string $operator
Documentation generated on Mon, 26 May 2008 06:30:15 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|