public function __construct($options, $forceGd = false)
{
if (!isset($options['filename'])) {
throw new Exception('Error: You must pass a filename in the $options parameter.');
}
if (isset($options['width']) && isset($options['height']) && is_numeric($options['width']) && is_numeric($options['height'])) {
$this->width = $options['width'];
$this->height = $options['height'];
} else {
throw new Exception('Error: You must either pass a valid width and height or a valid image in the $options parameter.');
}
if (isset($options['background']) && is_array($options['background']) && count($options['background']) == 3) {
$background = new Rgb($options['background'][0], $options['background'][1], $options['background'][2]);
} else {
$background = null;
}
$this->fontColor = new Rgb(0, 0, 0);
$this->axisColor = new Rgb(0, 0, 0);
$this->showXColor = new Rgb(200, 200, 200);
$this->showYColor = new Rgb(200, 200, 200);
if (stripos($options['filename'], '.pdf') !== false) {
$this->adapter = new Pdf($options['filename'], null, $this->width, $this->height);
} else {
if (stripos($options['filename'], '.svg') !== false) {
$class = '\\Pop\\Image\\Svg';
} else {
if ($forceGd || !\Pop\Image\Imagick::isInstalled()) {
$class = '\\Pop\\Image\\Gd';
} else {
$class = '\\Pop\\Image\\Imagick';
}
}
$this->adapter = new $class($options['filename'], $this->width, $this->height, $background);
}
}