Returns a URL for the Google Image Chart

@param DataTable $data (labels are keys... if associative array)
@param integer $width
@param integer $height
@param array $color
@param string $title
@return string the Google Image Chart URL of the PieChart
185809
public function getUrl(DataTable $data, $width, $height, $title = null, $params = array(), $rawParams = array()) {
        
        $title      = isset($title) ? $title: null;
        $titleSize  = isset($params['titleSize']) ? $params['titleSize']: null;
        $titleColor  = isset($params['titleColor']) ? $params['titleColor']: $this->options['titleColor'];
        $withLabels = isset($params['withLabels']) ? $params['withLabels']: $this->options['withLabels'];
        $withLegend = isset($params['withLegend']) ? $params['withLegend']: $this->options['withLegend'];
        $transparent = isset($params['transparent']) ? $params['transparent']: $this->options['transparent'];
        $backgroundFillColor = isset($params['backgroundFillColor']) ? $params['backgroundFillColor']: null;
        $color = isset($params['color']) ? $params['color']: null;
        
        if (is_array($color)) {
            $color = implode('|', $color);
        } else {
            $color = $color? $color: null;
        }
        
        $labels = null;
        if ($withLabels) {
            $labels = implode('|', $data->getLabels());
        }
        //still no legend but should have one?  Take the default one...
        $legendString = $this->getLegendParamValue($data);
        
        $dataString = $this->getValueParamValue($data);
        
        //backgroundFill
        if (!is_null($backgroundFillColor)) {
            $chf = 'bg';
            if ($transparent) {
                $chf = 'a';
            }
            $chf = $chf . ',s,' . $backgroundFillColor;
        }
        $params = array(
            'chd' => $dataString,
            'cht'  => static::CHART_TYPE,
            'chs'  => $width . 'x' . $height,
            'chco' => $color,
            'chtt' => $title,
            'chts' => $titleColor . ',' . $titleSize,
            'chl'  => isset($labels)? $labels : null,
            'chdl' => isset($legendString)? $legendString : null,
            'chf'  => isset($chf)? $chf : null,
        );
        
        $params = array_merge($params, $rawParams);
        
        return self::BuildUrl($params);
    }
442982
public function ThumbnailURL($width, $height)
    {
        $object = $this->getObjectLatestVersion();
        if ($object instanceof Thumbnail) {
            return $object->ThumbnailURL($width, $height);
        }
        return null;
    }
1312927
public function displayImage($string, $size = 64, $color = null, $backgroundColor = null)
    {
        $imageData = $this->getImageData($string, $size, $color, $backgroundColor);

        return Response::make($imageData, 200, ['Content-Type' => 'image/png']);
    }
881119
private function urlPlaceholder($width, $height, $text, $backgroundColor, $textColor, $textSize, $random, array
    $options)
    {
        if ($random) {
            $backgroundColor = $this->getRandomColor();
        }

        $src = 'https://placeholdit.imgix.net/~text?txtsize=' . $textSize . '&bg=' . str_replace('#', '',
                $backgroundColor) . '&txtclr=' . str_replace('#', '', $textColor) . '&txt=' . $text . '&w=' . $width . '&h=' . $height;

        if (!$this->options['placeholder']['cache']) {
            return Html::img($src, $options);
        }

        $cacheFileName = md5($width . $height . $text . $backgroundColor . $textColor . $textSize);
        $cacheFileExt = '.jpg';
        $cacheFileDir = '/' . substr($cacheFileName, 0, 2);
        $cacheFilePath = Yii::getAlias($this->cachePath) . $cacheFileDir;
        $cacheFile = $cacheFilePath . '/' . $cacheFileName . $cacheFileExt;
        $cacheUrl = str_replace('\\', '/', preg_replace('/^@[a-z]+/', '', $this->cachePath) . $cacheFileDir . '/'
            . $cacheFileName . $cacheFileExt);

        if (file_exists($cacheFile)) {
            if ($this->cacheExpire !== 0 && (time() - filemtime($cacheFile)) > $this->cacheExpire) {
                unlink($cacheFile);
            } else {
                return Html::img($cacheUrl, $options);
            }
        }

        if (!is_dir($cacheFilePath)) {
            mkdir($cacheFilePath, 0755, true);
        }

        $image = file_get_contents($src);

        file_put_contents($cacheFile, $image);

        return Html::img($cacheUrl, $options);
    }
1082670
public function getURL($width = '', $height = '')
    {
        $uri = $this->getName();
        if ($height && $width) {
            return Settings::get('image_url').$width.'/'.$height.'/'.$uri;
        } elseif ($width) {
            return Settings::get('image_url').$width.'/'.$uri;
        } else { // original image
            return Settings::get('image_url').$uri;
        }
    }
1270390
public static function materialAvatar(string $name, float $dimensions = 100, string $color = null) : string
    {
        $letter = mb_substr($name, 0, 1, 'utf-8');

        if (!$color) {
            $color = static::materialColors()->random();
        } else {
            $color = static::materialColors($color);
        }

        $text_position = bcdiv($dimensions, 2, 2);
        $cache_key = "support__material_avatar:{$letter}_{$dimensions}_{$color}";

        if (!Cache::has($cache_key)) {
            $image = Image::canvas($dimensions, $dimensions, $color)
                ->text($letter, $text_position, $text_position, function ($font) use ($dimensions) {
                    $font->file(__DIR__ . '/../Assets/fonts/Roboto-Light.ttf')
                        ->size(bcdiv($dimensions, 1.75, 2))
                        ->color('#ffffff')
                        ->align('center')
                        ->valign('middle');
                })
                ->encode('data-url');
            Cache::put($cache_key, $image);
            return $image;
        }

        return Cache::get($cache_key);
    }
985349
public function getQueryUrl()
    {

        $uri = $this->_defaultFeedUri;

        if ($this->_spreadsheetKey != null) {
            $uri .= '/'.$this->_spreadsheetKey;
        } else {
            require_once 'Zend/Gdata/App/Exception.php';
            throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for list queries.');
        }

        if ($this->_worksheetId != null) {
            $uri .= '/'.$this->_worksheetId;
        } else {
            require_once 'Zend/Gdata/App/Exception.php';
            throw new Zend_Gdata_App_Exception('A worksheet id must be provided for list queries.');
        }

        if ($this->_visibility != null) {
            $uri .= '/'.$this->_visibility;
        } else {
            require_once 'Zend/Gdata/App/Exception.php';
            throw new Zend_Gdata_App_Exception('A visibility must be provided for list queries.');
        }

        if ($this->_projection != null) {
            $uri .= '/'.$this->_projection;
        } else {
            require_once 'Zend/Gdata/App/Exception.php';
            throw new Zend_Gdata_App_Exception('A projection must be provided for list queries.');
        }

        if ($this->_rowId != null) {
            $uri .= '/'.$this->_rowId;
        }

        $uri .= $this->getQueryString();
        return $uri;
    }
925438
public function ThumbnailURL($width, $height)
    {
        $thumbnail = $this->Thumbnail($width, $height);
        if ($thumbnail) {
            return $thumbnail->getURL();
        }
        return $this->getIcon();
    }
479769
static function createImage( $width, $height, &$useTruecolor )
    {
        if ( $useTruecolor === null )
        {
//             print( "has GD2='" . eZImageInterface::hasGD2() . "'<br/>" );
            $useTruecolor = eZImageInterface::hasGD2();
        }
        if ( $useTruecolor and
             !function_exists( 'ImageCreateTrueColor' ) )
        {
            eZDebug::writeWarning( 'Function ImageCreateTrueColor does not exist, cannot create true color images', __METHOD__ );
            $useTruecolor = false;
        }
        if ( $useTruecolor )
            $imageObject = ImageCreateTrueColor( $width, $height );
        else
            $imageObject = ImageCreate( $width, $height );
        return $imageObject;
    }
1006726
public static function url($relative, $width, $height)
    {

        if (preg_match('/^https?:\/\//i', $relative)) {

            return static::fromUrl($relative, $width, $height);

        } elseif (strlen(parse_url($relative, PHP_URL_QUERY)) > 0) {

            $relative = static::$config['base_uri'] . $relative;

            return static::fromUrl($relative, $width, $height);
        }

        return static::fromFile($relative, $width, $height);
    }
236353
function ImageSVG($data)
	{
		$data = preg_replace('/^.*?<svg([> ])/is', '<svg\\1', $data); // mPDF 5.7.4
		$data = preg_replace('/<!--.*?-->/is', '', $data); // mPDF 5.7.4

		// Converts < to &lt; when not a tag
		$data = preg_replace('/<([^!?\/a-zA-Z_:])/i', '&lt;\\1', $data); // mPDF 5.7.4

		if ($this->mpdf->svgAutoFont) {
			$data = $this->markScriptToLang($data);
		}

		$this->svg_info = [];
		$last_gradid = ''; // mPDF 6
		$last_svg_fontid = ''; // mPDF 6
		$last_svg_fontdefw = ''; // mPDF 6
		$last_svg_fontstyle = ''; // mPDF 6

		if (preg_match('/<!ENTITY/si', $data)) {
			// Get User-defined entities
			preg_match_all('/<!ENTITY\s+([a-z]+)\s+\"(.*?)\">/si', $data, $ent);
			// Replace entities
			for ($i = 0; $i < count($ent[0]); $i++) {
				$data = preg_replace('/&' . preg_quote($ent[1][$i], '/') . ';/is', $ent[2][$i], $data);
			}
		}

		if (preg_match('/xlink:href\s*=/si', $data)) {

			// GRADIENTS
			// Get links
			preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href\s*=\s*["\']#(.*?)["\'](.*?)\/>/si', $data, $links);
			if (count($links[0])) {
				$links[5] = [];
			}

			// Delete links from data - keeping in $links
			for ($i = 0; $i < count($links[0]); $i++) {
				$links[5][$i] = 'tmpLink' . random_int(100000, 9999999);
				$data = preg_replace('/' . preg_quote($links[0][$i], '/') . '/is', '<MYLINKS' . $links[5][$i] . '>', $data);
			}

			// Get targets
			preg_match_all('/<(linearGradient|radialgradient)([^>]*)id\s*=\s*["\'](.*?)["\'](.*?)>(.*?)<\/(linearGradient|radialgradient)>/si', $data, $m);
			$targets = [];
			$stops = [];

			// keeping in $targets
			for ($i = 0; $i < count($m[0]); $i++) {
				$stops[$m[3][$i]] = $m[5][$i];
			}

			// Add back links this time as targets (gradients)
			for ($i = 0; $i < count($links[0]); $i++) {
				$def = $links[1][$i] . ' ' . $links[4][$i] . '>' . $stops[$links[3][$i]] . '</' . $links[2][$i] . '>';
				$data = preg_replace('/<MYLINKS' . $links[5][$i] . '>/is', $def, $data);
			}

			// mPDF 5.7.4
			// <TREF>
			preg_match_all('/<tref ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si', $data, $links);
			for ($i = 0; $i < count($links[0]); $i++) {
				// Get the item to use from defs
				$insert = '';
				if (preg_match('/<text [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\'][^>]*>(.*?)<\/text>/si', $data, $m)) {
					$insert = $m[1];
				}
				if ($insert) {
					$data = preg_replace('/' . preg_quote($links[0][$i], '/') . '/is', $insert, $data);
				}
			}

			// mPDF 5.7.2
			// <USE>
			preg_match_all('/<use( [^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si', $data, $links);
			for ($i = 0; $i < count($links[0]); $i++) {
				// Get the item to use from defs
				$insert = '';
				if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\'][^>]*\/>/si', $data, $m)) {
					$insert = $m[0];
				}
				if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\']/si', $data, $m)) {
					if (preg_match('/<' . $m[1] . '[^>]*id\s*=\s*["\']' . $links[2][$i] . '["\'][^>]*>.*?<\/' . $m[1] . '>/si', $data, $m)) {
						$insert = $m[0];
					}
				}

				if ($insert) {
					$inners = $links[1][$i] . ' ' . $links[3][$i];

					// Change x,y coords to translate()
					if (preg_match('/\sy\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {
						$y = $m[1];
					} else {
						$y = 0;
					}

					if (preg_match('/\sx\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {
						$x = $m[1];
					} else {
						$x = 0;
					}

					if ($x || $y) {

						$inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', $inners);
						if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {

							if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) {
								$transform = $m[1]; // transform="...."
								$x += $mm[1];
								$y += $mm[2];
								$transform = preg_replace('/' . preg_quote($mm[0], '/') . '/', '', $transform);
								$transform = 'transform="' . $transform . ' translate(' . $x . ', ' . $y . ')"';
								$inners = preg_replace('/' . preg_quote($m[0], '/') . '/is', $transform, $inners);
							} else {
								$inners = preg_replace('/' . preg_quote($m[0], '/') . '/is', 'transform="' . $m[1] . ' translate(' . $x . ', ' . $y . ')"', $inners);
							}

						} else {
							$inners .= ' transform="translate(' . $x . ', ' . $y . ')"';
						}
					}
				}

				$replacement = '<g ' . $inners . '>' . $insert . '</g>';
				$data = preg_replace('/' . preg_quote($links[0][$i], '/') . '/is', $replacement, $data);
			}

			preg_match_all('/<use( [^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)>\s*<\/use>/si', $data, $links);
			for ($i = 0; $i < count($links[0]); $i++) {

				// Get the item to use from defs
				$insert = '';
				if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\'][^>]*\/>/si', $data, $m)) {
					$insert = $m[0];
				}

				if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\']/si', $data, $m)) {
					if (preg_match('/<' . $m[1] . '[^>]*id\s*=\s*["\']' . $links[2][$i] . '["\'][^>]*>.*?<\/' . $m[1] . '>/si', $data, $m)) {
						$insert = $m[0];
					}
				}

				if ($insert) {
					$inners = $links[1][$i] . ' ' . $links[3][$i];

					// Change x,y coords to translate()
					if (preg_match('/\sy\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {
						$y = $m[1];
					} else {
						$y = 0;
					}

					if (preg_match('/\sx\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {
						$x = $m[1];
					} else {
						$x = 0;
					}

					if ($x || $y) {
						$inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', $inners);
						if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {
							if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) {
								$transform = $m[1]; // transform="...."
								$x += $mm[1];
								$y += $mm[2];
								$transform = preg_replace('/' . preg_quote($mm[0], '/') . '/', '', $transform);
								$transform = 'transform="' . $transform . ' translate(' . $x . ', ' . $y . ')"';
								$inners = preg_replace('/' . preg_quote($m[0], '/') . '/is', $transform, $inners);
							} else {
								$inners = preg_replace('/' . preg_quote($m[0], '/') . '/is', 'transform="' . $m[1] . ' translate(' . $x . ', ' . $y . ')"', $inners);
							}
						} else {
							$inners .= ' transform="translate(' . $x . ', ' . $y . ')"';
						}
					}

					$replacement = '<g ' . $inners . '>' . $insert . '</g>';
					$data = preg_replace('/' . preg_quote($links[0][$i], '/') . '/is', $replacement, $data);
				}
			}
		}

		// Removes <pattern>
		$data = preg_replace('/<pattern.*?<\/pattern>/is', '', $data);

		// Removes <marker>
		$data = preg_replace('/<marker.*?<\/marker>/is', '', $data);

		$this->svg_info['data'] = $data;
		$this->svg_string = '';

		$svg2pdf_xml = '';

		// Don't output stuff inside <defs>
		$this->inDefs = false;

		$svg2pdf_xml_parser = xml_parser_create("utf-8");

		xml_parser_set_option($svg2pdf_xml_parser, XML_OPTION_CASE_FOLDING, false);

		xml_set_element_handler(
			$svg2pdf_xml_parser,
			[$this, 'xml_svg2pdf_start'],
			[$this, 'xml_svg2pdf_end']
		);

		xml_set_character_data_handler(
			$svg2pdf_xml_parser,
			[$this, 'characterData']
		);

		xml_parse($svg2pdf_xml_parser, $data);

		if ($this->svg_error) {
			return false;
		} else {
			return [
				'x' => $this->svg_info['x'] * $this->kp,
				'y' => -$this->svg_info['y'] * $this->kp,
				'w' => $this->svg_info['w'] * $this->kp,
				'h' => -$this->svg_info['h'] * $this->kp,
				'data' => $this->svg_string,
			];
		}
	}
1108664
public function image($width = null, $height = null, array $options = [])
    {
        $url = $this->getImageUrlOrDefault();

        if (pathinfo($url, PATHINFO_EXTENSION) === 'svg') {
            return $url;
        }

        return url(Croppa::url($url, $width, $height, $options));
    }
1181441
public function chartMedia(
        array $media,
        string $color_from = null,
        string $color_to = null
    ): string {
        $chart_color1 = (string) $this->theme->parameter('distribution-chart-no-values');
        $chart_color2 = (string) $this->theme->parameter('distribution-chart-high-values');
        $color_from   = $color_from ?? $chart_color1;
        $color_to     = $color_to   ?? $chart_color2;

        $data = [
            [
                I18N::translate('Type'),
                I18N::translate('Total')
            ],
        ];

        foreach ($media as $type => $count) {
            $data[] = [
                GedcomTag::getFileFormTypeValue($type),
                $count
            ];
        }

        $colors = $this->color_service->interpolateRgb($color_from, $color_to, count($data) - 1);

        return view(
            'statistics/other/charts/pie',
            [
                'title'  => null,
                'data'   => $data,
                'colors' => $colors,
            ]
        );
    }
142886
public function getDiv($width = 500, $height = 400)
	{
	    $styleOptions = array('width'    =>    $width.'px', 
	                          'height'   =>    $height.'px'
	                         );
	    
	    return ChartRenderer::render( $this, $styleOptions );
	}
1219475
public function getSafeRedirectUrl($default, $data = null, $key = 'redirect') {
		$redirectUrl = $data ?: ($this->Controller->getRequest()->getData($key) ?: $this->Controller->getRequest()->getQuery($key));
		if ($redirectUrl && (mb_substr($redirectUrl, 0, 1) !== '/' || mb_substr($redirectUrl, 0, 2) === '//')) {
			$redirectUrl = null;
		}

		return $redirectUrl ?: $default;
	}
771133
public static function load($color, $resource)
    {
        if ($color === 'transparent') {

            return imagecolorallocatealpha($resource, 0, 0, 0, 127);
        }

        $gdpixel = new GDPixel($color);

        return imagecolorallocate($resource, $gdpixel->channelR, $gdpixel->channelG, $gdpixel->channelB);
    }
363852
public function table(array $data, $title = null, $cellPadding = 1) {
		if ($cellPadding < 0) {
			$cellPadding = 0;
		}
		
		// Dimensions calculation
		$columnsNumber = 0;
		$columnsWidths = [];
		
		foreach ($data as $row) {
			$columnsCount = count($row);
			
			if ($columnsCount > $columnsNumber) {
				$columnsNumber = $columnsCount;
			}
			
			foreach (array_values($row) as $key => $col) {
				$length = $this->strlen($col);
				
				if (isset($columnsWidths[$key])) {
					if ($length > $columnsWidths[$key]) {
						$columnsWidths[$key] = $length;
					}
				} else {
					$columnsWidths[$key] = $length;
				}
			}
		}
		
		$content = '';
		
		if ($title !== null) {
			$content .= $this->renderTitle($title, $cellPadding, $columnsWidths);
			$content .= PHP_EOL;
		}
		
		$content .= $this->renderTable($data, $cellPadding, $columnsWidths);
		
		return $content;
	}