9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/phancap.htm
17 * Image meta data and methods to get info about the file
21 * @author Christian Weiske <cweiske@cweiske.de>
22 * @copyright 2014 Christian Weiske
23 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
24 * @version Release: @package_version@
25 * @link http://cweiske.de/phancap.htm
31 * Description for protected
37 * Description for public
46 * @param string $name Image file name
48 public function __construct($name)
54 * Get the expiration date for the image, depending on
55 * the maximum age the user requested.
57 * @param Options $options Image rendering options
59 * @return integer Unix timestamp
61 public function getExpiryDate(Options $options)
63 $mtime = filemtime($this->getPath());
65 return $mtime + $options->values['smaxage'];
69 * Get the MIME type for the file
71 * @return string MIME type string ("image/png")
73 public function getMimeType()
75 $ext = substr($this->name, -4);
78 } else if ($ext == '.png') {
80 } else if ($ext == '.pdf') {
81 return 'application/pdf';
83 return 'application/octet-stream';
87 * Get the full path to the cached image on disk
89 * @return string Full path to image
91 public function getPath()
93 return $this->config->cacheDir . $this->name;
97 * Get the public URL for the image
99 * @return string Public image URL
101 public function getUrl()
103 return $this->config->cacheDirUrl . $this->name;
107 * Set phancap configuration
109 * @param Config $config Phancap configuration
113 public function setConfig(Config $config)
115 $this->config = $config;