6 public function setConfig(Config $config)
8 $this->config = $config;
11 public function getImage(Options $options)
13 $name = $this->getFilename($options);
14 $img = new Image($name);
15 $img->setConfig($this->config);
16 if (!$this->isAvailable($img, $options)) {
17 $this->render($img, $options);
22 public function getFilename(Options $options)
24 $optValues = $options->values;
25 unset($optValues['smaxage']);
26 unset($optValues['atimestamp']);
27 unset($optValues['asignature']);
28 unset($optValues['atoken']);
30 return parse_url($optValues['url'], PHP_URL_HOST)
31 . '-' . md5(\serialize($optValues))
32 . '.' . $optValues['sformat'];
36 * Check if the image is available locally.
38 * @return boolean True if we have it and it's within the cache lifetime,
39 * false if the cache expired or the screenshot does not
42 public function isAvailable(Image $img, Options $options)
44 $path = $img->getPath();
45 if (!file_exists($path)) {
49 if (filemtime($path) < time() - $options->values['smaxage']) {
56 protected function render(Image $img, Options $options)
58 $adapter = new Adapter_Cutycapt();
59 $adapter->render($img, $options);