public static function imagickcolortorgbhex(\ImagickPixel $color) { preg_match('#rgb\\(([0-9\\.]*?)%,([0-9\\.]*?)%,([0-9\\.]*?)%\\)#', $color->getcolorasstring(), $matches); list(, $r, $g, $b) = $matches; return dechex(255 * $r / 100) . dechex(255 * $g / 100) . dechex(255 * $b / 100); }