[
  {
    "path": ".gitignore",
    "content": "# Cache files\ncache/*\n\n# Test\ncoverage/\ncoverage.clover\n\n# Composer\ncomposer.lock\nvendor\n\n# Build and test\nbuild/\n\n# Mac OS\n.DS_Store\n"
  },
  {
    "path": ".scrutinizer.yml",
    "content": "imports:\n    - php\n\nfilter:\n    excluded_paths:\n        - test/\n        - webroot/check*\n        - webroot/imgd.php\n        - webroot/imgp.php\n        - webroot/imgs.php\n        - webroot/test/\n\nchecks:\n    php:\n        code_rating: true\n        duplication: true\n\ntools:\n   # Copy/Paste Detector                              \n   php_cpd: true\n\n   # Metrics\n   php_pdepend: true\n\n   # Some Metrics + Bug Detection/Auto-Fixes          \n   php_analyzer: true\n\n   php_code_sniffer:\n       config:\n           standard: \"PSR2\"\n\n   php_sim:\n       min_mass: 16 # Defaults to 16                  \n\n   php_mess_detector:\n       #config:                                       \n       #    ruleset: ../your-phpmd-ruleset/ruleset.xml\n\nbuild:\n    tests:\n        override:\n            -\n                command: 'phpunit'\n                coverage:\n                    file: 'coverage.clover'\n                    format: 'php-clover'\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: php\n\nphp:\n    - 5.4\n    - 5.5\n    - 5.6\n    - hhvm\n    - nightly\n    - \"7.0\"\n\n\n\nsudo: false\n\n\n\ngit:\n    submodules: false\n\n\n\naddons:\n    apt:\n        packages:\n            #- php-codesniffer\n            #- phpmd\n            #- shellcheck\n\n\nmatrix:\n    allow_failures:\n        - php: hhvm\n        - php: nightly\n\n\n\nbefore_script:\n\n    # Create a build directory for output\n    # Store all files in your own bin\n    #- install --directory build/bin\n    #- export PATH=$PATH:$PWD/build/bin/\n\n\n    # Install validation tools\n    #- npm install -g htmlhint csslint jshint jscs jsonlint js-yaml html-minifier@0.8.0 clean-css uglify-js\n    \n    # Install phpcs\n    #- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar\n    #- install --mode 0755 phpcs.phar $PWD/build/bin/phpcs\n\n    # Install phpmd\n    #- wget -c http://static.phpmd.org/php/latest/phpmd.phar\n    #- install --mode 0755 phpmd.phar $PWD/build/bin/phpmd\n\n\n\nscript:\n    # Check versions of validation tools\n    #- node --version\n    #- npm --version\n    \n    #- htmlhint --version\n    #- csslint --version\n    #- jscs --version\n    #- jshint --version\n    #- phpcs --version\n    #- phpmd --version\n    #- jsonlint --version\n    #- js-yaml --version\n    #- shellcheck --version\n    \n    #- html-minifier --version\n    #- cleancss --version\n    #- uglifyjs --version\n    \n    # Run validation & publish\n    #- make phpunit\n    - composer validate\n    - phpunit\n    #- make phpcs\n\n\n\nnotifications:\n    irc: \"irc.freenode.org#dbwebb\"\n\n    webhooks:\n        urls:\n          - https://webhooks.gitter.im/e/a89832db4f939e85ba97\n        on_success: change  # options: [always|never|change] default: always\n        on_failure: always  # options: [always|never|change] default: always\n        on_start: never     # options: [always|never|change] default: always\n"
  },
  {
    "path": "CAsciiArt.php",
    "content": "<?php\n/**\n * Create an ASCII version of an image.\n *\n */\nclass CAsciiArt\n{\n    /**\n     * Character set to use.\n     */\n    private $characterSet = array(\n        'one' => \"#0XT|:,.' \",\n        'two' => \"@%#*+=-:. \",\n        'three' => \"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\\\"^`'. \"\n    );\n\n\n\n    /**\n     * Current character set.\n     */\n    private $characters = null;\n\n\n\n    /**\n     * Length of current character set.\n     */\n    private $charCount = null;\n\n\n\n    /**\n     * Scale of the area to swap to a character.\n     */\n    private $scale = null;\n\n\n\n    /**\n     * Strategy to calculate luminance.\n     */\n    private $luminanceStrategy = null;\n\n\n\n    /**\n     * Constructor which sets default options.\n     */\n    public function __construct()\n    {\n        $this->setOptions();\n    }\n\n\n\n    /**\n     * Add a custom character set.\n     *\n     * @param string $key   for the character set.\n     * @param string $value for the character set.\n     *\n     * @return $this\n     */\n    public function addCharacterSet($key, $value)\n    {\n        $this->characterSet[$key] = $value;\n        return $this;\n    }\n\n\n\n    /**\n     * Set options for processing, defaults are available.\n     *\n     * @param array $options to use as default settings.\n     *\n     * @return $this\n     */\n    public function setOptions($options = array())\n    {\n        $default = array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        );\n        $default = array_merge($default, $options);\n        \n        if (!is_null($default['customCharacterSet'])) {\n            $this->addCharacterSet('custom', $default['customCharacterSet']);\n            $default['characterSet'] = 'custom';\n        }\n        \n        $this->scale = $default['scale'];\n        $this->characters = $this->characterSet[$default['characterSet']];\n        $this->charCount = strlen($this->characters);\n        $this->luminanceStrategy = $default['luminanceStrategy'];\n        \n        return $this;\n    }\n\n\n\n    /**\n     * Create an Ascii image from an image file.\n     *\n     * @param string $filename of the image to use.\n     *\n     * @return string $ascii with the ASCII image.\n     */\n    public function createFromFile($filename)\n    {\n        $img = imagecreatefromstring(file_get_contents($filename));\n        list($width, $height) = getimagesize($filename);\n\n        $ascii = null;\n        $incY = $this->scale;\n        $incX = $this->scale / 2;\n        \n        for ($y = 0; $y < $height - 1; $y += $incY) {\n            for ($x = 0; $x < $width - 1; $x += $incX) {\n                $toX = min($x + $this->scale / 2, $width - 1);\n                $toY = min($y + $this->scale, $height - 1);\n                $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);\n                $ascii .= $this->luminance2character($luminance);\n            }\n            $ascii .= PHP_EOL;\n        }\n\n        return $ascii;\n    }\n\n\n\n    /**\n     * Get the luminance from a region of an image using average color value.\n     *\n     * @param string  $img the image.\n     * @param integer $x1  the area to get pixels from.\n     * @param integer $y1  the area to get pixels from.\n     * @param integer $x2  the area to get pixels from.\n     * @param integer $y2  the area to get pixels from.\n     *\n     * @return integer $luminance with a value between 0 and 100.\n     */\n    public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2)\n    {\n        $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1);\n        $luminance = 0;\n        \n        for ($x = $x1; $x <= $x2; $x++) {\n            for ($y = $y1; $y <= $y2; $y++) {\n                $rgb   = imagecolorat($img, $x, $y);\n                $red   = (($rgb >> 16) & 0xFF);\n                $green = (($rgb >> 8) & 0xFF);\n                $blue  = ($rgb & 0xFF);\n                $luminance += $this->getLuminance($red, $green, $blue);\n            }\n        }\n        \n        return $luminance / $numPixels;\n    }\n\n\n\n    /**\n     * Calculate luminance value with different strategies.\n     *\n     * @param integer $red   The color red.\n     * @param integer $green The color green.\n     * @param integer $blue  The color blue.\n     *\n     * @return float $luminance with a value between 0 and 1.\n     */\n    public function getLuminance($red, $green, $blue)\n    {\n        switch ($this->luminanceStrategy) {\n            case 1:\n                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;\n                break;\n            case 2:\n                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;\n                break;\n            case 3:\n                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;\n                break;\n            case 0:\n            default:\n                $luminance = ($red + $green + $blue) / (255 * 3);\n        }\n\n        return $luminance;\n    }\n\n\n\n    /**\n     * Translate the luminance value to a character.\n     *\n     * @param string $position a value between 0-100 representing the\n     *                         luminance.\n     *\n     * @return string with the ascii character.\n     */\n    public function luminance2character($luminance)\n    {\n        $position = (int) round($luminance * ($this->charCount - 1));\n        $char = $this->characters[$position];\n        return $char;\n    }\n}\n"
  },
  {
    "path": "CCache.php",
    "content": "<?php\n/**\n * Deal with the cache directory and cached items.\n *\n */\nclass CCache\n{\n    /**\n     * Path to the cache directory.\n     */\n    private $path;\n\n\n\n    /**\n     * Set the path to the cache dir which must exist.\n     *\n     * @param string path to the cache dir.\n     *\n     * @throws Exception when $path is not a directory.\n     *\n     * @return $this\n     */\n    public function setDir($path)\n    {\n        if (!is_dir($path)) {\n            throw new Exception(\"Cachedir is not a directory.\");\n        }\n\n        $this->path = $path;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the path to the cache subdir and try to create it if its not there.\n     *\n     * @param string $subdir name of subdir\n     * @param array  $create default is to try to create the subdir\n     *\n     * @return string | boolean as real path to the subdir or\n     *                          false if it does not exists\n     */\n    public function getPathToSubdir($subdir, $create = true)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        if (is_dir($path)) {\n            return $path;\n        }\n\n        if ($create && defined('WINDOWS2WSL')) {\n            // Special case to solve Windows 2 WSL integration\n            $path = $this->path . \"/\" . $subdir;\n\n            if (mkdir($path)) {\n                return realpath($path);\n            }\n        }\n\n        if ($create && is_writable($this->path)) {\n            $path = $this->path . \"/\" . $subdir;\n\n            if (mkdir($path)) {\n                return realpath($path);\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Get status of the cache subdir.\n     *\n     * @param string $subdir name of subdir\n     *\n     * @return string with status\n     */\n    public function getStatusOfSubdir($subdir)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        $exists = is_dir($path);\n        $res  = $exists ? \"exists\" : \"does not exist\";\n        \n        if ($exists) {\n            $res .= is_writable($path) ? \", writable\" : \", not writable\";\n        }\n\n        return $res;\n    }\n\n\n\n    /**\n     * Remove the cache subdir.\n     *\n     * @param string $subdir name of subdir\n     *\n     * @return null | boolean true if success else false, null if no operation\n     */\n    public function removeSubdir($subdir)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        if (is_dir($path)) {\n            return rmdir($path);\n        }\n\n        return null;\n    }\n}\n"
  },
  {
    "path": "CFastTrackCache.php",
    "content": "<?php\n/**\n * Enable a fast track cache with a json representation of the image delivery.\n *\n */\nclass CFastTrackCache\n{\n    /**\n     * Cache is disabled to start with.\n     */\n    private $enabled = false;\n\n\n\n    /**\n     * Path to the cache directory.\n     */\n    private $path;\n\n\n\n    /**\n     * Filename of current cache item.\n     */\n    private $filename;\n\n\n\n    /**\n     * Container with items to store as cached item.\n     */\n    private $container;\n\n\n\n    /**\n     * Enable or disable cache.\n     *\n     * @param boolean $enable set to true to enable, false to disable\n     *\n     * @return $this\n     */\n    public function enable($enabled)\n    {\n        $this->enabled = $enabled;\n        return $this;\n    }\n\n\n\n    /**\n     * Set the path to the cache dir which must exist.\n     *\n     * @param string $path to the cache dir.\n     *\n     * @throws Exception when $path is not a directory.\n     *\n     * @return $this\n     */\n    public function setCacheDir($path)\n    {\n        if (!is_dir($path)) {\n            throw new Exception(\"Cachedir is not a directory.\");\n        }\n\n        $this->path = rtrim($path, \"/\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set the filename to store in cache, use the querystring to create that\n     * filename.\n     *\n     * @param array $clear items to clear in $_GET when creating the filename.\n     *\n     * @return string as filename created.\n     */\n    public function setFilename($clear)\n    {\n        $query = $_GET;\n\n        // Remove parts from querystring that should not be part of filename\n        foreach ($clear as $value) {\n            unset($query[$value]);\n        }\n\n        arsort($query);\n        $queryAsString = http_build_query($query);\n\n        $this->filename = md5($queryAsString);\n\n        if (CIMAGE_DEBUG) {\n            $this->container[\"query-string\"] = $queryAsString;\n        }\n\n        return $this->filename;\n    }\n\n\n\n    /**\n     * Add header items.\n     *\n     * @param string $header add this as header.\n     *\n     * @return $this\n     */\n    public function addHeader($header)\n    {\n        $this->container[\"header\"][] = $header;\n        return $this;\n    }\n\n\n\n    /**\n     * Add header items on output, these are not output when 304.\n     *\n     * @param string $header add this as header.\n     *\n     * @return $this\n     */\n    public function addHeaderOnOutput($header)\n    {\n        $this->container[\"header-output\"][] = $header;\n        return $this;\n    }\n\n\n\n    /**\n     * Set path to source image to.\n     *\n     * @param string $source path to source image file.\n     *\n     * @return $this\n     */\n    public function setSource($source)\n    {\n        $this->container[\"source\"] = $source;\n        return $this;\n    }\n\n\n\n    /**\n     * Set last modified of source image, use to check for 304.\n     *\n     * @param string $lastModified\n     *\n     * @return $this\n     */\n    public function setLastModified($lastModified)\n    {\n        $this->container[\"last-modified\"] = $lastModified;\n        return $this;\n    }\n\n\n\n    /**\n     * Get filename of cached item.\n     *\n     * @return string as filename.\n     */\n    public function getFilename()\n    {\n        return $this->path . \"/\" . $this->filename;\n    }\n\n\n\n    /**\n     * Write current item to cache.\n     *\n     * @return boolean if cache file was written.\n     */\n    public function writeToCache()\n    {\n        if (!$this->enabled) {\n            return false;\n        }\n\n        if (is_dir($this->path) && is_writable($this->path)) {\n            $filename = $this->getFilename();\n            return file_put_contents($filename, json_encode($this->container)) !== false;\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Output current item from cache, if available.\n     *\n     * @return void\n     */\n    public function output()\n    {\n        $filename = $this->getFilename();\n        if (!is_readable($filename)) {\n            return;\n        }\n\n        $item = json_decode(file_get_contents($filename), true);\n\n        if (!is_readable($item[\"source\"])) {\n            return;\n        }\n\n        foreach ($item[\"header\"] as $value) {\n            header($value);\n        }\n\n        if (isset($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"])\n            && strtotime($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"]) == $item[\"last-modified\"]) {\n            header(\"HTTP/1.0 304 Not Modified\");\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 304\");\n            }\n            exit;\n        }\n\n        foreach ($item[\"header-output\"] as $value) {\n            header($value);\n        }\n\n        if (CIMAGE_DEBUG) {\n            trace(__CLASS__ . \" 200\");\n        }\n        readfile($item[\"source\"]);\n        exit;\n    }\n}\n"
  },
  {
    "path": "CHttpGet.php",
    "content": "<?php\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CHttpGet\n{\n    private $request  = array();\n    private $response = array();\n\n\n\n    /**\n    * Constructor\n    *\n    */\n    public function __construct()\n    {\n        $this->request['header'] = array();\n    }\n\n\n\n    /**\n     * Build an encoded url.\n     *\n     * @param string $baseUrl This is the original url which will be merged.\n     * @param string $merge   Thse parts should be merged into the baseUrl,\n     *                        the format is as parse_url.\n     *\n     * @return string $url as the modified url.\n     */\n    public function buildUrl($baseUrl, $merge)\n    {\n        $parts = parse_url($baseUrl);\n        $parts = array_merge($parts, $merge);\n\n        $url  = $parts['scheme'];\n        $url .= \"://\";\n        $url .= $parts['host'];\n        $url .= isset($parts['port'])\n            ? \":\" . $parts['port']\n            : \"\" ;\n        $url .= $parts['path'];\n\n        return $url;\n    }\n\n\n\n    /**\n     * Set the url for the request.\n     *\n     * @param string $url\n     *\n     * @return $this\n     */\n    public function setUrl($url)\n    {\n        $parts = parse_url($url);\n        \n        $path = \"\";\n        if (isset($parts['path'])) {\n            $pathParts = explode('/', $parts['path']);\n            unset($pathParts[0]);\n            foreach ($pathParts as $value) {\n                $path .= \"/\" . rawurlencode($value);\n            }\n        }\n        $url = $this->buildUrl($url, array(\"path\" => $path));\n\n        $this->request['url'] = $url;\n        return $this;\n    }\n\n\n\n    /**\n     * Set custom header field for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function setHeader($field, $value)\n    {\n        $this->request['header'][] = \"$field: $value\";\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function parseHeader()\n    {\n        //$header = explode(\"\\r\\n\", rtrim($this->response['headerRaw'], \"\\r\\n\"));\n        \n        $rawHeaders = rtrim($this->response['headerRaw'], \"\\r\\n\");\n        # Handle multiple responses e.g. with redirections (proxies too)\n        $headerGroups = explode(\"\\r\\n\\r\\n\", $rawHeaders);\n        # We're only interested in the last one\n        $header = explode(\"\\r\\n\", end($headerGroups));\n\n        $output = array();\n\n        if ('HTTP' === substr($header[0], 0, 4)) {\n            list($output['version'], $output['status']) = explode(' ', $header[0]);\n            unset($header[0]);\n        }\n\n        foreach ($header as $entry) {\n            $pos = strpos($entry, ':');\n            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));\n        }\n\n        $this->response['header'] = $output;\n        return $this;\n    }\n\n\n\n    /**\n     * Perform the request.\n     *\n     * @param boolean $debug set to true to dump headers.\n     *\n     * @throws Exception when curl fails to retrieve url.\n     *\n     * @return boolean\n     */\n    public function doGet($debug = false)\n    {\n        $options = array(\n            CURLOPT_URL             => $this->request['url'],\n            CURLOPT_HEADER          => 1,\n            CURLOPT_HTTPHEADER      => $this->request['header'],\n            CURLOPT_AUTOREFERER     => true,\n            CURLOPT_RETURNTRANSFER  => true,\n            CURLINFO_HEADER_OUT     => $debug,\n            CURLOPT_CONNECTTIMEOUT  => 5,\n            CURLOPT_TIMEOUT         => 5,\n            CURLOPT_FOLLOWLOCATION  => true,\n            CURLOPT_MAXREDIRS       => 2,\n        );\n\n        $ch = curl_init();\n        curl_setopt_array($ch, $options);\n        $response = curl_exec($ch);\n\n        if (!$response) {\n            throw new Exception(\"Failed retrieving url, details follows: \" . curl_error($ch));\n        }\n\n        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n        $this->response['headerRaw'] = substr($response, 0, $headerSize);\n        $this->response['body']      = substr($response, $headerSize);\n\n        $this->parseHeader();\n\n        if ($debug) {\n            $info = curl_getinfo($ch);\n            echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\";\n            echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\";\n            echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\";\n        }\n\n        curl_close($ch);\n        return true;\n    }\n\n\n\n    /**\n     * Get HTTP code of response.\n     *\n     * @return integer as HTTP status code or null if not available.\n     */\n    public function getStatus()\n    {\n        return isset($this->response['header']['status'])\n            ? (int) $this->response['header']['status']\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @return int as timestamp.\n     */\n    public function getLastModified()\n    {\n        return isset($this->response['header']['Last-Modified'])\n            ? strtotime($this->response['header']['Last-Modified'])\n            : null;\n    }\n\n\n\n    /**\n     * Get content type.\n     *\n     * @return string as the content type or null if not existing or invalid.\n     */\n    public function getContentType()\n    {\n        $type = isset($this->response['header']['Content-Type'])\n            ? $this->response['header']['Content-Type']\n            : '';\n\n        return preg_match('#[a-z]+/[a-z]+#', $type)\n            ? $type\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @param mixed $default as default value (int seconds) if date is\n     *                       missing in response header.\n     *\n     * @return int as timestamp or $default if Date is missing in\n     *             response header.\n     */\n    public function getDate($default = false)\n    {\n        return isset($this->response['header']['Date'])\n            ? strtotime($this->response['header']['Date'])\n            : $default;\n    }\n\n\n\n    /**\n     * Get max age of cachable item.\n     *\n     * @param mixed $default as default value if date is missing in response\n     *                       header.\n     *\n     * @return int as timestamp or false if not available.\n     */\n    public function getMaxAge($default = false)\n    {\n        $cacheControl = isset($this->response['header']['Cache-Control'])\n            ? $this->response['header']['Cache-Control']\n            : null;\n\n        $maxAge = null;\n        if ($cacheControl) {\n            // max-age=2592000\n            $part = explode('=', $cacheControl);\n            $maxAge = ($part[0] == \"max-age\")\n                ? (int) $part[1]\n                : null;\n        }\n\n        if ($maxAge) {\n            return $maxAge;\n        }\n\n        $expire = isset($this->response['header']['Expires'])\n            ? strtotime($this->response['header']['Expires'])\n            : null;\n\n        return $expire ? $expire : $default;\n    }\n\n\n\n    /**\n     * Get body of response.\n     *\n     * @return string as body.\n     */\n    public function getBody()\n    {\n        return $this->response['body'];\n    }\n}\n"
  },
  {
    "path": "CImage.php",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n */\n#[AllowDynamicProperties]\nclass CImage\n{\n\n    /**\n     * Constants type of PNG image\n     */\n    const PNG_GREYSCALE         = 0;\n    const PNG_RGB               = 2;\n    const PNG_RGB_PALETTE       = 3;\n    const PNG_GREYSCALE_ALPHA   = 4;\n    const PNG_RGB_ALPHA         = 6;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const JPEG_QUALITY_DEFAULT = 60;\n\n\n\n    /**\n     * Quality level for JPEG images.\n     */\n    private $quality;\n\n\n\n    /**\n     * Is the quality level set from external use (true) or is it default (false)?\n     */\n    private $useQuality = false;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const PNG_COMPRESSION_DEFAULT = -1;\n\n\n\n    /**\n     * Compression level for PNG images.\n     */\n    private $compress;\n\n\n\n    /**\n     * Is the compress level set from external use (true) or is it default (false)?\n     */\n    private $useCompress = false;\n\n\n\n\n    /**\n     * Add HTTP headers for outputing image.\n     */\n    private $HTTPHeader = array();\n\n\n\n    /**\n     * Default background color, red, green, blue, alpha.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    /*\n    const BACKGROUND_COLOR = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );*/\n\n\n\n    /**\n     * Default background color to use.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    //private $bgColorDefault = self::BACKGROUND_COLOR;\n    private $bgColorDefault = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );\n\n\n    /**\n     * Background color to use, specified as part of options.\n     */\n    private $bgColor;\n\n\n\n    /**\n     * Where to save the target file.\n     */\n    private $saveFolder;\n\n\n\n    /**\n     * The working image object.\n     */\n    private $image;\n\n\n\n    /**\n     * Image filename, may include subdirectory, relative from $imageFolder\n     */\n    private $imageSrc;\n\n\n\n    /**\n     * Actual path to the image, $imageFolder . '/' . $imageSrc\n     */\n    private $pathToImage;\n\n\n\n    /**\n     * File type for source image, as provided by getimagesize()\n     */\n    private $fileType;\n\n\n\n    /**\n     * File extension to use when saving image.\n     */\n    private $extension;\n\n\n\n    /**\n     * Output format, supports null (image) or json.\n     */\n    private $outputFormat = null;\n\n\n\n    /**\n     * Do lossy output using external postprocessing tools.\n     */\n    private $lossy = null;\n\n\n\n    /**\n     * Verbose mode to print out a trace and display the created image\n     */\n    private $verbose = false;\n\n\n\n    /**\n     * Keep a log/trace on what happens\n     */\n    private $log = array();\n\n\n\n    /**\n     * Handle image as palette image\n     */\n    private $palette;\n\n\n\n    /**\n     * Target filename, with path, to save resulting image in.\n     */\n    private $cacheFileName;\n\n\n\n    /**\n     * Set a format to save image as, or null to use original format.\n     */\n    private $saveAs;\n\n\n    /**\n     * Path to command for lossy optimize, for example pngquant.\n     */\n    private $pngLossy;\n    private $pngLossyCmd;\n\n\n\n    /**\n     * Path to command for filter optimize, for example optipng.\n     */\n    private $pngFilter;\n    private $pngFilterCmd;\n\n\n\n    /**\n     * Path to command for deflate optimize, for example pngout.\n     */\n    private $pngDeflate;\n    private $pngDeflateCmd;\n\n\n\n    /**\n     * Path to command to optimize jpeg images, for example jpegtran or null.\n     */\n     private $jpegOptimize;\n     private $jpegOptimizeCmd;\n\n\n\n    /**\n     * Image dimensions, calculated from loaded image.\n     */\n    private $width;  // Calculated from source image\n    private $height; // Calculated from source image\n\n\n    /**\n     * New image dimensions, incoming as argument or calculated.\n     */\n    private $newWidth;\n    private $newWidthOrig;  // Save original value\n    private $newHeight;\n    private $newHeightOrig; // Save original value\n\n\n    /**\n     * Change target height & width when different dpr, dpr 2 means double image dimensions.\n     */\n    private $dpr = 1;\n\n\n    /**\n     * Always upscale images, even if they are smaller than target image.\n     */\n    const UPSCALE_DEFAULT = true;\n    private $upscale = self::UPSCALE_DEFAULT;\n\n\n\n    /**\n     * Array with details on how to crop, incoming as argument and calculated.\n     */\n    public $crop;\n    public $cropOrig; // Save original value\n\n\n    /**\n     * String with details on how to do image convolution. String\n     * should map a key in the $convolvs array or be a string of\n     * 11 float values separated by comma. The first nine builds\n     * up the matrix, then divisor and last offset.\n     */\n    private $convolve;\n\n\n    /**\n     * Custom convolution expressions, matrix 3x3, divisor and offset.\n     */\n    private $convolves = array(\n        'lighten'       => '0,0,0, 0,12,0, 0,0,0, 9, 0',\n        'darken'        => '0,0,0, 0,6,0, 0,0,0, 9, 0',\n        'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n        'emboss'        => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0',\n        'emboss-alt'    => '-2,-1,0, -1,1,1, 0,1,2, 1, 0',\n        'blur'          => '1,1,1, 1,15,1, 1,1,1, 23, 0',\n        'gblur'         => '1,2,1, 2,4,2, 1,2,1, 16, 0',\n        'edge'          => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0',\n        'edge-alt'      => '0,1,0, 1,-4,1, 0,1,0, 1, 0',\n        'draw'          => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0',\n        'mean'          => '1,1,1, 1,1,1, 1,1,1, 9, 0',\n        'motion'        => '1,0,0, 0,1,0, 0,0,1, 3, 0',\n    );\n\n\n    /**\n     * Resize strategy to fill extra area with background color.\n     * True or false.\n     */\n    private $fillToFit;\n\n\n\n    /**\n     * To store value for option scale.\n     */\n    private $scale;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateBefore;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateAfter;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $autoRotate;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $sharpen;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $emboss;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $blur;\n\n\n\n    /**\n     * Used with option area to set which parts of the image to use.\n     */\n    private $offset;\n\n\n\n    /**\n     * Calculate target dimension for image when using fill-to-fit resize strategy.\n     */\n    private $fillWidth;\n    private $fillHeight;\n\n\n\n    /**\n     * Allow remote file download, default is to disallow remote file download.\n     */\n    private $allowRemote = false;\n\n\n\n    /**\n     * Path to cache for remote download.\n     */\n    private $remoteCache;\n\n\n\n    /**\n     * Pattern to recognize a remote file.\n     */\n    //private $remotePattern = '#^[http|https]://#';\n    private $remotePattern = '#^https?://#';\n\n\n\n    /**\n     * Use the cache if true, set to false to ignore the cached file.\n     */\n    private $useCache = true;\n\n\n    /**\n    * Disable the fasttrackCacke to start with, inject an object to enable it.\n    */\n    private $fastTrackCache = null;\n\n\n\n    /*\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     */\n    private $remoteHostWhitelist = null;\n\n\n\n    /*\n     * Do verbose logging to file by setting this to a filename.\n     */\n    private $verboseFileName = null;\n\n\n\n    /*\n     * Output to ascii can take som options as an array.\n     */\n    private $asciiOptions = array();\n\n\n\n    /*\n     * Use interlaced progressive mode for JPEG images.\n     */\n    private $interlace = false;\n\n\n\n    /*\n     * Image copy strategy, defaults to RESAMPLE.\n     */\n     const RESIZE = 1;\n     const RESAMPLE = 2;\n     private $copyStrategy = NULL;\n\n\n\n    /**\n     * Properties, the class is mutable and the method setOptions()\n     * decides (partly) what properties are created.\n     *\n     * @todo Clean up these and check if and how they are used\n     */\n\n    public $keepRatio;\n    public $cropToFit;\n    private $cropWidth;\n    private $cropHeight;\n    public $crop_x;\n    public $crop_y;\n    public $filters;\n    private $attr; // Calculated from source image\n\n\n\n\n    /**\n     * Constructor, can take arguments to init the object.\n     *\n     * @param string $imageSrc    filename which may contain subdirectory.\n     * @param string $imageFolder path to root folder for images.\n     * @param string $saveFolder  path to folder where to save the new file or null to skip saving.\n     * @param string $saveName    name of target file when saveing.\n     */\n    public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null)\n    {\n        $this->setSource($imageSrc, $imageFolder);\n        $this->setTarget($saveFolder, $saveName);\n    }\n\n\n\n    /**\n     * Inject object and use it, must be available as member.\n     *\n     * @param string $property to set as object.\n     * @param object $object   to set to property.\n     *\n     * @return $this\n     */\n    public function injectDependency($property, $object)\n    {\n        if (!property_exists($this, $property)) {\n            $this->raiseError(\"Injecting unknown property.\");\n        }\n        $this->$property = $object;\n        return $this;\n    }\n\n\n\n    /**\n     * Set verbose mode.\n     *\n     * @param boolean $mode true or false to enable and disable verbose mode,\n     *                      default is true.\n     *\n     * @return $this\n     */\n    public function setVerbose($mode = true)\n    {\n        $this->verbose = $mode;\n        return $this;\n    }\n\n\n\n    /**\n     * Set save folder, base folder for saving cache files.\n     *\n     * @todo clean up how $this->saveFolder is used in other methods.\n     *\n     * @param string $path where to store cached files.\n     *\n     * @return $this\n     */\n    public function setSaveFolder($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Use cache or not.\n     *\n     * @param boolean $use true or false to use cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Create and save a dummy image. Use dimensions as stated in\n     * $this->newWidth, or $width or default to 100 (same for height.\n     *\n     * @param integer $width  use specified width for image dimension.\n     * @param integer $height use specified width for image dimension.\n     *\n     * @return $this\n     */\n    public function createDummyImage($width = null, $height = null)\n    {\n        $this->newWidth  = $this->newWidth  ?: $width  ?: 100;\n        $this->newHeight = $this->newHeight ?: $height ?: 100;\n\n        $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Allow or disallow remote image download.\n     *\n     * @param boolean $allow   true or false to enable and disable.\n     * @param string  $cache   path to cache dir.\n     * @param string  $pattern to use to detect if its a remote file.\n     *\n     * @return $this\n     */\n    public function setRemoteDownload($allow, $cache, $pattern = null)\n    {\n        $this->allowRemote = $allow;\n        $this->remoteCache = $cache;\n        $this->remotePattern = is_null($pattern) ? $this->remotePattern : $pattern;\n\n        $this->log(\n            \"Set remote download to: \"\n            . ($this->allowRemote ? \"true\" : \"false\")\n            . \" using pattern \"\n            . $this->remotePattern\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the image resource is a remote file or not.\n     *\n     * @param string $src check if src is remote.\n     *\n     * @return boolean true if $src is a remote file, else false.\n     */\n    public function isRemoteSource($src)\n    {\n        $remote = preg_match($this->remotePattern, $src);\n        $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\"));\n        return !!$remote;\n    }\n\n\n\n    /**\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     *\n     * @param array $whitelist with regexp hostnames to allow download from.\n     *\n     * @return $this\n     */\n    public function setRemoteHostWhitelist($whitelist = null)\n    {\n        $this->remoteHostWhitelist = $whitelist;\n        $this->log(\n            \"Setting remote host whitelist to: \"\n            . (is_null($whitelist) ? \"null\" : print_r($whitelist, 1))\n        );\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the hostname for the remote image, is on a whitelist,\n     * if the whitelist is defined.\n     *\n     * @param string $src the remote source.\n     *\n     * @return boolean true if hostname on $src is in the whitelist, else false.\n     */\n    public function isRemoteSourceOnWhitelist($src)\n    {\n        if (is_null($this->remoteHostWhitelist)) {\n            $this->log(\"Remote host on whitelist not configured - allowing.\");\n            return true;\n        }\n\n        $whitelist = new CWhitelist();\n        $hostname = parse_url($src, PHP_URL_HOST);\n        $allow = $whitelist->check($hostname, $this->remoteHostWhitelist);\n\n        $this->log(\n            \"Remote host is on whitelist: \"\n            . ($allow ? \"true\" : \"false\")\n        );\n        return $allow;\n    }\n\n\n\n    /**\n     * Check if file extension is valid as a file extension.\n     *\n     * @param string $extension of image file.\n     *\n     * @return $this\n     */\n    private function checkFileExtension($extension)\n    {\n        $valid = array('jpg', 'jpeg', 'png', 'gif', 'webp');\n\n        in_array(strtolower($extension), $valid)\n            or $this->raiseError('Not a valid file extension.');\n\n        return $this;\n    }\n\n\n\n    /**\n     * Normalize the file extension.\n     *\n     * @param string $extension of image file or skip to use internal.\n     *\n     * @return string $extension as a normalized file extension.\n     */\n    private function normalizeFileExtension($extension = \"\")\n    {\n        $extension = strtolower($extension ? $extension : $this->extension ?? \"\");\n\n        if ($extension == 'jpeg') {\n                $extension = 'jpg';\n        }\n\n        return $extension;\n    }\n\n\n\n    /**\n     * Download a remote image and return path to its local copy.\n     *\n     * @param string $src remote path to image.\n     *\n     * @return string as path to downloaded remote source.\n     */\n    public function downloadRemoteSource($src)\n    {\n        if (!$this->isRemoteSourceOnWhitelist($src)) {\n            throw new Exception(\"Hostname is not on whitelist for remote sources.\");\n        }\n\n        $remote = new CRemoteImage();\n\n        if (!is_writable($this->remoteCache)) {\n            $this->log(\"The remote cache is not writable.\");\n        }\n\n        $remote->setCache($this->remoteCache);\n        $remote->useCache($this->useCache);\n        $src = $remote->download($src);\n\n        $this->log(\"Remote HTTP status: \" . $remote->getStatus());\n        $this->log(\"Remote item is in local cache: $src\");\n        $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true));\n\n        return $src;\n    }\n\n\n\n    /**\n     * Set source file to use as image source.\n     *\n     * @param string $src of image.\n     * @param string $dir as optional base directory where images are.\n     *\n     * @return $this\n     */\n    public function setSource($src, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->imageSrc = null;\n            $this->pathToImage = null;\n            return $this;\n        }\n\n        if ($this->allowRemote && $this->isRemoteSource($src)) {\n            $src = $this->downloadRemoteSource($src);\n            $dir = null;\n        }\n\n        if (!isset($dir)) {\n            $dir = dirname($src);\n            $src = basename($src);\n        }\n\n        $this->imageSrc     = ltrim($src, '/');\n        $imageFolder        = rtrim($dir, '/');\n        $this->pathToImage  = $imageFolder . '/' . $this->imageSrc;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set target file.\n     *\n     * @param string $src of target image.\n     * @param string $dir as optional base directory where images are stored.\n     *                    Uses $this->saveFolder if null.\n     *\n     * @return $this\n     */\n    public function setTarget($src = null, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->cacheFileName = null;\n            return $this;\n        }\n\n        if (isset($dir)) {\n            $this->saveFolder = rtrim($dir, '/');\n        }\n\n        $this->cacheFileName  = $this->saveFolder . '/' . $src;\n\n        // Sanitize filename\n        $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName);\n        $this->log(\"The cache file name is: \" . $this->cacheFileName);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get filename of target file.\n     *\n     * @return Boolean|String as filename of target or false if not set.\n     */\n    public function getTarget()\n    {\n        return $this->cacheFileName;\n    }\n\n\n\n    /**\n     * Set options to use when processing image.\n     *\n     * @param array $args used when processing image.\n     *\n     * @return $this\n     */\n    public function setOptions($args)\n    {\n        $this->log(\"Set new options for processing image.\");\n\n        $defaults = array(\n            // Options for calculate dimensions\n            'newWidth'    => null,\n            'newHeight'   => null,\n            'aspectRatio' => null,\n            'keepRatio'   => true,\n            'cropToFit'   => false,\n            'fillToFit'   => null,\n            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),\n            'area'        => null, //'0,0,0,0',\n            'upscale'     => self::UPSCALE_DEFAULT,\n\n            // Options for caching or using original\n            'useCache'    => true,\n            'useOriginal' => true,\n\n            // Pre-processing, before resizing is done\n            'scale'        => null,\n            'rotateBefore' => null,\n            'autoRotate'  => false,\n\n            // General options\n            'bgColor'     => null,\n\n            // Post-processing, after resizing is done\n            'palette'     => null,\n            'filters'     => null,\n            'sharpen'     => null,\n            'emboss'      => null,\n            'blur'        => null,\n            'convolve'       => null,\n            'rotateAfter' => null,\n            'interlace' => null,\n\n            // Output format\n            'outputFormat' => null,\n            'dpr'          => 1,\n\n            // Postprocessing using external tools\n            'lossy' => null,\n        );\n\n        // Convert crop settings from string to array\n        if (isset($args['crop']) && !is_array($args['crop'])) {\n            $pices = explode(',', $args['crop']);\n            $args['crop'] = array(\n                'width'   => $pices[0],\n                'height'  => $pices[1],\n                'start_x' => $pices[2],\n                'start_y' => $pices[3],\n            );\n        }\n\n        // Convert area settings from string to array\n        if (isset($args['area']) && !is_array($args['area'])) {\n                $pices = explode(',', $args['area']);\n                $args['area'] = array(\n                    'top'    => $pices[0],\n                    'right'  => $pices[1],\n                    'bottom' => $pices[2],\n                    'left'   => $pices[3],\n                );\n        }\n\n        // Convert filter settings from array of string to array of array\n        if (isset($args['filters']) && is_array($args['filters'])) {\n            foreach ($args['filters'] as $key => $filterStr) {\n                $parts = explode(',', $filterStr);\n                $filter = $this->mapFilter($parts[0]);\n                $filter['str'] = $filterStr;\n                for ($i=1; $i<=$filter['argc']; $i++) {\n                    if (isset($parts[$i])) {\n                        $filter[\"arg{$i}\"] = $parts[$i];\n                    } else {\n                        throw new Exception(\n                            'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php'\n                        );\n                    }\n                }\n                $args['filters'][$key] = $filter;\n            }\n        }\n\n        // Merge default arguments with incoming and set properties.\n        //$args = array_merge_recursive($defaults, $args);\n        $args = array_merge($defaults, $args);\n        foreach ($defaults as $key => $val) {\n            $this->{$key} = $args[$key];\n        }\n\n        if ($this->bgColor) {\n            $this->setDefaultBackgroundColor($this->bgColor);\n        }\n\n        // Save original values to enable re-calculating\n        $this->newWidthOrig  = $this->newWidth;\n        $this->newHeightOrig = $this->newHeight;\n        $this->cropOrig      = $this->crop;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Map filter name to PHP filter and id.\n     *\n     * @param string $name the name of the filter.\n     *\n     * @return array with filter settings\n     * @throws Exception\n     */\n    private function mapFilter($name)\n    {\n        $map = array(\n            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),\n            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),\n            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),\n            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),\n            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),\n            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),\n            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),\n            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),\n            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),\n            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),\n            'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),\n            'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),\n        );\n\n        if (isset($map[$name])) {\n            return $map[$name];\n        } else {\n            throw new Exception('No such filter.');\n        }\n    }\n\n\n\n    /**\n     * Load image details from original image file.\n     *\n     * @param string $file the file to load or null to use $this->pathToImage.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function loadImageDetails($file = null)\n    {\n        $file = $file ? $file : $this->pathToImage;\n\n        // Special case to solve Windows 2 WSL integration\n        if (!defined('WINDOWS2WSL')) {\n            is_readable($file)\n                or $this->raiseError('Image file does not exist.');\n        }\n\n        $info = list($this->width, $this->height, $this->fileType) = getimagesize($file);\n        if (empty($info)) {\n            // To support webp\n            $this->fileType = false;\n            if (function_exists(\"exif_imagetype\")) {\n                $this->fileType = exif_imagetype($file);\n                if ($this->fileType === false) {\n                    if (function_exists(\"imagecreatefromwebp\")) {\n                        $webp = imagecreatefromwebp($file);\n                        if ($webp !== false) {\n                            $this->width  = imagesx($webp);\n                            $this->height = imagesy($webp);\n                            $this->fileType = IMG_WEBP;\n                        }\n                    }\n                }\n            }\n        }\n\n        if (!$this->fileType) {\n            throw new Exception(\"Loading image details, the file doesn't seem to be a valid image.\");\n        }\n\n        if ($this->verbose) {\n            $this->log(\"Loading image details for: {$file}\");\n            $this->log(\" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType}).\");\n            $this->log(\" Image filesize: \" . filesize($file) . \" bytes.\");\n            $this->log(\" Image mimetype: \" . $this->getMimeType());\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get mime type for image type.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    protected function getMimeType()\n    {\n        if ($this->fileType === IMG_WEBP) {\n            return \"image/webp\";\n        }\n\n        return image_type_to_mime_type($this->fileType);\n    }\n\n\n\n    /**\n     * Init new width and height and do some sanity checks on constraints, before any\n     * processing can be done.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function initDimensions()\n    {\n        $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // width as %\n        if ($this->newWidth\n            && $this->newWidth[strlen($this->newWidth)-1] == '%') {\n            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;\n            $this->log(\"Setting new width based on % to {$this->newWidth}\");\n        }\n\n        // height as %\n        if ($this->newHeight\n            && $this->newHeight[strlen($this->newHeight)-1] == '%') {\n            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;\n            $this->log(\"Setting new height based on % to {$this->newHeight}\");\n        }\n\n        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');\n\n        // width & height from aspect ratio\n        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {\n            if ($this->aspectRatio >= 1) {\n                $this->newWidth   = $this->width;\n                $this->newHeight  = $this->width / $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n\n            } else {\n                $this->newHeight  = $this->height;\n                $this->newWidth   = $this->height * $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n            }\n\n        } elseif ($this->aspectRatio && is_null($this->newWidth)) {\n            $this->newWidth   = $this->newHeight * $this->aspectRatio;\n            $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\");\n\n        } elseif ($this->aspectRatio && is_null($this->newHeight)) {\n            $this->newHeight  = $this->newWidth / $this->aspectRatio;\n            $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\");\n        }\n\n        // Change width & height based on dpr\n        if ($this->dpr != 1) {\n            if (!is_null($this->newWidth)) {\n                $this->newWidth  = round($this->newWidth * $this->dpr);\n                $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\");\n            }\n            if (!is_null($this->newHeight)) {\n                $this->newHeight = round($this->newHeight * $this->dpr);\n                $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\");\n            }\n        }\n\n        // Check values to be within domain\n        is_null($this->newWidth)\n            or is_numeric($this->newWidth)\n            or $this->raiseError('Width not numeric');\n\n        is_null($this->newHeight)\n            or is_numeric($this->newHeight)\n            or $this->raiseError('Height not numeric');\n\n        $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Calculate new width and height of image, based on settings.\n     *\n     * @return $this\n     */\n    public function calculateNewWidthAndHeight()\n    {\n        // Crop, use cropped width and height as base for calulations\n        $this->log(\"Calculate new width and height.\");\n        $this->log(\"Original width x height is {$this->width} x {$this->height}.\");\n        $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // Check if there is an area to crop off\n        if (isset($this->area)) {\n            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);\n            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);\n            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);\n            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);\n            $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];\n            $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];\n            $this->width  = $this->offset['width'];\n            $this->height = $this->offset['height'];\n            $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\");\n            $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\");\n        }\n\n        $width  = $this->width;\n        $height = $this->height;\n\n        // Check if crop is set\n        if ($this->crop) {\n            $width  = $this->crop['width']  = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];\n            $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];\n\n            if ($this->crop['start_x'] == 'left') {\n                $this->crop['start_x'] = 0;\n            } elseif ($this->crop['start_x'] == 'right') {\n                $this->crop['start_x'] = $this->width - $width;\n            } elseif ($this->crop['start_x'] == 'center') {\n                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);\n            }\n\n            if ($this->crop['start_y'] == 'top') {\n                $this->crop['start_y'] = 0;\n            } elseif ($this->crop['start_y'] == 'bottom') {\n                $this->crop['start_y'] = $this->height - $height;\n            } elseif ($this->crop['start_y'] == 'center') {\n                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);\n            }\n\n            $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\");\n        }\n\n        // Calculate new width and height if keeping aspect-ratio.\n        if ($this->keepRatio) {\n\n            $this->log(\"Keep aspect ratio.\");\n\n            // Crop-to-fit and both new width and height are set.\n            if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Use newWidth and newHeigh as width/height, image should fit in box.\n                $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\");\n\n            } elseif (isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Both new width and height are set.\n                // Use newWidth and newHeigh as max width/height, image should not be larger.\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n                $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;\n                $this->newWidth  = round($width  / $ratio);\n                $this->newHeight = round($height / $ratio);\n                $this->log(\"New width and height was set.\");\n\n            } elseif (isset($this->newWidth)) {\n\n                // Use new width as max-width\n                $factor = (float)$this->newWidth / (float)$width;\n                $this->newHeight = round($factor * $height);\n                $this->log(\"New width was set.\");\n\n            } elseif (isset($this->newHeight)) {\n\n                // Use new height as max-hight\n                $factor = (float)$this->newHeight / (float)$height;\n                $this->newWidth = round($factor * $width);\n                $this->log(\"New height was set.\");\n\n            } else {\n\n                // Use existing width and height as new width and height.\n                $this->newWidth = $width;\n                $this->newHeight = $height;\n            }\n\n\n            // Get image dimensions for pre-resize image.\n            if ($this->cropToFit || $this->fillToFit) {\n\n                // Get relations of original & target image\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n\n                if ($this->cropToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Crop to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;\n                    $this->cropWidth  = round($width  / $ratio);\n                    $this->cropHeight = round($height / $ratio);\n                    $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\");\n\n                } elseif ($this->fillToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Fill to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;\n                    $this->fillWidth  = round($width  / $ratio);\n                    $this->fillHeight = round($height / $ratio);\n                    $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\");\n                }\n            }\n        }\n\n        // Crop, ensure to set new width and height\n        if ($this->crop) {\n            $this->log(\"Crop.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }\n\n        // Fill to fit, ensure to set new width and height\n        /*if ($this->fillToFit) {\n            $this->log(\"FillToFit.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }*/\n\n        // No new height or width is set, use existing measures.\n        $this->newWidth  = round(isset($this->newWidth) ? $this->newWidth : $this->width);\n        $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height);\n        $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Re-calculate image dimensions when original image dimension has changed.\n     *\n     * @return $this\n     */\n    public function reCalculateDimensions()\n    {\n        $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight);\n\n        $this->newWidth  = $this->newWidthOrig;\n        $this->newHeight = $this->newHeightOrig;\n        $this->crop      = $this->cropOrig;\n\n        $this->initDimensions()\n             ->calculateNewWidthAndHeight();\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set extension for filename to save as.\n     *\n     * @param string $saveas extension to save image as\n     *\n     * @return $this\n     */\n    public function setSaveAsExtension($saveAs = null)\n    {\n        if (isset($saveAs)) {\n            $saveAs = strtolower($saveAs);\n            $this->checkFileExtension($saveAs);\n            $this->saveAs = $saveAs;\n            $this->extension = $saveAs;\n        }\n\n        $this->log(\"Prepare to save image as: \" . $this->extension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set JPEG quality to use when saving image\n     *\n     * @param int $quality as the quality to set.\n     *\n     * @return $this\n     */\n    public function setJpegQuality($quality = null)\n    {\n        if ($quality) {\n            $this->useQuality = true;\n        }\n\n        $this->quality = isset($quality)\n            ? $quality\n            : self::JPEG_QUALITY_DEFAULT;\n\n        (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting JPEG quality to {$this->quality}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set PNG compressen algorithm to use when saving image\n     *\n     * @param int $compress as the algorithm to use.\n     *\n     * @return $this\n     */\n    public function setPngCompression($compress = null)\n    {\n        if ($compress) {\n            $this->useCompress = true;\n        }\n\n        $this->compress = isset($compress)\n            ? $compress\n            : self::PNG_COMPRESSION_DEFAULT;\n\n        (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting PNG compression level to {$this->compress}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Use original image if possible, check options which affects image processing.\n     *\n     * @param boolean $useOrig default is to use original if possible, else set to false.\n     *\n     * @return $this\n     */\n    public function useOriginalIfPossible($useOrig = true)\n    {\n        if ($useOrig\n            && ($this->newWidth == $this->width)\n            && ($this->newHeight == $this->height)\n            && !$this->area\n            && !$this->crop\n            && !$this->cropToFit\n            && !$this->fillToFit\n            && !$this->filters\n            && !$this->sharpen\n            && !$this->emboss\n            && !$this->blur\n            && !$this->convolve\n            && !$this->palette\n            && !$this->useQuality\n            && !$this->useCompress\n            && !$this->saveAs\n            && !$this->rotateBefore\n            && !$this->rotateAfter\n            && !$this->autoRotate\n            && !$this->bgColor\n            && ($this->upscale === self::UPSCALE_DEFAULT)\n            && !$this->lossy\n        ) {\n            $this->log(\"Using original image.\");\n            $this->output($this->pathToImage);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Generate filename to save file in cache.\n     *\n     * @param string  $base      as optional basepath for storing file.\n     * @param boolean $useSubdir use or skip the subdir part when creating the\n     *                           filename.\n     * @param string  $prefix    to add as part of filename\n     *\n     * @return $this\n     */\n    public function generateFilename($base = null, $useSubdir = true, $prefix = null)\n    {\n        $filename     = basename($this->pathToImage);\n        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;\n        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;\n        $crop_x       = $this->crop_x       ? \"_x{$this->crop_x}\"        : null;\n        $crop_y       = $this->crop_y       ? \"_y{$this->crop_y}\"        : null;\n        $scale        = $this->scale        ? \"_s{$this->scale}\"         : null;\n        $bgColor      = $this->bgColor      ? \"_bgc{$this->bgColor}\"     : null;\n        $quality      = $this->quality      ? \"_q{$this->quality}\"       : null;\n        $compress     = $this->compress     ? \"_co{$this->compress}\"     : null;\n        $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null;\n        $rotateAfter  = $this->rotateAfter  ? \"_ra{$this->rotateAfter}\"  : null;\n        $lossy        = $this->lossy        ? \"_l\"                       : null;\n        $interlace    = $this->interlace    ? \"_i\"                       : null;\n\n        $saveAs = $this->normalizeFileExtension();\n        $saveAs = $saveAs ? \"_$saveAs\" : null;\n\n        $copyStrat = null;\n        if ($this->copyStrategy === self::RESIZE) {\n            $copyStrat = \"_rs\";\n        }\n\n        $width  = $this->newWidth  ? '_' . $this->newWidth  : null;\n        $height = $this->newHeight ? '_' . $this->newHeight : null;\n\n        $offset = isset($this->offset)\n            ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left']\n            : null;\n\n        $crop = $this->crop\n            ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y']\n            : null;\n\n        $filters = null;\n        if (isset($this->filters)) {\n            foreach ($this->filters as $filter) {\n                if (is_array($filter)) {\n                    $filters .= \"_f{$filter['id']}\";\n                    for ($i=1; $i<=$filter['argc']; $i++) {\n                        $filters .= \"-\".$filter[\"arg{$i}\"];\n                    }\n                }\n            }\n        }\n\n        $sharpen = $this->sharpen ? 's' : null;\n        $emboss  = $this->emboss  ? 'e' : null;\n        $blur    = $this->blur    ? 'b' : null;\n        $palette = $this->palette ? 'p' : null;\n\n        $autoRotate = $this->autoRotate ? 'ar' : null;\n\n        $optimize  = $this->jpegOptimize ? 'o' : null;\n        $optimize .= $this->pngFilter    ? 'f' : null;\n        $optimize .= $this->pngDeflate   ? 'd' : null;\n\n        $convolve = null;\n        if ($this->convolve) {\n            $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve);\n        }\n\n        $upscale = null;\n        if ($this->upscale !== self::UPSCALE_DEFAULT) {\n            $upscale = '_nu';\n        }\n\n        $subdir = null;\n        if ($useSubdir === true) {\n            $subdir = str_replace('/', '-', dirname($this->imageSrc));\n            $subdir = ($subdir == '.') ? '_.' : $subdir;\n            $subdir .= '_';\n        }\n\n        $file = $prefix . $subdir . $filename . $width . $height\n            . $offset . $crop . $cropToFit . $fillToFit\n            . $crop_x . $crop_y . $upscale\n            . $quality . $filters . $sharpen . $emboss . $blur . $palette\n            . $optimize . $compress\n            . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor\n            . $convolve . $copyStrat . $lossy . $interlace . $saveAs;\n\n        return $this->setTarget($file, $base);\n    }\n\n\n\n    /**\n     * Use cached version of image, if possible.\n     *\n     * @param boolean $useCache is default true, set to false to avoid using cached object.\n     *\n     * @return $this\n     */\n    public function useCacheIfPossible($useCache = true)\n    {\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime   = filemtime($this->pathToImage);\n            $cacheTime  = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                if ($this->useCache) {\n                    if ($this->verbose) {\n                        $this->log(\"Use cached file.\");\n                        $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $this->output($this->cacheFileName, $this->outputFormat);\n                } else {\n                    $this->log(\"Cache is valid but ignoring it by intention.\");\n                }\n            } else {\n                $this->log(\"Original file is modified, ignoring cache.\");\n            }\n        } else {\n            $this->log(\"Cachefile does not exists or ignoring it.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Load image from disk. Try to load image without verbose error message,\n     * if fail, load again and display error messages.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     *\n     */\n    public function load($src = null, $dir = null)\n    {\n        if (isset($src)) {\n            $this->setSource($src, $dir);\n        }\n\n        $this->loadImageDetails();\n\n        if ($this->fileType === IMG_WEBP) {\n            $this->image = imagecreatefromwebp($this->pathToImage);\n        } else {\n            $imageAsString = file_get_contents($this->pathToImage);\n            $this->image = imagecreatefromstring($imageAsString);\n        }\n        if ($this->image === false) {\n            throw new Exception(\"Could not load image.\");\n        }\n\n        /* Removed v0.7.7\n        if (image_type_to_mime_type($this->fileType) == 'image/png') {\n            $type = $this->getPngType();\n            $hasFewColors = imagecolorstotal($this->image);\n\n            if ($type == self::PNG_RGB_PALETTE || ($hasFewColors > 0 && $hasFewColors <= 256)) {\n                if ($this->verbose) {\n                    $this->log(\"Handle this image as a palette image.\");\n                }\n                $this->palette = true;\n            }\n        }\n        */\n\n        if ($this->verbose) {\n            $this->log(\"### Image successfully loaded from file.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->colorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index >= 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the type of PNG image.\n     *\n     * @param string $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    public function getPngType($filename = null)\n    {\n        $filename = $filename ? $filename : $this->pathToImage;\n\n        $pngType = ord(file_get_contents($filename, false, null, 25, 1));\n\n        if ($this->verbose) {\n            $this->log(\"Checking png type of: \" . $filename);\n            $this->log($this->getPngTypeAsString($pngType));\n        }\n\n        return $pngType;\n    }\n\n\n\n    /**\n     * Get the type of PNG image as a verbose string.\n     *\n     * @param integer $type     to use, default is to check the type.\n     * @param string  $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    private function getPngTypeAsString($pngType = null, $filename = null)\n    {\n        if ($filename || !$pngType) {\n            $pngType = $this->getPngType($filename);\n        }\n\n        $index = imagecolortransparent($this->image);\n        $transparent = null;\n        if ($index != -1) {\n            $transparent = \" (transparent)\";\n        }\n\n        switch ($pngType) {\n\n            case self::PNG_GREYSCALE:\n                $text = \"PNG is type 0, Greyscale$transparent\";\n                break;\n\n            case self::PNG_RGB:\n                $text = \"PNG is type 2, RGB$transparent\";\n                break;\n\n            case self::PNG_RGB_PALETTE:\n                $text = \"PNG is type 3, RGB with palette$transparent\";\n                break;\n\n            case self::PNG_GREYSCALE_ALPHA:\n                $text = \"PNG is type 4, Greyscale with alpha channel\";\n                break;\n\n            case self::PNG_RGB_ALPHA:\n                $text = \"PNG is type 6, RGB with alpha channel (PNG 32-bit)\";\n                break;\n\n            default:\n                $text = \"PNG is UNKNOWN type, is it really a PNG image?\";\n        }\n\n        return $text;\n    }\n\n\n\n\n    /**\n     * Calculate number of colors in an image.\n     *\n     * @param resource $im the image.\n     *\n     * @return int\n     */\n    private function colorsTotal($im)\n    {\n        if (imageistruecolor($im)) {\n            $this->log(\"Colors as true color.\");\n            $h = imagesy($im);\n            $w = imagesx($im);\n            $c = array();\n            for ($x=0; $x < $w; $x++) {\n                for ($y=0; $y < $h; $y++) {\n                    @$c['c'.imagecolorat($im, $x, $y)]++;\n                }\n            }\n            return count($c);\n        } else {\n            $this->log(\"Colors as palette.\");\n            return imagecolorstotal($im);\n        }\n    }\n\n\n\n    /**\n     * Preprocess image before rezising it.\n     *\n     * @return $this\n     */\n    public function preResize()\n    {\n        $this->log(\"### Pre-process before resizing\");\n\n        // Rotate image\n        if ($this->rotateBefore) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateBefore, $this->bgColor)\n                 ->reCalculateDimensions();\n        }\n\n        // Auto-rotate image\n        if ($this->autoRotate) {\n            $this->log(\"Auto rotating image.\");\n            $this->rotateExif()\n                 ->reCalculateDimensions();\n        }\n\n        // Scale the original image before starting\n        if (isset($this->scale)) {\n            $this->log(\"Scale by {$this->scale}%\");\n            $newWidth  = $this->width * $this->scale / 100;\n            $newHeight = $this->height * $this->scale / 100;\n            $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);\n            imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);\n            $this->image = $img;\n            $this->width = $newWidth;\n            $this->height = $newHeight;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Resize or resample the image while resizing.\n     *\n     * @param int $strategy as CImage::RESIZE or CImage::RESAMPLE\n     *\n     * @return $this\n     */\n     public function setCopyResizeStrategy($strategy)\n     {\n         $this->copyStrategy = $strategy;\n         return $this;\n     }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return void\n     */\n    public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)\n    {\n        if($this->copyStrategy == self::RESIZE) {\n            $this->log(\"Copy by resize\");\n            imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        } else {\n            $this->log(\"Copy by resample\");\n            imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        }\n    }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return $this\n     */\n    public function resize()\n    {\n\n        $this->log(\"### Starting to Resize()\");\n        $this->log(\"Upscale = '$this->upscale'\");\n\n        // Only use a specified area of the image, $this->offset is defining the area to use\n        if (isset($this->offset)) {\n\n            $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\");\n            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);\n            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);\n            $this->image = $img;\n            $this->width = $this->offset['width'];\n            $this->height = $this->offset['height'];\n        }\n\n        if ($this->crop) {\n\n            // Do as crop, take only part of image\n            $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\");\n            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);\n            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);\n            $this->image = $img;\n            $this->width = $this->crop['width'];\n            $this->height = $this->crop['height'];\n        }\n\n        if (!$this->upscale) {\n            // Consider rewriting the no-upscale code to fit within this if-statement,\n            // likely to be more readable code.\n            // The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch\n        }\n\n        if ($this->cropToFit) {\n\n            // Resize by crop to fit\n            $this->log(\"Resizing using strategy - Crop to fit\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                $posX = 0;\n                $posY = 0;\n                $cropX = 0;\n                $cropY = 0;\n\n                if ($this->newWidth > $this->width) {\n                    $posX = round(($this->newWidth - $this->width) / 2);\n                }\n                if ($this->newWidth < $this->width) {\n                    $cropX = round(($this->width/2) - ($this->newWidth/2));\n                }\n\n                if ($this->newHeight > $this->height) {\n                    $posY = round(($this->newHeight - $this->height) / 2);\n                }\n                if ($this->newHeight < $this->height) {\n                    $cropY = round(($this->height/2) - ($this->newHeight/2));\n                }\n                $this->log(\" cwidth: $this->cropWidth\");\n                $this->log(\" cheight: $this->cropHeight\");\n                $this->log(\" nwidth: $this->newWidth\");\n                $this->log(\" nheight: $this->newHeight\");\n                $this->log(\" width: $this->width\");\n                $this->log(\" height: $this->height\");\n                $this->log(\" posX: $posX\");\n                $this->log(\" posY: $posY\");\n                $this->log(\" cropX: $cropX\");\n                $this->log(\" cropY: $cropY\");\n\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);\n            } else {\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n                $imgPreCrop   = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif ($this->fillToFit) {\n\n            // Resize by fill to fit\n            $this->log(\"Resizing using strategy - Fill to fit\");\n\n            $posX = 0;\n            $posY = 0;\n\n            $ratioOrig = $this->width / $this->height;\n            $ratioNew  = $this->newWidth / $this->newHeight;\n\n            // Check ratio for landscape or portrait\n            if ($ratioOrig < $ratioNew) {\n                $posX = round(($this->newWidth - $this->fillWidth) / 2);\n            } else {\n                $posY = round(($this->newHeight - $this->fillHeight) / 2);\n            }\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth && $this->height < $this->newHeight)\n            ) {\n\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n                $posX = round(($this->newWidth - $this->width) / 2);\n                $posY = round(($this->newHeight - $this->height) / 2);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);\n\n            } else {\n                $imgPreFill   = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {\n\n            // Resize it\n            $this->log(\"Resizing, new height and/or width\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                if (!$this->keepRatio) {\n                    $this->log(\"Resizing - stretch to fit selected.\");\n\n                    $posX = 0;\n                    $posY = 0;\n                    $cropX = 0;\n                    $cropY = 0;\n\n                    if ($this->newWidth > $this->width && $this->newHeight > $this->height) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                    } elseif ($this->newWidth > $this->width) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $cropY = round(($this->height - $this->newHeight) / 2);\n                    } elseif ($this->newHeight > $this->height) {\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                        $cropX = round(($this->width - $this->newWidth) / 2);\n                    }\n\n                    $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                    imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);\n                    $this->image = $imageResized;\n                    $this->width = $this->newWidth;\n                    $this->height = $this->newHeight;\n                }\n            } else {\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);\n                $this->image = $imageResized;\n                $this->width = $this->newWidth;\n                $this->height = $this->newHeight;\n            }\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Postprocess image after rezising image.\n     *\n     * @return $this\n     */\n    public function postResize()\n    {\n        $this->log(\"### Post-process after resizing\");\n\n        // Rotate image\n        if ($this->rotateAfter) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateAfter, $this->bgColor);\n        }\n\n        // Apply filters\n        if (isset($this->filters) && is_array($this->filters)) {\n\n            foreach ($this->filters as $filter) {\n                $this->log(\"Applying filter {$filter['type']}.\");\n\n                switch ($filter['argc']) {\n\n                    case 0:\n                        imagefilter($this->image, $filter['type']);\n                        break;\n\n                    case 1:\n                        imagefilter($this->image, $filter['type'], $filter['arg1']);\n                        break;\n\n                    case 2:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']);\n                        break;\n\n                    case 3:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']);\n                        break;\n\n                    case 4:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']);\n                        break;\n                }\n            }\n        }\n\n        // Convert to palette image\n        if ($this->palette) {\n            $this->log(\"Converting to palette image.\");\n            $this->trueColorToPalette();\n        }\n\n        // Blur the image\n        if ($this->blur) {\n            $this->log(\"Blur.\");\n            $this->blurImage();\n        }\n\n        // Emboss the image\n        if ($this->emboss) {\n            $this->log(\"Emboss.\");\n            $this->embossImage();\n        }\n\n        // Sharpen the image\n        if ($this->sharpen) {\n            $this->log(\"Sharpen.\");\n            $this->sharpenImage();\n        }\n\n        // Custom convolution\n        if ($this->convolve) {\n            //$this->log(\"Convolve: \" . $this->convolve);\n            $this->imageConvolution();\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using angle.\n     *\n     * @param float $angle        to rotate image.\n     * @param int   $anglebgColor to fill image with if needed.\n     *\n     * @return $this\n     */\n    public function rotate($angle, $bgColor)\n    {\n        $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\");\n\n        $color = $this->getBackgroundColor();\n        $this->image = imagerotate($this->image, $angle, $color);\n\n        $this->width  = imagesx($this->image);\n        $this->height = imagesy($this->image);\n\n        $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using information in EXIF.\n     *\n     * @return $this\n     */\n    public function rotateExif()\n    {\n        if (!in_array($this->fileType, array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) {\n            $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\");\n            return $this;\n        }\n\n        $exif = exif_read_data($this->pathToImage);\n\n        if (!empty($exif['Orientation'])) {\n            switch ($exif['Orientation']) {\n                case 3:\n                    $this->log(\"Autorotate 180.\");\n                    $this->rotate(180, $this->bgColor);\n                    break;\n\n                case 6:\n                    $this->log(\"Autorotate -90.\");\n                    $this->rotate(-90, $this->bgColor);\n                    break;\n\n                case 8:\n                    $this->log(\"Autorotate 90.\");\n                    $this->rotate(90, $this->bgColor);\n                    break;\n\n                default:\n                    $this->log(\"Autorotate ignored, unknown value as orientation.\");\n            }\n        } else {\n            $this->log(\"Autorotate ignored, no orientation in EXIF.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert true color image to palette image, keeping alpha.\n     * http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\n     *\n     * @return void\n     */\n    public function trueColorToPalette()\n    {\n        $img = imagecreatetruecolor($this->width, $this->height);\n        $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);\n        imagecolortransparent($img, $bga);\n        imagefill($img, 0, 0, $bga);\n        imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);\n        imagetruecolortopalette($img, false, 255);\n        imagesavealpha($img, true);\n\n        if (imageistruecolor($this->image)) {\n            $this->log(\"Matching colors with true color image.\");\n            imagecolormatch($this->image, $img);\n        }\n\n        $this->image = $img;\n    }\n\n\n\n    /**\n     * Sharpen image using image convolution.\n     *\n     * @return $this\n     */\n    public function sharpenImage()\n    {\n        $this->imageConvolution('sharpen');\n        return $this;\n    }\n\n\n\n    /**\n     * Emboss image using image convolution.\n     *\n     * @return $this\n     */\n    public function embossImage()\n    {\n        $this->imageConvolution('emboss');\n        return $this;\n    }\n\n\n\n    /**\n     * Blur image using image convolution.\n     *\n     * @return $this\n     */\n    public function blurImage()\n    {\n        $this->imageConvolution('blur');\n        return $this;\n    }\n\n\n\n    /**\n     * Create convolve expression and return arguments for image convolution.\n     *\n     * @param string $expression constant string which evaluates to a list of\n     *                           11 numbers separated by komma or such a list.\n     *\n     * @return array as $matrix (3x3), $divisor and $offset\n     */\n    public function createConvolveArguments($expression)\n    {\n        // Check of matching constant\n        if (isset($this->convolves[$expression])) {\n            $expression = $this->convolves[$expression];\n        }\n\n        $part = explode(',', $expression);\n        $this->log(\"Creating convolution expressen: $expression\");\n\n        // Expect list of 11 numbers, split by , and build up arguments\n        if (count($part) != 11) {\n            throw new Exception(\n                \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\"\n            );\n        }\n\n        array_walk($part, function ($item, $key) {\n            if (!is_numeric($item)) {\n                throw new Exception(\"Argument to convolve expression should be float but is not.\");\n            }\n        });\n\n        return array(\n            array(\n                array($part[0], $part[1], $part[2]),\n                array($part[3], $part[4], $part[5]),\n                array($part[6], $part[7], $part[8]),\n            ),\n            $part[9],\n            $part[10],\n        );\n    }\n\n\n\n    /**\n     * Add custom expressions (or overwrite existing) for image convolution.\n     *\n     * @param array $options Key value array with strings to be converted\n     *                       to convolution expressions.\n     *\n     * @return $this\n     */\n    public function addConvolveExpressions($options)\n    {\n        $this->convolves = array_merge($this->convolves, $options);\n        return $this;\n    }\n\n\n\n    /**\n     * Image convolution.\n     *\n     * @param string $options A string with 11 float separated by comma.\n     *\n     * @return $this\n     */\n    public function imageConvolution($options = null)\n    {\n        // Use incoming options or use $this.\n        $options = $options ? $options : $this->convolve;\n\n        // Treat incoming as string, split by +\n        $this->log(\"Convolution with '$options'\");\n        $options = explode(\":\", $options);\n\n        // Check each option if it matches constant value\n        foreach ($options as $option) {\n            list($matrix, $divisor, $offset) = $this->createConvolveArguments($option);\n            imageconvolution($this->image, $matrix, $divisor, $offset);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set default background color between 000000-FFFFFF or if using\n     * alpha 00000000-FFFFFF7F.\n     *\n     * @param string $color as hex value.\n     *\n     * @return $this\n    */\n    public function setDefaultBackgroundColor($color)\n    {\n        $this->log(\"Setting default background color to '$color'.\");\n\n        if (!(strlen($color) == 6 || strlen($color) == 8)) {\n            throw new Exception(\n                \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $red    = hexdec(substr($color, 0, 2));\n        $green  = hexdec(substr($color, 2, 2));\n        $blue   = hexdec(substr($color, 4, 2));\n\n        $alpha = (strlen($color) == 8)\n            ? hexdec(substr($color, 6, 2))\n            : null;\n\n        if (($red < 0 || $red > 255)\n            || ($green < 0 || $green > 255)\n            || ($blue < 0 || $blue > 255)\n            || ($alpha < 0 || $alpha > 127)\n        ) {\n            throw new Exception(\n                \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $this->bgColor = strtolower($color);\n        $this->bgColorDefault = array(\n            'red'   => $red,\n            'green' => $green,\n            'blue'  => $blue,\n            'alpha' => $alpha\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the background color.\n     *\n     * @param resource $img the image to work with or null if using $this->image.\n     *\n     * @return color value or null if no background color is set.\n    */\n    private function getBackgroundColor($img = null)\n    {\n        $img = isset($img) ? $img : $this->image;\n\n        if ($this->bgColorDefault) {\n\n            $red   = $this->bgColorDefault['red'];\n            $green = $this->bgColorDefault['green'];\n            $blue  = $this->bgColorDefault['blue'];\n            $alpha = $this->bgColorDefault['alpha'];\n\n            if ($alpha) {\n                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);\n            } else {\n                $color = imagecolorallocate($img, $red, $green, $blue);\n            }\n\n            return $color;\n\n        } else {\n            return 0;\n        }\n    }\n\n\n\n    /**\n     * Create a image and keep transparency for png and gifs.\n     *\n     * @param int $width of the new image.\n     * @param int $height of the new image.\n     *\n     * @return image resource.\n    */\n    private function createImageKeepTransparency($width, $height)\n    {\n        $this->log(\"Creating a new working image width={$width}px, height={$height}px.\");\n        $img = imagecreatetruecolor($width, $height);\n        imagealphablending($img, false);\n        imagesavealpha($img, true);\n\n        $index = $this->image\n            ? imagecolortransparent($this->image)\n            : -1;\n\n        if ($index != -1) {\n\n            imagealphablending($img, true);\n            $transparent = imagecolorsforindex($this->image, $index);\n            $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']);\n            imagefill($img, 0, 0, $color);\n            $index = imagecolortransparent($img, $color);\n            $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\");\n\n        } elseif ($this->bgColorDefault) {\n\n            $color = $this->getBackgroundColor($img);\n            imagefill($img, 0, 0, $color);\n            $this->Log(\"Filling image with background color.\");\n        }\n\n        return $img;\n    }\n\n\n\n    /**\n     * Set optimizing  and post-processing options.\n     *\n     * @param array $options with config for postprocessing with external tools.\n     *\n     * @return $this\n     */\n    public function setPostProcessingOptions($options)\n    {\n        if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) {\n            $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd'];\n        } else {\n            $this->jpegOptimizeCmd = null;\n        }\n\n        if (array_key_exists(\"png_lossy\", $options)\n            && $options['png_lossy'] !== false) {\n            $this->pngLossy = $options['png_lossy'];\n            $this->pngLossyCmd = $options['png_lossy_cmd'];\n        } else {\n            $this->pngLossyCmd = null;\n        }\n\n        if (isset($options['png_filter']) && $options['png_filter']) {\n            $this->pngFilterCmd = $options['png_filter_cmd'];\n        } else {\n            $this->pngFilterCmd = null;\n        }\n\n        if (isset($options['png_deflate']) && $options['png_deflate']) {\n            $this->pngDeflateCmd = $options['png_deflate_cmd'];\n        } else {\n            $this->pngDeflateCmd = null;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Find out the type (file extension) for the image to be saved.\n     *\n     * @return string as image extension.\n     */\n    protected function getTargetImageExtension()\n    {\n        // switch on mimetype\n        if (isset($this->extension)) {\n            return strtolower($this->extension);\n        } elseif ($this->fileType === IMG_WEBP) {\n            return \"webp\";\n        }\n\n        return substr(image_type_to_extension($this->fileType), 1);\n    }\n\n\n\n    /**\n     * Save image.\n     *\n     * @param string  $src       as target filename.\n     * @param string  $base      as base directory where to store images.\n     * @param boolean $overwrite or not, default to always overwrite file.\n     *\n     * @return $this or false if no folder is set.\n     */\n    public function save($src = null, $base = null, $overwrite = true)\n    {\n        if (isset($src)) {\n            $this->setTarget($src, $base);\n        }\n\n        if ($overwrite === false && is_file($this->cacheFileName)) {\n            $this->Log(\"Not overwriting file since its already exists and \\$overwrite if false.\");\n            return;\n        }\n\n        if (!defined(\"WINDOWS2WSL\")) {\n            is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n        }\n\n        $type = $this->getTargetImageExtension();\n        $this->Log(\"Saving image as \" . $type);\n        switch($type) {\n\n            case 'jpeg':\n            case 'jpg':\n                // Set as interlaced progressive JPEG\n                if ($this->interlace) {\n                    $this->Log(\"Set JPEG image to be interlaced.\");\n                    $res = imageinterlace($this->image, true);\n                }\n\n                $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\");\n                imagejpeg($this->image, $this->cacheFileName, $this->quality);\n\n                // Use JPEG optimize if defined\n                if ($this->jpegOptimizeCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->log($cmd);\n                    $this->log($res);\n                }\n                break;\n\n            case 'gif':\n                $this->Log(\"Saving image as GIF to cache.\");\n                imagegif($this->image, $this->cacheFileName);\n                break;\n\n            case 'webp':\n                $this->Log(\"Saving image as WEBP to cache using quality = {$this->quality}.\");\n                imagewebp($this->image, $this->cacheFileName, $this->quality);\n                break;\n\n            case 'png':\n            default:\n                $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\");\n\n                // Turn off alpha blending and set alpha flag\n                imagealphablending($this->image, false);\n                imagesavealpha($this->image, true);\n                imagepng($this->image, $this->cacheFileName, $this->compress);\n\n                // Use external program to process lossy PNG, if defined\n                $lossyEnabled = $this->pngLossy === true;\n                $lossySoftEnabled = $this->pngLossy === null;\n                $lossyActiveEnabled = $this->lossy === true;\n                if ($lossyEnabled || ($lossySoftEnabled && $lossyActiveEnabled)) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Lossy enabled: $lossyEnabled\");\n                        $this->log(\"Lossy soft enabled: $lossySoftEnabled\");\n                        $this->Log(\"Filesize before lossy optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngLossyCmd . \" $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to filter PNG, if defined\n                if ($this->pngFilterCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngFilterCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to deflate PNG, if defined\n                if ($this->pngDeflateCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n                break;\n        }\n\n        if ($this->verbose) {\n            clearstatcache();\n            $this->log(\"Saved image to cache.\");\n            $this->log(\" Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->ColorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert image from one colorpsace/color profile to sRGB without\n     * color profile.\n     *\n     * @param string  $src      of image.\n     * @param string  $dir      as base directory where images are.\n     * @param string  $cache    as base directory where to store images.\n     * @param string  $iccFile  filename of colorprofile.\n     * @param boolean $useCache or not, default to always use cache.\n     *\n     * @return string | boolean false if no conversion else the converted\n     *                          filename.\n     */\n    public function convert2sRGBColorSpace($src, $dir, $cache, $iccFile, $useCache = true)\n    {\n        if ($this->verbose) {\n            $this->log(\"# Converting image to sRGB colorspace.\");\n        }\n\n        if (!class_exists(\"Imagick\")) {\n            $this->log(\" Ignoring since Imagemagick is not installed.\");\n            return false;\n        }\n\n        // Prepare\n        $this->setSaveFolder($cache)\n             ->setSource($src, $dir)\n             ->generateFilename(null, false, 'srgb_');\n\n        // Check if the cached version is accurate.\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime  = filemtime($this->pathToImage);\n            $cacheTime = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                $this->log(\" Using cached version: \" . $this->cacheFileName);\n                return $this->cacheFileName;\n            }\n        }\n\n        // Only covert if cachedir is writable\n        if (is_writable($this->saveFolder)) {\n            // Load file and check if conversion is needed\n            $image      = new Imagick($this->pathToImage);\n            $colorspace = $image->getImageColorspace();\n            $this->log(\" Current colorspace: \" . $colorspace);\n\n            $profiles      = $image->getImageProfiles('*', false);\n            $hasICCProfile = (array_search('icc', $profiles) !== false);\n            $this->log(\" Has ICC color profile: \" . ($hasICCProfile ? \"YES\" : \"NO\"));\n\n            if ($colorspace != Imagick::COLORSPACE_SRGB || $hasICCProfile) {\n                $this->log(\" Converting to sRGB.\");\n\n                $sRGBicc = file_get_contents($iccFile);\n                $image->profileImage('icc', $sRGBicc);\n\n                $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);\n                $image->writeImage($this->cacheFileName);\n                return $this->cacheFileName;\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Create a hard link, as an alias, to the cached file.\n     *\n     * @param string $alias where to store the link,\n     *                      filename without extension.\n     *\n     * @return $this\n     */\n    public function linkToCacheFile($alias)\n    {\n        if ($alias === null) {\n            $this->log(\"Ignore creating alias.\");\n            return $this;\n        }\n\n        if (is_readable($alias)) {\n            unlink($alias);\n        }\n\n        $res = link($this->cacheFileName, $alias);\n\n        if ($res) {\n            $this->log(\"Created an alias as: $alias\");\n        } else {\n            $this->log(\"Failed to create the alias: $alias\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Add HTTP header for output together with image.\n     *\n     * @param string $type  the header type such as \"Cache-Control\"\n     * @param string $value the value to use\n     *\n     * @return void\n     */\n    public function addHTTPHeader($type, $value)\n    {\n        $this->HTTPHeader[$type] = $value;\n    }\n\n\n\n    /**\n     * Output image to browser using caching.\n     *\n     * @param string $file   to read and output, default is to\n     *                       use $this->cacheFileName\n     * @param string $format set to json to output file as json\n     *                       object with details\n     *\n     * @return void\n     */\n    public function output($file = null, $format = null)\n    {\n        if (is_null($file)) {\n            $file = $this->cacheFileName;\n        }\n\n        if (is_null($format)) {\n            $format = $this->outputFormat;\n        }\n\n        $this->log(\"### Output\");\n        $this->log(\"Output format is: $format\");\n\n        if (!$this->verbose && $format == 'json') {\n            header('Content-type: application/json');\n            echo $this->json($file);\n            exit;\n        } elseif ($format == 'ascii') {\n            header('Content-type: text/plain');\n            echo $this->ascii($file);\n            exit;\n        }\n\n        $this->log(\"Outputting image: $file\");\n\n        // Get image modification time\n        clearstatcache();\n        $lastModified = filemtime($file);\n        $lastModifiedFormat = \"D, d M Y H:i:s\";\n        $gmdate = gmdate($lastModifiedFormat, $lastModified);\n\n        if (!$this->verbose) {\n            $header = \"Last-Modified: $gmdate GMT\";\n            header($header);\n            $this->fastTrackCache->addHeader($header);\n            $this->fastTrackCache->setLastModified($lastModified);\n        }\n\n        foreach ($this->HTTPHeader as $key => $val) {\n            $header = \"$key: $val\";\n            header($header);\n            $this->fastTrackCache->addHeader($header);\n        }\n\n        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])\n            && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {\n\n            if ($this->verbose) {\n                $this->log(\"304 not modified\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            header(\"HTTP/1.0 304 Not Modified\");\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 304\");\n            }\n\n        } else {\n\n            $this->loadImageDetails($file);\n            $mime = $this->getMimeType();\n            $size = filesize($file);\n\n            if ($this->verbose) {\n                $this->log(\"Last-Modified: \" . $gmdate . \" GMT\");\n                $this->log(\"Content-type: \" . $mime);\n                $this->log(\"Content-length: \" . $size);\n                $this->verboseOutput();\n\n                if (is_null($this->verboseFileName)) {\n                    exit;\n                }\n            }\n\n            $header = \"Content-type: $mime\";\n            header($header);\n            $this->fastTrackCache->addHeaderOnOutput($header);\n\n            $header = \"Content-length: $size\";\n            header($header);\n            $this->fastTrackCache->addHeaderOnOutput($header);\n\n            $this->fastTrackCache->setSource($file);\n            $this->fastTrackCache->writeToCache();\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 200\");\n            }\n            readfile($file);\n        }\n\n        exit;\n    }\n\n\n\n    /**\n     * Create a JSON object from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string json-encoded representation of the image.\n     */\n    public function json($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $details = array();\n\n        clearstatcache();\n\n        $details['src']       = $this->imageSrc;\n        $lastModified         = filemtime($this->pathToImage);\n        $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $details['cache']       = basename($this->cacheFileName ?? \"\");\n        $lastModified           = filemtime($this->cacheFileName ?? \"\");\n        $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $this->load($file);\n\n        $details['filename']    = basename($file ?? \"\");\n        $details['mimeType']    = $this->getMimeType($this->fileType);\n        $details['width']       = $this->width;\n        $details['height']      = $this->height;\n        $details['aspectRatio'] = round($this->width / $this->height, 3);\n        $details['size']        = filesize($file ?? \"\");\n        $details['colors'] = $this->colorsTotal($this->image);\n        $details['includedFiles'] = count(get_included_files());\n        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . \" MB\" ;\n        $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . \" MB\";\n        $details['memoryLimit'] = ini_get('memory_limit');\n\n        if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {\n            $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . \"s\";\n        }\n\n        if ($details['mimeType'] == 'image/png') {\n            $details['pngType'] = $this->getPngTypeAsString(null, $file);\n        }\n\n        $options = null;\n        if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) {\n            $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;\n        }\n\n        return json_encode($details, $options);\n    }\n\n\n\n    /**\n     * Set options for creating ascii version of image.\n     *\n     * @param array $options empty to use default or set options to change.\n     *\n     * @return void.\n     */\n    public function setAsciiOptions($options = array())\n    {\n        $this->asciiOptions = $options;\n    }\n\n\n\n    /**\n     * Create an ASCII version from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string ASCII representation of the image.\n     */\n    public function ascii($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $asciiArt = new CAsciiArt();\n        $asciiArt->setOptions($this->asciiOptions);\n        return $asciiArt->createFromFile($file);\n    }\n\n\n\n    /**\n     * Log an event if verbose mode.\n     *\n     * @param string $message to log.\n     *\n     * @return this\n     */\n    public function log($message)\n    {\n        if ($this->verbose) {\n            $this->log[] = $message;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Do verbose output to a file.\n     *\n     * @param string $fileName where to write the verbose output.\n     *\n     * @return void\n     */\n    public function setVerboseToFile($fileName)\n    {\n        $this->log(\"Setting verbose output to file.\");\n        $this->verboseFileName = $fileName;\n    }\n\n\n\n    /**\n     * Do verbose output and print out the log and the actual images.\n     *\n     * @return void\n     */\n    private function verboseOutput()\n    {\n        $log = null;\n        $this->log(\"### Summary of verbose log\");\n        $this->log(\"As JSON: \\n\" . $this->json());\n        $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\");\n        $this->log(\"Memory limit: \" . ini_get('memory_limit'));\n\n        $included = get_included_files();\n        $this->log(\"Included files: \" . count($included));\n\n        foreach ($this->log as $val) {\n            if (is_array($val)) {\n                foreach ($val as $val1) {\n                    $log .= htmlentities($val1) . '<br/>';\n                }\n            } else {\n                $log .= htmlentities($val) . '<br/>';\n            }\n        }\n\n        if (!is_null($this->verboseFileName)) {\n            file_put_contents(\n                $this->verboseFileName,\n                str_replace(\"<br/>\", \"\\n\", $log)\n            );\n        } else {\n            echo <<<EOD\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n        }\n    }\n\n\n\n    /**\n     * Raise error, enables to implement a selection of error methods.\n     *\n     * @param string $message the error message to display.\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function raiseError($message)\n    {\n        throw new Exception($message);\n    }\n}\n"
  },
  {
    "path": "CRemoteImage.php",
    "content": "<?php\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CRemoteImage\n{\n    /**\n     * Path to cache files.\n     */\n    private $saveFolder = null;\n\n\n\n    /**\n     * Use cache or not.\n     */\n    private $useCache = true;\n\n\n\n    /**\n     * HTTP object to aid in download file.\n     */\n    private $http;\n\n\n\n    /**\n     * Status of the HTTP request.\n     */\n    private $status;\n\n\n\n    /**\n     * Defalt age for cached items 60*60*24*7.\n     */\n    private $defaultMaxAge = 604800;\n\n\n\n    /**\n     * Url of downloaded item.\n     */\n    private $url;\n\n\n\n    /**\n     * Base name of cache file for downloaded item and name of image.\n     */\n    private $fileName;\n\n\n\n    /**\n     * Filename for json-file with details of cached item.\n     */\n    private $fileJson;\n\n\n\n    /**\n     * Cache details loaded from file.\n     */\n    private $cache;\n\n\n\n    /**\n     * Get status of last HTTP request.\n     *\n     * @return int as status\n     */\n    public function getStatus()\n    {\n        return $this->status;\n    }\n\n\n\n    /**\n     * Get JSON details for cache item.\n     *\n     * @return array with json details on cache.\n     */\n    public function getDetails()\n    {\n        return $this->cache;\n    }\n\n\n\n    /**\n     * Set the path to the cache directory.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function setCache($path)\n    {\n        $this->saveFolder = rtrim($path, \"/\") . \"/\";\n        return $this;\n    }\n\n\n\n    /**\n     * Check if cache is writable or throw exception.\n     *\n     * @return $this\n     *\n     * @throws Exception if cahce folder is not writable.\n     */\n    public function isCacheWritable()\n    {\n        if (!is_writable($this->saveFolder)) {\n            throw new Exception(\"Cache folder is not writable for downloaded files.\");\n        }\n        return $this;\n    }\n\n\n\n    /**\n     * Decide if the cache should be used or not before trying to download\n     * a remote file.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields.\n     *\n     * @return $this\n     */\n    public function setHeaderFields()\n    {\n        $cimageVersion = \"CImage\";\n        if (defined(\"CIMAGE_USER_AGENT\")) {\n            $cimageVersion = CIMAGE_USER_AGENT;\n        }\n        \n        $this->http->setHeader(\"User-Agent\", \"$cimageVersion (PHP/\". phpversion() . \" cURL)\");\n        $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\");\n\n        if ($this->useCache) {\n            $this->http->setHeader(\"Cache-Control\", \"max-age=0\");\n        } else {\n            $this->http->setHeader(\"Cache-Control\", \"no-cache\");\n            $this->http->setHeader(\"Pragma\", \"no-cache\");\n        }\n    }\n\n\n\n    /**\n     * Save downloaded resource to cache.\n     *\n     * @return string as path to saved file or false if not saved.\n     */\n    public function save()\n    {\n        $this->cache = array();\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n        $type         = $this->http->getContentType();\n\n        $this->cache['Date']           = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']        = $maxAge;\n        $this->cache['Content-Type']   = $type;\n        $this->cache['Url']            = $this->url;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        // Save only if body is a valid image\n        $body = $this->http->getBody();\n        $img = imagecreatefromstring($body);\n\n        if ($img !== false) {\n            file_put_contents($this->fileName, $body);\n            file_put_contents($this->fileJson, json_encode($this->cache));\n            return $this->fileName;\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Got a 304 and updates cache with new age.\n     *\n     * @return string as path to cached file.\n     */\n    public function updateCacheDetails()\n    {\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n\n        $this->cache['Date']    = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age'] = $maxAge;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        file_put_contents($this->fileJson, json_encode($this->cache));\n        return $this->fileName;\n    }\n\n\n\n    /**\n     * Download a remote file and keep a cache of downloaded files.\n     *\n     * @param string $url a remote url.\n     *\n     * @throws Exception when status code does not match 200 or 304.\n     *\n     * @return string as path to downloaded file or false if failed.\n     */\n    public function download($url)\n    {\n        $this->http = new CHttpGet();\n        $this->url = $url;\n\n        // First check if the cache is valid and can be used\n        $this->loadCacheDetails();\n\n        if ($this->useCache) {\n            $src = $this->getCachedSource();\n            if ($src) {\n                $this->status = 1;\n                return $src;\n            }\n        }\n\n        // Do a HTTP request to download item\n        $this->setHeaderFields();\n        $this->http->setUrl($this->url);\n        $this->http->doGet();\n\n        $this->status = $this->http->getStatus();\n        if ($this->status === 200) {\n            $this->isCacheWritable();\n            return $this->save();\n        } elseif ($this->status === 304) {\n            $this->isCacheWritable();\n            return $this->updateCacheDetails();\n        }\n\n        throw new Exception(\"Unknown statuscode when downloading remote image: \" . $this->status);\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return $this\n     */\n    public function loadCacheDetails()\n    {\n        $cacheFile = md5($this->url);\n        $this->fileName = $this->saveFolder . $cacheFile;\n        $this->fileJson = $this->fileName . \".json\";\n        if (is_readable($this->fileJson)) {\n            $this->cache = json_decode(file_get_contents($this->fileJson), true);\n        }\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return string as the path ot the image file or false if no cache.\n     */\n    public function getCachedSource()\n    {\n        $imageExists = is_readable($this->fileName);\n\n        // Is cache valid?\n        $date   = strtotime($this->cache['Date']);\n        $maxAge = $this->cache['Max-Age'];\n        $now    = time();\n        \n        if ($imageExists && $date + $maxAge > $now) {\n            return $this->fileName;\n        }\n\n        // Prepare for a 304 if available\n        if ($imageExists && isset($this->cache['Last-Modified'])) {\n            $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']);\n        }\n\n        return false;\n    }\n}\n"
  },
  {
    "path": "CWhitelist.php",
    "content": "<?php\n/**\n * Act as whitelist (or blacklist).\n *\n */\nclass CWhitelist\n{\n    /**\n     * Array to contain the whitelist options.\n     */\n    private $whitelist = array();\n\n\n\n    /**\n     * Set the whitelist from an array of strings, each item in the\n     * whitelist should be a regexp without the surrounding / or #.\n     *\n     * @param array $whitelist with all valid options,\n     *                         default is to clear the whitelist.\n     *\n     * @return $this\n     */\n    public function set($whitelist = array())\n    {\n        if (!is_array($whitelist)) {\n            throw new Exception(\"Whitelist is not of a supported format.\");\n        }\n\n        $this->whitelist = $whitelist;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if item exists in the whitelist.\n     *\n     * @param string $item      string to check.\n     * @param array  $whitelist optional with all valid options, default is null.\n     *\n     * @return boolean true if item is in whitelist, else false.\n     */\n    public function check($item, $whitelist = null)\n    {\n        if ($whitelist !== null) {\n            $this->set($whitelist);\n        }\n        \n        if (empty($item) or empty($this->whitelist)) {\n            return false;\n        }\n        \n        foreach ($this->whitelist as $regexp) {\n            if (preg_match(\"#$regexp#\", $item)) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n}\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2012 - 2016 Mikael Roos, https://mikaelroos.se, mos@dbwebb.se\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "Image conversion on the fly using PHP\n=====================================\n\n[![Join the chat at https://gitter.im/mosbth/cimage](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mosbth/cimage?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n<!--\n[![Build Status](https://travis-ci.org/mosbth/cimage.svg?branch=master)](https://travis-ci.org/mosbth/cimage)\n[![Build Status](https://scrutinizer-ci.com/g/mosbth/cimage/badges/build.png?b=master)](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)\n-->\n\nAbout\n-------------------------------------\n\n<img src=\"https://cimage.se/cimage/imgd.php?src=example/kodim07.png&w=200&c=140,140,520,340&sharpen\"/>\n\n`CImage` is a PHP class enabling resizing of images through scaling, cropping and filtering effects -- using PHP GD. The script `img.php` uses `CImage` to enable server-side image processing utilizing caching and optimization of the processed images.\n\nServer-side image processing is a most useful tool for any web developer, `img.php` has an easy to use interface and its powerful when you integrate it with your website. Using it might decrease the time and effort for managing images and it might improve your workflow for creating content for websites.\n\nThis software is free and open source, licensed according MIT.\n\n\n\nDocumentation\n--------------------------------------\n\nRead full documentation at:\n<strike>http://dbwebb.se/opensource/cimage</strike>\n\nNew website is being setup at [cimage.se](https://cimage.se), to improve documentation (work is ongoing).\n\n\n\n\nRequirements\n--------------------------------------\n\n`CImage` and `img.php` supports GIF (with transparency), JPEG and PNG (8bit transparent, 24bit semi transparent) images. It requires PHP 5.3 and PHP GD. You optionally need the EXIF extension to support auto-rotation of JPEG-images. \n\n*Version v0.7.x will be the last version to support PHP 5.3. Coming version will require newer version of PHP.*\n\n\n\nInstallation\n--------------------------------------\n\nThere are several ways of installing. You either install the whole project which uses the autoloader to include the various files, or you install the all-included bundle that -- for convenience -- contains all code in one script.\n\n\n\n### Install source from GitHub \n\nThe [sourcode is available on GitHub](https://github.com/mosbth/cimage). Clone, fork or [download as zip](https://github.com/mosbth/cimage/archive/master.zip). \n\n**Latest stable version is v0.7.18 released 2016-08-09.**\n\nI prefer cloning like this. Do switch to the latest stable version.\n\n```bash\ngit clone git://github.com/mosbth/cimage.git\ncd cimage\ngit checkout v0.7.18\n```\n\nMake the cache-directory writable by the webserver.\n\n```bash\nchmod 777 cache\n```\n\n\n### Install all-included bundle \n\nThere are some all-included bundles of `img.php` that can be downloaded and used without dependency to the rest of the sourcecode.\n\n| Scriptname | Description | \n|------------|-------------|\n| `imgd.php` | Development mode with verbose error reporting and option `&verbose` enabled. | \n| `imgp.php` | Production mode logs all errors to file, giving server error 500 for bad usage, option `&verbose` disabled. | \n| `imgs.php` | Strict mode logs few errors to file, giving server error 500 for bad usage, option `&verbose` disabled. | \n\nDowload the version of your choice like this.\n\n```bash\nwget https://raw.githubusercontent.com/mosbth/cimage/v0.7.18/webroot/imgp.php\n```\n\nOpen up the file in your editor and edit the array `$config`. Ensure that the paths to the image directory and the cache directory matches your environment, or create an own config-file for the script.\n\n\n\n### Install from Packagist\n\nYou can install the package [`mos/cimage` from Packagist](https://packagist.org/packages/mos/cimage) using composer.\n\n\n\nUse cases \n--------------------------------------\n\nLets take some use cases to let you know when and how `img.php` might be useful.\n\n\n\n### Make a thumbnail \n\n<img src=\"https://cimage.se/cimage/imgd.php?src=example/kodim04.png&w=80&h=80&cf\">\n\nLets say you have a larger image and you want to make a smaller thumbnail of it with a size of 80x80 pixels. You simply take the image and add constraints on `width`, `height` and you use the resize strategy `crop-to-fit` to crops out the parts of the image that does not fit.\n\nTo produce such a thumbnail, create a link like this:\n\n> `img.php?src=kodim04.png&width=80&height=80&crop-to-fit`\n\n\n\n### Slightly complexer use case \n\nPerhaps you got an image from a friend. The image was taken with the iPhone and thus rotated. \n\n<img src=\"https://cimage.se/cimage/imgd.php?src=example/issue36/me-270.jpg&w=250\">\n\nThe original image is looking like this one, scaled down to a width of 250 pixels. \n\nSo, you need to rotate it and crop off some parts to make it intresting. \n\nTo show it off, I'll auto-rotate the image based on its EXIF-information, I will crop it to a thumbnail of 100x100 pixels and add a filter to make it greyscale finishing up with a sharpen effect. Just for the show I'll rotate the image 25 degrees - do not ask me why.\n\nLets call this *the URL-Photoshopper*. This is how the magic looks like. \n\n> `img.php?src=issue36/me-270.jpg&w=100&h=100&cf&aro`\n> `&rb=-25&a=8,30,30,38&f=grayscale&convolve=sharpen-alt`\n\n<img src=\"https://cimage.se/cimage/imgd.php?src=example/issue36/me-270.jpg&w=100&h=100&cf&aro&rb=-25&a=8,30,30,38&f=grayscale&convolve=sharpen-alt\">\n\nFor myself, I use `img.php` to put up all images on my website, it gives me the power of affecting the resulting images - without opening up a photo-editing application.\n\n\n\nGet going quickly \n--------------------------------------\n\n\n\n### Check out the test page \n\nTry it out by pointing your browser to the test file `webroot/test/test.php`. It will show some example images and you can review how they are created.\n\n\n\n### Process your first image \n\n<img src=\"https://cimage.se/cimage/imgd.php?src=example/kodim04.png&amp;w=w2&amp;a=40,0,50,0\" alt=''>\n\nTry it yourself by opening up an image in your browser. Start with \n\n> `webroot/img.php?src=kodim04.png` \n\nand try to resize it to a thumbnail by adding the options \n\n> `&width=100&height=100&crop-to-fit`\n\n\n\n### What does \"processing the image\" involves? \n\nAdd `&verbose` to the link to get a verbose output of what is happens during image processing. This is useful for developers and those who seek a deeper understanding on how it works behind the scene. \n\n\n\n### Check your system \n\nOpen up `webroot/check_system.php` if you are uncertain that your system has the right extensions loaded. \n\n\n\n\n### How does it work? \n\nReview the settings in `webroot/img_config.php` and check out `webroot/img.php` on how it uses `CImage`.\n\nThe programatic flow, just to get you oriented in the environment, is.\n\n1. Start in `img.php`.\n2. `img.php` reads configuration details from `img_config.php` (if the config-file is available).\n3. `img.php` reads and processes incoming `$_GET` arguments to prepare using `CImage`.\n4. `img.php` uses `CImage`.\n5. `CImage` processes, caches and outputs the image according to how its used. \n\nRead on to learn more on how to use `img.php`.\n\n\n\nBasic usage \n--------------------------------------\n\n\n\n### Select the source \n\nOpen an image through `img.php` by using its `src` attribute.\n\n> `img.php?src=kodim13.png`\n\nIt looks like this.\n\n<img src=\"https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=w1&save-as=jpg\">\n\nAll images are stored in a directory structure and you access them as:\n\n> `?src=dir1/dir2/image.png`\n\n\n\n### Resize using constraints on width and height \n\nCreate a thumbnail of the image by applying constraints on width and height, or one of them.\n\n| `&width=150`        | `&height=150`       | `&w=150&h=150`      |\n|---------------------|---------------------|---------------------|\n| <img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=150 alt=''> | <img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&h=150 alt=''> | <img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=150&h=150 alt=''> |\n\nBy setting `width`, `height` or both, the image gets resized to be *not larger* than the defined dimensions *and* keeping its original aspect ratio.\n\nThink of the constraints as a imaginary box where the image should fit. With `width=150` and `height=150` the box would have the dimension of 150x150px. A landscape image would fit in that box and its width would be 150px and its height depending on the aspect ratio, but for sure less than 150px. A portrait image would fit with a height of 150px and the width depending on the aspect ratio, but surely less than 150px.\n\n\n\n### Resize to fit a certain dimension \n\nCreating a thumbnail with a certain dimension of width and height, usually involves stretching or cropping the image to fit in the selected dimensions. Here is how you create a image that has the exact dimensions of 300x150 pixels, by either *stretching*, *cropping* or *fill to fit*.\n\n\n| What                | The image           |\n|---------------------|---------------------|\n| **Original.** The original image resized with a max width and max height.<br>`?w=300&h=150` | <img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=300&h=150 alt=''> |\n| **Stretch.** Stretch the image so that the resulting image has the defined width and height.<br>`?w=300&h=150&stretch` | <img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=300&h=150&stretch alt=''> |\n| **Crop to fit.** Keep the aspect ratio and crop out the parts of the image that does not fit.<br>`?w=300&h=150&crop-to-fit` | <img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=300&h=150&crop-to-fit alt=''> |\n| **Fill to fit.** Keep the aspect ratio and fill then blank space with a background color.<br>`?w=300&h=150&fill-to-fit=006600` | <img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=300&h=150&fill-to-fit=006600 alt=''> |\n\nLearn to crop your images, creative cropping can make wonderful images from appearingly useless originals.\n\nStretching might work, like in the above example where you can not really notice that the image is stretched. But usually, stretching is not that a good option since it distorts the ratio. Stretching a face may not turn out particularly well.\n\nFill to fit is useful when you have some image that must fit in a certain dimension and stretching nor cropping can do it. Carefully choose the background color to make a good resulting image. Choose the same background color as your website and no one will notice.\n\n\n\n### List of parameters\n\n`img.php` supports a lot of parameters. Combine the parameters to get the desired behavior and resulting image. For example, take the original image, resize it using width, aspect-ratio and crop-to-fit, apply a sharpen effect, save the image as JPEG using quality 30.\n\n> `img.php?src=kodim13.png&w=600&aspect-ratio=4`\n> `&crop-to-fit&sharpen&save-as=jpg&q=30`\n\n<img src=https://cimage.se/cimage/imgd.php?src=example/kodim13.png&w=600&aspect-ratio=4&crop-to-fit&sharpen&save-as=jpg&q=30 alt=''>\n\nHere is a list of all parameters that you can use together with `img.php`, grouped by its basic intent of usage. \n\n\n#### Mandatory options and debugging \n\nOption `src` is the only mandatory option. The options in this section is useful for debugging or deciding what version of the target image is used.\n\n| Parameter      | Explained                                    | \n|----------------|----------------------------------------------|\n| `src`          | Source image to use, mandatory. `src=img.png` or with subdirectory `src=dir/img.png`. |\n| `nc, no-cache` | Do not use the cached version, do all image processing and save a new image to cache. |\n| `so, skip-original`| Skip using the original image, always process image, create and use a cached version of the original image. |\n| `v, verbose`   | Do verbose output and print out a log what happens. Good for debugging, analyzing the process and inspecting how the image is being processed. |\n| `json`         | Output a JSON-representation of the image, useful for testing or optimizing when one wants to know the image dimensions, before using it. |\n| `pwd, password` | Use password to protect unauthorized usage. |\n\n\n\n#### Options for deciding width and height of target image\n\nThese options are all affecting the final dimensions, width and height, of the resulting image.\n\n| Parameter      | Explained                                    | \n|----------------|----------------------------------------------|\n| `h, height`    | `h=200` sets the width to be to max 200px. `h=25%` sets the height to max 25% of its original height. |\n| `w, width`     | `w=200` sets the height to be max 200px. `w=100%` sets the width to max 100% of its original width. |\n| `ar, aspect-ratio` | Control target aspect ratio. Use together with either height or width or alone to base calculations on original image dimensions. This setting is used to calculate the resulting dimension for the image. `w=160&aspect-ratio=1.6` results in a height of 100px. Use `ar=!1.6` to inverse the ratio, useful for portrait images, compared to landscape images. |\n| `dpr, device-pixel-ratio` | Default value is 1, set to 2 when you are delivering the image to a high density screen, `dpr=2` or `dpr=1.4`. Its a easy way to say the image should have larger dimensions. The resulting image will be twice as large (or 1.4 times), keeping its aspect ratio. |\n\n\n\n#### Options for resize strategy\n\nThese options affect strategy to use when resizing an image into a target image that has both width and height set.\n\n| Parameter      | Explained                                    | \n|----------------|----------------------------------------------|\n| `nr, no-ratio, stretch` | Do *not* keep aspect ratio when resizing and using both width & height constraints. Results in stretching the image, if needed, to fit in the resulting box. |\n| `cf, crop-to-fit`  | Set together with both `h` and `w` to make the image fit into dimensions, and crop out the rest of the image. |\n| `ff, fill-to-fit` | Set together with both `h` and `w` to make the image fit into dimensions, and fill the rest using a background color. You can optionally supply a background color as this `ff=00ff00`, or `ff=00ff007f` when using the alpha channel. |\n| `nu, no-upscale` | Avoid smaller images from being upscaled to larger ones. Combine with `stretch`, `crop-to-fit` or `fill-to-fit` to get the smaller image centered on a larger canvas. The requested dimension for the target image are thereby met. |\n\n\n\n#### Options for cropping part of image\n\nThese options enable to decide what part of image to crop out.\n\n| Parameter      | Explained                                    | \n|----------------|----------------------------------------------|\n| `c, crop`      | Crops an area from the original image, set `width`, `height`, `start_x` and `start_y` to define the area to crop, for example `crop=100,100,10,10` (`crop=width,height,start_x,start_y`). Left top corner is 0, 0. You can use `left`, `right` or `center` when setting `start_x`. You may use `top`, `bottom` or `center` when setting `start_y`. |\n| `a, area`      | Define the area of the image to work with. Set `area=10,10,10,10` (`top`, `right`, `bottom`, `left`) to crop out the 10% of the outermost area. It works like an offset to define the part of the image you want to process. Its an alternative of using `crop`. |\n\n\n\n#### General processing options\n\nThese options are general options affecting processing.\n\n| Parameter      | Explained                                    | \n|----------------|----------------------------------------------|\n| `bgc, bg-color` | Set the backgroundcolor to use (if its needed). Use six hex digits as `bgc=00ff00` and 8 digits when using the alpha channel, as this `bgc=00ff007f`. The alpha value can be between 00 and 7f. |\n\n\n\n#### Processing of image before resizing \n\nThis option are executed *before* the image is resized.\n\n| Parameter      | Explained                                    | \n|----------------|----------------------------------------------|\n| `s, scale`     | Scale the image to a size proportional to a percentage of its original size, `scale=25` makes an image 25% of its original size and `size=200` doubles up the image size. Scale is applied before resizing and has no impact of the target width and height. |\n| `rb, rotate-before` | Rotate the image before its processed, send the angle as parameter `rb=45`. |\n| `aro, auto-rotate`  | Auto rotate the image based on EXIF information (useful when using images from smartphones). |\n\n\n\n#### Processing of image after resizing \n\nThese options are executed *after* the image is resized.\n\n| Parameter      | Explained                                    |\n|----------------|----------------------------------------------|\n| `ra, rotate-after`<br>`r, rotate` | Rotate the image after its processed, send the angle as parameter `ra=45`. |\n| `sharpen`            | Appy a convolution filter that sharpens the image.       |\n| `emboss`             | Appy a convolution filter with an emboss effect.         |\n| `blur`               | Appy a convolution filter with a blur effect.            |\n| `convolve`           | Appy custom convolution filter as a 3x3 matrix, a divisor and offset, `convolve=0,-1,0,-1,5,-1,0,-1,0,1,0` sharpens the image. |\n| `convolve`           | Use predefined convolution expression as `convolve=sharpen-alt` or a serie of convolutions as `convolve=draw,mean,motion`. These are supported out of the box: `lighten`, `darken`, `sharpen`, `sharpen-alt`, `emboss`, `emboss-alt`, `blur`, `gblur`, `edge`, `edge-alt`, `draw`, `mean`, `motion`. Add your own, or overwrite existing, in `img_config.php`. |\n| `f, filter`          | Apply filter to image, `f=colorize,0,255,0,0` makes image more green. Supports all filters as defined in [PHP GD `imagefilter()`](http://php.net/manual/en/function.imagefilter.php). |\n| `f0, f1-f9`    | Same as `filter`, just add more filters. Applied in order `f`, `f0-f9`.  |\n| `sc, shortcut` | Save longer expressions in `img_config.php`. One place to change your favorite processing options, use as `sc=sepia` which is a shortcut for `&f=grayscale&f0=brightness,-10&f1=contrast,-20`<br>`&f2=colorize,120,60,0,0&sharpen`. |\n\n\n\n#### Saving image, affecting quality and file size \n\nOptions for saving the target image.\n\n| Parameter      | Explained                                    | \n|----------------|----------------------------------------------|\n| `q, quality`   | Quality affects lossy compression and file size for JPEG images by setting the quality between 1-100, default is 60.  Quality only affects JPEG. |\n| `co, compress` | For PNG images it defines the compression algorithm, values can be 0-9, default is defined by PHP GD. Compress only affects PNG. |\n| `p, palette`   | Create a palette version of the image with up to 256 colors. |\n| `sa, save-as`  | Save resulting image as JPEG, PNG or GIF, for example `?src=river.png&save-as=gif`. |\n| `alias`        | Save resulting image as a copy in the alias-directory. |\n\nCarry on reading to view examples on how to use and combine the parameters to achieve desired effects and target images.\n\n\n\nThe configuration settings in `_config.php`\n--------------------------------------\n\nThere are several configurations settings that can be used to change the behaviour of `img.php`. Here is an overview, listed as they appear in the default config-file.\n\n| Setting                 | Explained                                    | \n|-------------------------|----------------------------------------------|\n| `mode`                  | Set to \"development\", \"production\" or \"strict\" to match the mode of your environment. It mainly affects the error reporting and if option `verbose` is enabled or not. |\n| `autoloader`            | Path to the file containing the autoloader. | \n| `image_path`            | Path to the directory-structure containing the images. |  \n| `cache_path`            | Path to the directory where all the cache-files are stored. |  \n| `alias_path`            | Path to where the alias, or copy, of the images are stored. |  \n| `password`              | Set the password to use. |  \n| `password_always`       | Always require the use of password and match with `password`. |  \n| `remote_allow`          | Allow remote download of images when `src=http://example.com/img.jpg`. |  \n| `remote_pattern`        | Pattern (regexp) to detect if a file is remote or not. |  \n| `valid_filename`        | A regular expression to test if a `src` filename is valid or not. |  \n| `valid_aliasname`       | A regular expression to test if a `alias` filename is valid or not. |  |  \n| `img_path_constraint`   | Check that the target image is in a true subdirectory of `img-path` (disables symbolic linking to another part of the filesystem. |  \n| `default_timezone`      | Use to set the timezone if its not already set. |  \n| `max_width`             | Maximal width of the target image. Fails for larger values. | \n| `max_height`            | Maximal height of the target image. Fails for larger values. | \n| `background_color`      | Specify a default background color and overwrite the one proposed by `CImage`. |  \n| `png_filter`            | Use (or not) an external command for filter PNG images. |  \n| `png_filter_cmd`        | Path and options to the actual external command. |  \n| `png_deflate`           | Use (or not) an external command for deflating PNG images. |  \n| `png_deflate_cmd`       | Path and options to the actual external command. |  \n| `jpeg_optimize`         | Use (or not) an external command for optimizing JPEG images. |  \n| `jpeg_optimize_cmd`     | Path and options to the actual external command. |  \n| `convolution_constant`  | Constants for own defined convolution expressions. |  \n| `allow_hotlinking`      | Allow or disallow hotlinking7leeching of images. |  \n| `hotlinking_whitelist`  | Array of regular expressions that allow hotlinking (if hotlinking is disabled). |  \n| `shortcut`              | Define own shortcuts for more advanced combination of options to `img.php`. |  \n| `size_constant`         | Create an array with constant values to be used instead of `width` and `height`. |  \n| `aspect_ratio_constant` | Create an array for constant values to be used with option 'aspect-ratio`. |  \n\nConsult the file `webroot/img-config.php` for a complete list together with the default values for each configuration setting. There is an [appendix where you can see the default config-file](#img-config).\n\n\n\n### Create and name the config file \n\nThe file `img.php` looks for the config-file `img_config.php`, and uses it if its found. The three files where everything is included -- `imgd.php`, `imgp.php` and `imgs.php` -- includes an empty `$config`-array which can be overridden by saving a config-file in the same directory. If the script is `imgp.php` then name the config-file `imgp_config.php` and it will find it and use those settings. \n\n\n\nDebugging image processing \n--------------------------------------\n\nYou can visualize what happens during image processing by adding the `v, verbose` parameter. It will then display the resulting image together with a verbose output on what is actually happening behind the scene.\n\n<img src=\"http://dbwebb.se/image/snapshot/CImage_verbose_output.jpg?w=w2&q=60&sharpen\">\n\nThis can be most useful for debugging and to understand what actually happen.\n\nThe parameter `nc, no-cache` ignores the cached item and will always create a new cached item.\n\nThe parameter `so, skip-original` skips the original image, even it that is a best fit. As a result a cached image is created and displayed.\n\n\n\nA JSON representation of the image\n--------------------------------------\n\nYou can ge a JSON representation of the image by adding the option `json`. This can be useful if you need to know the actual dimension of the image. \n\nFor example, the following image is created like this:\n\n> `&w=300&save-as=jpg`\n\n<img src=\"https://cimage.se/cimage/imgd.php?src=example/kodim24.png&w=300&save-as=jpg\" alt=''>\n\nIts JSON-representation is retrieved like this:\n\n> `&w=300&save-as=jpg&json`\n\nWhich gives the following result.\n\n```php\n{  \n    \"src\":\"kodim24.png\",\n    \"srcGmdate\":\"Wed, 12 Feb 2014 13:46:19\",\n    \"cache\":\"_._kodim24_300_200_q60.jpg\",\n    \"cacheGmdate\":\"Sat, 06 Dec 2014 14:09:50\",\n    \"filename\":\"_._kodim24_300_200_q60.jpg\",\n    \"width\":300,\n    \"height\":200,\n    \"aspectRatio\":1.5,\n    \"size\":11008,\n    \"colors\":25751\n}\n```\n\nI'll use this feature for ease testing of `img.php` and `CImage`. But the feature can also be useful when one really want complete control over the resulting dimension of an image.\n\n\n\n\nImplications and considerations \n--------------------------------------\n\nHere are some thoughts when applying `img.php` on a live system.\n\n\n\n### Select the proper mode \n\nSelect the proper mode for `img.php`. Set it to \"strict\" or \"production\" to prevent outsiders to get information about your system. Use only \"development\" for internal use since its quite verbose in its nature of error reporting. \n\n\n\n### Put the installation directory outside web root \n\nEdit the config file to put the installation directory -- and the cache directory -- outside of the web root. Best practice would be to store the installation directory and cache, outside of the web root. The only thing needed in the web root is `img.php` and `img_config.php` (if used) which can be placed, for example, in `/img/img.php` or just as `/img.php`.\n\n\n\n### Friendly urls through `.htaccess` \n\nUse `.htaccess`and rewrite rules (Apache) to get friendly image urls. Put `img.php` in the `/img` directory. Put the file `.htaccess` in the web root.\n\n**.htaccess for `img.php`.**\n\n```php\n#\n# Rewrite to have friendly urls to img.php, edit it to suite your environment.\n#\n# The example is set up as following.\n#\n#  img                 A directory where all images are stored\n#  img/me.jpg          Access a image as usually.\n#  img/img.php         This is where I choose to place img.php (and img_config.php).\n#  image/me.jpg        Access a image though img.php using htaccess rewrite.\n#  image/me.jpg?w=300  Using options to img.php.\n# \n# Subdirectories also work.\n#  img/me/me.jpg          Direct access to the image.\n#  image/me/me.jpg        Accessed through img.php.\n#  image/me/me.jpg?w=300  Using options to img.php.\n#\nRewriteRule ^image/(.*)$        img/img.php?src=$1 [QSA,NC,L]\n```\n\nYou can now access all images through either `/image/car.jpg` (which uses `img.php`) or as usual through `/img/car.jpg` without passing through `img.php`. You send the arguments as usual.\n\n> `/image/car.jpg?w=300&sharpen`\n\nOr a image that resides in a subdirectory.\n\n> `/image/all-cars/car.jpg?w=300&sharpen`\n\nThe result is good readable urls to your images. Its easy for the search engine to track and you can use the directory structure already existing in `/img`. Just like one wants to have it.\n\n\n\n### Monitor cache size\n\nThere is a utility `cache.bash` included for monitoring the size of the cache-directory. It generates an output like this.\n\n```bash\n$ ./cache.bash\nUsage: ./cache.bash [cache-dir]   \n\n$ ./cache.bash cache                         \nTotal size:       27M                                            \nNumber of files:  225                                            \n                                                                 \nTop-5 largest files:                                             \n1032    cache/_._kodim08_768_512_q60convolvesharpen.png          \n960     cache/_._kodim08_768_512_q60convolveemboss.png           \n932     cache/_._kodim08_768_512_q60_rb45.png                    \n932     cache/_._kodim08_768_512_q60_ra45.png                    \n856     cache/_._kodim08_768_512_q60_rb90.png                    \n                                                                 \nLast-5 created files:                                            \n2014-11-26 16:51 cache/_._kodim08_768_512_q60convolvelighten.png \n2014-11-26 16:51 cache/_._kodim08_768_512_q60convolveblur.png    \n2014-11-26 16:48 cache/_._kodim08_400_267_q60convolvesharpen.png \n2014-11-26 16:48 cache/_._kodim08_400_267_q60convolvelighten.png \n2014-11-26 16:48 cache/_._kodim08_400_267_q60convolveemboss.png  \n                                                                 \nLast-5 accessed files:                                           \n2014-11-27 16:12 _._wider_900_581_q60.jpg                        \n2014-11-27 16:12 _._wider_750_484_q60.jpg                        \n2014-11-27 16:12 _._wider_640_413_q60.jpg                        \n2014-11-27 16:12 _._wider_640_200_c640-200-0-100_q60.jpg         \n2014-11-27 16:12 _._wider_600_387_q60.jpg                        \n```\n\nUse it as a base if you feel the need to monitor the size och the cache-directory.\n\n\n\n### Read-only cache\n\nThe cache directory need to be writable for `img.php` to create new files. But its possible to first create all cache-files and then set the directory to be read-only. This will give you a way of shutting of `img.php` from creating new cache files. `img.php` will then continue to work for all images having a cached version but will fail if someone tries to create a new, not previously cached, version of the image.\n\n\n\n### Post-processing with external tools\n\nYou can use external tools to post-process the images to optimize the file size. This option is available for JPEG and for PNG images. Post-processing is disabled by default, edit `img_config.php` to enable it.\n\nIt takes additional time to do post processing, it can take up to a couple of seconds. This is processing to create the cached image, thereafter the cached version will be used and no more post processing needs to be done.\n\nThese tools for post processing is not a part of `CImage` and `img.php`, you need to download and install them separately. I use them myself on my system to get an optimal file size.\n\n\n\n### Allowing remote download of images\n\nYou can allow `img.php` to download remote images. That can be enabled in the config-file. However, before doing so, consider the implications on allowing anyone to download a file, hopefully an image, to your server and then the possibility to access it through the webserver.\n\nThat sounds scary. It should.\n\nFor my own sake I will use it like this, since I consider it a most useful feature.\n\n* Create a special version of `img.php` that has remote download allowed, hide it from public usage.\n* Always use a password.\n* Download and process the image and save it as an `alias`.\n* Integrate the image into your webpage and use the image in the alias directory.\n\nThis is an easy way to quickly download a remote image, process and share it.\n\nSo, its a scary feature and I might regret I did put it in. Still, its disabled by default and you enable it on your own risk. I have tried to make it as secure as I can, but I might have missed something. I will run it on my own system so I guess I'll find out how secure it is.\n\n\n\nCommunity \n--------------------------------------\n\nThere is a Swedish forum where you can ask questions, even in English. The forum is a general forum for education in web development, it is not specific for this software. \n\nAsk questions on `CImage` and `img.php` [in the PHP sub forum]([BASEURL]forum/viewforum.php?f=12).\n\nOr ask it on GitHub by creating an issue -- that would be the best place to ask questions.\n\nOr if you fancy irc.\n\n* `irc://irc.bsnet.se/#db-o-webb`\n* `irc://irc.freenode.net/#dbwebb`\n\n\n\nTrouble- and feature requests \n--------------------------------------\n\nUse [GitHub to report issues](https://github.com/mosbth/cimage/issues). Always include the following.\n\n1. Describe very shortly: What are you trying to achieve, what happens, what did you expect.\n2. Parameter list used for `img.php`.\n3. The image used.\n\nIf you request a feature, describe its usage and argument for why you think it fits into `CImage` and `img.php`.\n\nFeel free to fork, clone and create pull requests.\n\n\n\n\n```\n .\n..:  Copyright 2012-2015 by Mikael Roos (me@mikaelroos.se)\n```\n"
  },
  {
    "path": "REVISION.md",
    "content": "Revision history\n=====================================\n\n<!--\n[![Build Status](https://travis-ci.org/mosbth/cimage.svg?branch=master)](https://travis-ci.org/mosbth/cimage)\n[![Build Status](https://scrutinizer-ci.com/g/mosbth/cimage/badges/build.png?b=master)](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)\n--->\n\nv0.8.6 (2023-10-27)\n-------------------------------------\n\n* Fix deprecation notice on \"Creation of dynamic property\" for PHP 8.2.\n\n\n\nv0.8.5 (2022-11-17)\n-------------------------------------\n\n* Enable configuration fix for solving Windows 2 WSL2 issue with is_readable/is_writable #189.\n* Update CHttpGet.php for php 8.1 deprecated notice #188.\n* Remove build status from README (since it is not up to date).\n\n\n\nv0.8.4 (2022-05-30)\n-------------------------------------\n\n* Support PHP 8.1 and remove (more) deprecated messages when run in in development mode.\n\n\n\nv0.8.3 (2022-05-24)\n-------------------------------------\n\n* Support PHP 8.1 and remove deprecated messages when run in in development mode.\n* Generate prebuilt all include files for various settings\n* Fix deprecated for PHP 8.1\n* Fix deprecated for PHP 8.1\n* Add php version as output in verbose mode\n* Add PHP 81 as test environment\n\n\n\nv0.8.2 (2021-10-27)\n-------------------------------------\n\n* Remove bad configuration.\n\n\n\nv0.8.1 (2020-06-08)\n-------------------------------------\n\n* Updated version number in define.php.\n\n\n\nv0.8.0 (2020-06-08)\n-------------------------------------\n\n* Enable to set JPEG image as interlaced, implement feature #177.\n* Add function getValue() to read from querystring.\n* Set PHP 7.0 as precondition (to prepare to update the codebase).\n\n\n\nv0.7.23 (2020-05-06)\n-------------------------------------\n\n* Fix error in composer.json\n\n\n\nv0.7.22 (2020-05-06)\n-------------------------------------\n\n* Update composer.json and move ext-gd from required to suggested to ease installation where cli does not have all extensions installed.\n\n\n\nv0.7.21 (2020-01-15)\n-------------------------------------\n\n* Support PHP 7.4, some minor fixes with notices.\n\n\nv0.7.20 (2017-11-06)\n-------------------------------------\n\n* Remove webroot/img/{round8.PNG,wider.JPEG,wider.JPG} to avoid unzip warning message when installing with composer.\n* Adding docker-compose.yml #169.\n\n\nv0.7.19 (2017-03-31)\n-------------------------------------\n\n* Move exception handler from functions.php to img.php #166.\n* Correct XSS injection in `check_system.php`.\n* Composer suggests ext-imagick and ext-curl.\n\n\nv0.7.18 (2016-08-09)\n-------------------------------------\n\n* Made `&lossless` a requirement to not use the original image.\n\n\nv0.7.17 (2016-08-09)\n-------------------------------------\n\n* Made `&lossless` part of the generated cache filename.\n\n\nv0.7.16 (2016-08-09)\n-------------------------------------\n\n* Fix default mode to be production.\n* Added pngquant as extra postprocessing utility for PNG-images, #154.\n* Bug `&status` wrong variable name for fast track cache.\n\n\nv0.7.15 (2016-08-09)\n-------------------------------------\n\n* Added the [Lenna/Lena sample image](http://www.cs.cmu.edu/~chuck/lennapg/) as tif and created a png, jpeg and webp version using Imagick convert `convert lena.tif lena.{png,jpg,webp}`, #152.\n* Limited and basic support for WEBP format, se #132.\n\n\nv0.7.14 (2016-08-08)\n-------------------------------------\n\n* Re-add removed cache directory.\n* Make fast track cache disabled by default in the config file.\n\n\nv0.7.13 (2016-08-08)\n-------------------------------------\n\n* Moved functions from img.php to `functions.php`.\n* Added function `trace()` to measure speed and memory consumption, only for development.\n* Added fast cache #149.\n* Added `imgf.php` as shortcut to check for fast cache, before loading `img.php` as usual, adding `imgf_config.php` as symlink to `img_config.php`.\n* Created `defines.php` and moved definition av version there.\n* Fixed images in README, #148.\n* Initiated dependency injection to `CImage`, class names can be set in config file and will be injected to `CImage` from `img.php`. Not implemented for all classes. #151.\n* Enabled debug mode to make it easier to trace what actually happens while processing the image, #150.\n\n\nv0.7.12 (2016-06-01)\n-------------------------------------\n\n* Fixed to correctly display image when using a resize strategy without height or width.\n* Fixed background color for option `no-upscale`, #144.\n\n\nv0.7.11 (2016-04-18)\n-------------------------------------\n\n* Add option for `skip_original` to config file to always skip original, #118.\n\n\nv0.7.10 (2016-04-01)\n-------------------------------------\n\n* Add backup option for images `src-alt`, #141.\n* Add require of ext-gd in composer.json, #133.\n* Fix strict mode only reporting 404 when failure, #127.\n\n\nv0.7.9 (2015-12-07)\n-------------------------------------\n\n* Strict mode only reporting 404 when failure, #127.\n* Added correct CImage version to remote agent string, #131.\n* Adding CCache to improve cache handling of caching for dummy, remote and srgb. #130.\n\n\nv0.7.8 (2015-12-06)\n-------------------------------------\n\n* HTTP error messages now 403, 404 and 500 as in #128 and #127.\n* More examples on dealing with cache through bash `bin/cache.bash`, #129.\n* Added conversion to sRGB using option `?srgb`. #120.\n* Added Gitter badge to README, #126.\n* Fix proper download url in README, #125.\n* Change path in `webroot/htaccess` to make it work in current environment.\n\n\nv0.7.7 (2015-10-21)\n-------------------------------------\n\n* One can now add a HTTP header for Cache-Control in the config file, #109.\n* Added hook in img,php before CImage is called, #123.\n* Added configuration for default jpeg quality and png compression in the config file, #107.\n* Strip comments and whitespace in imgs.php, #115.\n* Bundle imgs.php did not have the correct mode.\n* Adding option &status to get an overview of the installed on configured utilities, #116.\n* Bug, all files saved as png-files, when not saving as specific file.\n* Removed saving filename extension for alias images.\n* Added option to decide if resample or resize when copying images internally. `&no-resample` makes resize, instead of resample as is default.\n* Verbose now correctly states if transparent color is detected.\n* Compare-tool now supports 6 images.\n* Added option for dark background in the compare-tool.\n* Removed that source png-files, containing less than 255 colors, is always saved as palette images since this migth depend on processing of the image.\n* Adding save-as as part of the generated cache filename, #121.\n* Add extra fields to json-response, #114.\n* Add header for Content-Length, #111.\n* Add check for postprocessing tools in path in `webroot/check_system.php`, #104.\n\n\nv0.7.6 (2015-10-18)\n-------------------------------------\n\n* Adding testpage for dummy images `webroot/test/test_issue101-dummy.php`.\n* Adding width and height when creating dummy image.\n\n\nv0.7.5 (2015-10-18)\n-------------------------------------\n\n* Adding feature for creating dummy images `src=dummy`, #101.\n* Add png compression to generated cache filename, fix #103.\n* Removed file prefix from storing images in cache, breaking filenamestructure for cache images.\n* Code cleaning in `CImage.php`.\n\n\nv0.7.4 (2015-09-15)\n-------------------------------------\n\n* Add CAsciiArt.php to composer for autoloading, fix #102.\n* Generate filename with filters, does not work on Windows, fix #100.\n\n\nv0.7.3 (2015-09-01)\n-------------------------------------\n\n* Support output of ascii images, #67.\n\n\nv0.7.2 (2015-08-17)\n-------------------------------------\n\n* Allow space in remote filenames, fix #98.\n\n\nv0.7.1 (2015-07-25)\n-------------------------------------\n\n* Support for password hashes using `text`, `md5` and `hash`, fix #77.\n* Using `CWhitelist` for checking hotlinking to images, fix #88.\n* Added mode for `test` which enables logging verbose mode to file, fix #97.\n* Improved codestyle and added `phpcs.xml` to start using phpcs to check code style, fix #95.\n* Adding `composer.json` for publishing on packagist.\n* Add permalink to setup for comparing images with `webroot/compare/compare.php`, fix #92.\n* Allow space in filename by using `urlencode()` and allow space as valid filenam character. fix #91.\n* Support redirections for remote images, fix #87, fix #90.\n* Improving usage of Travis and Scrutinizer.\n* Naming cache-file using md5 for remote images, fix #86.\n* Loading images without depending on filename extension, fix #85.\n* Adding unittest with phpunit #84, fix #13\n* Adding support for whitelist of remote hostnames, #84\n* Adding phpdoc, fix #48.\n* Adding travis, fix #15.\n* Adding scrutinizer, fix #57.\n\n\nv0.7.0 (2015-02-10)\n-------------------------------------\n\n* Always use password, setting in img_config.php, fix #78.\n* Resize gif keeping transparency #81.\n* Now returns statuscode 500 when something fails #55.\n* Three different modes: strict, production, development #44.\n* Three files for all-in-one `imgs.php`, `imgp.php`, `imgd.php` #73.\n* Change name of script all-in-one to `webroot/imgs.php` #73.\n* Combine all code into one singel script, `webroot/img_single.php` #73.\n* Disallow hotlinking/leeching by configuration #46.\n* Alias-name is without extension #47.\n* Option `alias` now requires `password` to work #47.\n* Support for option `password, pwd` to protect usage of `alias` and remote download.\n* Added support for option `alias` that creates a link to a cached version  of the image #47.\n* Create cache directory for remote download if it does not exists.\n* Cleaned up `img_config.php` and introduced default values for almost all options #72.\n\n\nv0.6.2 (2015-01-14)\n-------------------------------------\n\n* Added support for download of remote images #43.\n* Added autoloader.\n\n\nv0.6.1 (2015-01-08)\n-------------------------------------\n\n* Adding compare-page for comparing images. Issue #20.\n* Added option `no-upscale, nu` as resizing strategy to decline upscaling of smaller images. Fix #61.\n* Minor change in `CImage::resize()`, crop now does imagecopy without resamling.\n* Correcting internal details for save-as and response json which indicated wrong colors. Fix #62.\n* Fixed fill-to-fit that failed when using aspect-ratio. Fix #52.\n* JSON returns correct values for resulting image. Fix #58.\n* Corrected behaviour for skip-original. Fix #60.\n\n\nv0.6 (2014-12-06)\n-------------------------------------\n\n* Rewrote and added documentation.\n* Moved conolution expressesion from `img_config.php` to `CImage`.\n* Minor cleaning of properties in `CImage`. Fix #23.\n* Adding `webroot/htaccess` to show off how friendly urls can be created for `img.php`. Fix #45.\n* Added option `fill-to-fit, ff`. Fix #38.\n* Added option `shortcut, sc` to enable configuration of complex expressions. Fix #2.\n* Added support for custom convolutions. Fix #49.\n* Restructured testprograms. Fix #41.\n* Corrected json on PHP 5.3. Fix #42.\n* Improving template for tests in `webroot/tests` when testing out #40.\n* Adding testcase for #40.\n* Adding option `convolve` taking comma-separated list of 11 float-values, wraps and exposes `imageconvoluttion()`. #4\n* Adding option `dpr, device-pixel-ratio` which defaults to 1. Set to 2 to get a twice as large image. Useful for Retina displays. Basically a shortcut to enlarge the image.\n* Adding utility `cache.bash` to ease gathering stats on cache usage. #21\n* Cache-directory can now be readonly and serve all cached files, still failing when need to save files. #5\n* Cache now uses same file extension as original image #37.\n* Can output image as json format using `json` #11.\n\n\nv0.5.3 (2014-11-21)\n-------------------------------------\n\n* Support filenames of uppercase JPEG, JPG, PNG and GIF, as proposed in #37.\n* Changing `CImage::output()` as proposed in #37.\n* Adding security check that image filename is always below the path `image_path` as specified in `img_config.php` #37.\n* Adding configuration item in `img_config.php` for setting valid characters in image filename.\n* Moving `webroot/test*` into directory `webroot/test`.\n* `webroot/check_system.php` now outputs if extension for exif is loaded.\n* Broke API when `initDimensions()` split into two methods, new `initDimensions()` and `loadImageDetails()`.\n* Added `autoRotate, aro` to auto rotate image based on EXIF information.\n* Added `bgColor, bgc` to use as backgroundcolor when needing a filler color, for example rotate 45.\n* Added `rotateBefore, rb` to rotate image a certain angle before processing.\n* Added `rotateAfter, ra` to rotate image a certain angle after processing.\n* Cleaned up code formatting, removed trailing spaces.\n* Removed @ from opening images, better to display correct warning when failing #34, but put it back again.\n* Setting gd.jpeg_ignore_warning to true as default #34.\n* `webroot/check_system.php` now outputs version of PHP and GD.\n* #32 correctly send 404 header when serving an error message.\n* Trying to verify issue #29, but can not.\n* Adding structure for testprograms together with, use `webroot/test_issue29.php` as sample.\n* Improving code formatting.\n* Moving parts of verbose output from img.php to CImage.php.\n\n\nv0.5.2 (2014-04-01)\n-------------------------------------\n\n* Correcting issue #26 providing error message when not using postprocessing.\n* Correcting issue #27 warning of default timezone.\n* Removed default $config options in `img.php`, was not used, all configuration should be in `img_config.php`.\n* Verified known bug - sharpen acts as blur in PHP 5.5.9 and 5.5.10 #28\n\n\nv0.5.1 (2014-02-12)\n-------------------------------------\n\n* Display image in README-file.\n* Create an empty `cache` directory as part of repo.\n\n\nv0.5 (2014-02-12)\n-------------------------------------\n\n* Change constant name `CImage::PNG_QUALITY_DEFAULT` to `CImage::PNG_COMPRESSION_DEFAULT`.\n* Split JPEG quality and PNG compression, `CImage->quality` and `CImage->compression`\n* Changed `img.php` parameter name `d, deflate` to `co, compress`.\n* Separating configuration issues from `img.php` to `img_config.php`.\n* Format code according to PSR-2.\n* Disabled post-processing JPEG and PNG as default.\n* This version is supporting PHP 5.3, later versions will require 5.5 or later.\n* Using GitHub issue tracking for feature requests and planning.\n* Rewrote [the manual](http://dbwebb.se/opensource/cimage).\n* Created directory `webroot` and moved some files there.\n\n\nv0.4.1 (2014-01-27)\n-------------------------------------\n\n* Changed => to == on Modified-Since.\n* Always send Last-Modified-Header.\n* Added `htmlentities()` to verbose output.\n* Fixed support for jpeg, not only jpg.\n* Fixed crop whole image by setting crop=0,0,0,0\n* Use negative values for crop width & height to base calulation on original width/height and withdraw selected amount.\n* Correcting jpeg when setting quality.\n* Removed obsolete reference to `$newName` in `CImage::__construct()` (issue 1).\n\n\nv0.4 (2013-10-08)\n-------------------------------------\n\n* Improved support for pre-defined sizes.\n* Adding grid column size as predefined size, c1-c24 for a 24 column grid. Configure in `img.php`.\n* Corrected error on naming cache-files using subdir.\n* Corrected calculation error on width & height for crop-to-fit.\n* Adding effects for sharpen, emboss and blur through imageconvolution using matrixes.\n* crop-to-fit, add parameter for offset x and y to enable to define which area is the, implemented as area.\n* Support for resizing opaque images.\n* Center of the image from which the crop is done. Improved usage of area to crop.\n* Added support for % in width & height.\n* Added aspect-ratio.\n* Added scale.\n* Quality for PNG images is now knows as deflate.\n* Added palette to create images with max 256 colors.\n* Added usage of all parameters to README.md\n* Added documentation here http://dbwebb.se/opensource/cimage\n* Adding `.gitignore`\n* Re-adding `cache` directory\n\n\nv0.3 (2012-10-02)\n-------------------------------------\n\n* Added crop. Can crop a area (`width`, `height`, `start_x`, `start_y`) from the original\nimage.\n* Corrected to make the 304 Not Modified header work.\n* Predefined sizes can be configured for width in `img.php`.\n* Corrected to make crop work with width or height in combination with crop-to-fit.\n\n\nv0.2 (2012-05-09)\n-------------------------------------\n\n* Implemented filters as in http://php.net/manual/en/function.imagefilter.php\n* Changed `crop` to `crop_to_fit`, works the same way.\n* Changed arguments and sends them in array.\n* Added quality-setting.\n* Added testcases for above.\n\n\nv0.1.1 (2012-04-27)\n-------------------------------------\n\n* Corrected calculation where both width and height were set.\n\n\nv0.1 (2012-04-25)\n-------------------------------------\n\n* Initial release after rewriting some older code doing the same, but not that good and flexible.\n"
  },
  {
    "path": "SECURITY.md",
    "content": "Security policy\n======================\n\nTo report security vulnerabilities in the project, send en email to mikael.t.h.roos@gmail.com.\n\nFor other security related issues, please open an issue on the project.\n"
  },
  {
    "path": "autoload.php",
    "content": "<?php\n/**\n * Autoloader for CImage and related class files.\n *\n */\nrequire_once __DIR__ . \"/defines.php\";\nrequire_once __DIR__ . \"/functions.php\";\n\n\n\n/**\n * Autoloader for classes.\n *\n * @param string $class the fully-qualified class name.\n *\n * @return void\n */\nspl_autoload_register(function ($class) {\n    //$path = CIMAGE_SOURCE_PATH . \"/{$class}.php\";\n    $path = __DIR__ . \"/{$class}.php\";\n    if (is_file($path)) {\n        require($path);\n    }\n});\n"
  },
  {
    "path": "bin/cache.bash",
    "content": "#!/bin/bash\n#\n# ls -ult list and sorts fils by its access time\n#\n#\n# Main, start by checking basic usage\n#\nif [ $# -lt 1 ]\nthen\n    echo \"Usage: $0 [cache-dir]\"\n    exit 1\nelif [ ! -d \"$1\" ]; then\n    echo \"Usage: $0 [cache-dir]\"\n    echo \"$1 is not a directory.\"\n    exit 1\nfi\n\n\n\n#\n# Print out details on cache-directory\n#\necho \"# Size\"\necho \"Total size:       $( du -sh $1 | cut -f1 )\"\necho \"Number of files:  $( find $1 -type f | wc -l )\"\necho \"Number of dirs:   $( find $1 -type d | wc -l )\"\necho\necho \"# Top-5 largest files/dirs:\"\necho \"$( du -s $1/* | sort -nr | head -5 )\"\necho \necho \"# Last-5 created files:\"\necho \"$( find $1 -type f -printf '%TY-%Tm-%Td %TH:%TM %p\\n' | sort -r | head -5 )\"\necho\necho \"# Last-5 accessed files:\"\necho \"$( find $1 -type f -printf '%AY-%Am-%Ad %AH:%AM %f\\n' | sort -r | head -5 )\"\necho\necho \"# 5 Oldest files:\"\necho \"$( find $1 -type f -printf '%AY-%Am-%Ad %AH:%AM %f\\n' | sort | head -5 )\"\necho\necho \"# Files not accessed within the last 30 days\"\necho \"Number of files: $( find $1 -type f -atime +30 | wc -l )\"\necho \"Total file size: $( find $1 -type f -atime +30 -exec du {} \\; | cut -f1 | paste -sd+ | bc )\"\necho\n"
  },
  {
    "path": "bin/create-img-single.bash",
    "content": "#!/bin/bash\n\n#\n# Paths and settings\n#\nTARGET_D=\"webroot/imgd.php\"\nTARGET_P=\"webroot/imgp.php\"\nTARGET_S=\"webroot/imgs.php\"\nNEWLINES=\"\\n\\n\\n\"\n\n\n\n#\n# Specify the utilities used\n#\nECHO=\"printf\"\n\n\n\n#\n# Main, start by checking basic usage\n#\nif [ $# -gt 0 ]\nthen\n    $ECHO \"Usage: $0\\n\"\n    exit 1\nfi\n\n\n\n#\n# Print out details on cache-directory\n#\n$ECHO \"Creating '$TARGET_D', '$TARGET_P' and '$TARGET_S' by combining the following files:\"\n$ECHO \"\\n\"\n$ECHO \"\\n webroot/img_header.php\"\n$ECHO \"\\n defines.php\"\n$ECHO \"\\n functions.php\"\n$ECHO \"\\n CHttpGet.php\"\n$ECHO \"\\n CRemoteImage.php\"\n$ECHO \"\\n CWhitelist.php\"\n$ECHO \"\\n CAsciiArt.php\"\n$ECHO \"\\n CImage.php\"\n$ECHO \"\\n CCache.php\"\n$ECHO \"\\n CFastTrackCache.php\"\n$ECHO \"\\n webroot/img.php\"\n$ECHO \"\\n\"\n$ECHO \"\\n'$TARGET_D' is for development mode.\"\n$ECHO \"\\n'$TARGET_P' is for production mode (default mode).\"\n$ECHO \"\\n'$TARGET_S' is for strict mode.\"\n$ECHO \"\\n\"\n\n$ECHO \"\\nPress enter to continue. \"\nread answer\n\n\n#\n# Create the $TARGET_? files\n#\ncat webroot/img_header.php > $TARGET_P\ncat webroot/img_header.php | sed \"s|//'mode'         => 'production',|'mode'         => 'development',|\" > $TARGET_D\ncat webroot/img_header.php | sed \"s|//'mode'         => 'production',|'mode'         => 'strict',|\" > $TARGET_S\n\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 defines.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 functions.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 CHttpGet.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 CRemoteImage.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 CWhitelist.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 CAsciiArt.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 CImage.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 CCache.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 CFastTrackCache.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\ntail -n +2 webroot/img.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n$ECHO \"$NEWLINES\" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null\n\nphp -w $TARGET_S > tmp && mv tmp $TARGET_S\n\n$ECHO \"\\nDone.\"\n$ECHO \"\\n\"\n$ECHO \"\\n\"\n"
  },
  {
    "path": "cache/.gitignore",
    "content": "# Ignore everything in this directory\n*\n# Except this file\n!.gitignore\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"mos/cimage\",\n    \"type\": \"library\",\n    \"description\": \"Process, scale, resize, crop and filter images.\",\n    \"keywords\": [\"image\", \"imageprocessing\", \"gd\"],\n    \"homepage\": \"http://dbwebb.se/opensource/cimage\",\n    \"license\": \"MIT\",\n    \"authors\": [\n        {\n            \"name\": \"Mikael Roos\",\n            \"email\": \"me@mikaelroos.se\",\n            \"homepage\": \"http://mikaelroos.se\",\n            \"role\": \"Developer\"\n        }\n    ],\n    \"support\": {\n        \"issues\": \"https://github.com/mosbth/cimage/issues\",\n        \"docs\": \"http://dbwebb.se/opensource/cimage\"\n    },\n    \"require\": {\n        \"php\": \">=7.0\"\n    },\n    \"suggest\": {\n        \"ext-curl\": \"*\",\n        \"ext-exif\": \"*\",\n        \"ext-gd\": \"*\",\n        \"ext-imagick\": \"*\"\n    },\n    \"autoload\": {\n       \"files\": [\n           \"defines.php\",\n           \"functions.php\"\n       ],\n       \"classmap\": [\n            \"CImage.php\",\n            \"CHttpGet.php\",\n            \"CRemoteImage.php\",\n            \"CWhitelist.php\",\n            \"CAsciiArt.php\",\n            \"CCache.php\",\n            \"CFastTrackCache.php\"\n        ]\n    }\n}\n"
  },
  {
    "path": "defines.php",
    "content": "<?php\n// Version of cimage and img.php\ndefine(\"CIMAGE_VERSION\", \"v0.8.6 (2023-10-27)\");\n\n// For CRemoteImage\ndefine(\"CIMAGE_USER_AGENT\", \"CImage/\" . CIMAGE_VERSION);\n\n// Image type IMG_WEBP is only defined from 5.6.25\nif (!defined(\"IMG_WEBP\")) {\n    define(\"IMG_WEBP\", -1);\n}\n"
  },
  {
    "path": "docker-compose.yaml",
    "content": "version: \"3\"\nservices:\n    cli:\n        image: anax/dev\n        volumes: [ \".:/home/anax/repo\" ]\n\n    apache:\n        image: anax/dev:apache\n        volumes: [ \".:/home/anax/repo\" ]\n        ports: [ \"11000:80\" ]\n\n    remserver:\n        image: anax/dev:apache\n        ports:\n            - \"8090:80\"\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php82:\n        image: anax/dev:php82\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php82-apache:\n        image: anax/dev:php82-apache\n        ports: [ \"11082:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php81:\n        image: anax/dev:php81\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php81-apache:\n        image: anax/dev:php81-apache\n        ports: [ \"11081:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php80:\n        image: anax/dev:php80\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php80-apache:\n        image: anax/dev:php80-apache\n        ports: [ \"11080:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php74:\n        image: anax/dev:php74\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php74-apache:\n        image: anax/dev:php74-apache\n        ports: [ \"11074:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php73:\n        image: anax/dev:php73\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php73-apache:\n        image: anax/dev:php73-apache\n        ports: [ \"11073:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php72:\n        image: anax/dev:php72\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php72-apache:\n        image: anax/dev:php72-apache\n        ports: [ \"11072:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php71:\n        image: anax/dev:php71\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php71-apache:\n        image: anax/dev:php71-apache\n        ports: [ \"11071:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php70:\n        image: anax/dev:php70\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php70:\n        image: anax/dev:php70-apache\n        ports: [ \"11070:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php56:\n        image: anax/dev:php56\n        volumes: [ \".:/home/anax/repo\" ]\n\n    php56:\n        image: anax/dev:php56-apache\n        ports: [ \"11056:80\" ]\n        volumes: [ \".:/home/anax/repo\" ]\n"
  },
  {
    "path": "docs/api/.htaccess",
    "content": "# Fixes a vulnerability in CentOS: http://stackoverflow.com/questions/20533279/prevent-php-from-parsing-non-php-files-such-as-somefile-php-txt\n<FilesMatch \\.php\\.txt$>\n    RemoveHandler .php\n    ForceType text/plain\n</FilesMatch>"
  },
  {
    "path": "docs/api/classes/CAsciiArt.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    <script type=\"text/javascript\">\n    function loadExternalCodeSnippets() {\n        Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n            var src = pre.getAttribute('data-src');\n            var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n            var language = 'php';\n\n            var code = document.createElement('code');\n            code.className = 'language-' + language;\n\n            pre.textContent = '';\n\n            code.textContent = 'Loading…';\n\n            pre.appendChild(code);\n\n            var xhr = new XMLHttpRequest();\n\n            xhr.open('GET', src, true);\n\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState == 4) {\n\n                    if (xhr.status < 400 && xhr.responseText) {\n                        code.textContent = xhr.responseText;\n\n                        Prism.highlightElement(code);\n                    }\n                    else if (xhr.status >= 400) {\n                        code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                    }\n                    else {\n                        code.textContent = '✖ Error: File does not exist or is empty';\n                    }\n                }\n            };\n\n            xhr.send(null);\n        });\n    }\n\n    $(document).ready(function(){\n        loadExternalCodeSnippets();\n    });\n    $('#source-view').on('shown', function () {\n        loadExternalCodeSnippets();\n    })\n</script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1847469476\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1847469476\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <nav>\n                                                <a href=\"../namespaces/default.html\">\\</a> <i class=\"icon-level-up\"></i>\n                                            </nav>\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n\n                    <h1><small>\\</small>CAsciiArt</h1>\n                    <p><em>Create an ASCII version of an image.</em></p>\n                    \n                    \n                                        \n                    <section id=\"summary\">\n                        <h2>Summary</h2>\n                        <section class=\"row-fluid heading\">\n                            <section class=\"span4\">\n                                <a href=\"#methods\">Methods</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#properties\">Properties</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#constants\">Constants</a>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid public\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CAsciiArt.html#method___construct\" class=\"\">__construct()</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#method_addCharacterSet\" class=\"\">addCharacterSet()</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#method_setOptions\" class=\"\">setOptions()</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#method_createFromFile\" class=\"\">createFromFile()</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#method_luminanceAreaAverage\" class=\"\">luminanceAreaAverage()</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#method_getLuminance\" class=\"\">getLuminance()</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#method_luminance2character\" class=\"\">luminance2character()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No public properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No constants found</em>\n                                                            </section>\n                        </section>\n                        <section class=\"row-fluid protected\">\n                            <section class=\"span4\">\n                                                                    <em>No protected methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No protected properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid private\">\n                            <section class=\"span4\">\n                                                                    <em>No private methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CAsciiArt.html#property_characterSet\" class=\"\">$characterSet</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#property_characters\" class=\"\">$characters</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#property_charCount\" class=\"\">$charCount</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#property_scale\" class=\"\">$scale</a><br />\n                                                                    <a href=\"../classes/CAsciiArt.html#property_luminanceStrategy\" class=\"\">$luminanceStrategy</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                    </section>\n                </div>\n                <aside class=\"span4 detailsbar\">\n                                        \n                    \n                    <dl>\n                        <dt>File</dt>\n                            <dd><a href=\"../files/CAsciiArt.html\"><div class=\"path-wrapper\">CAsciiArt.php</div></a></dd>\n                                                <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">Default</div></dd>\n                                                <dt>Class hierarchy</dt>\n                            <dd class=\"hierarchy\">\n                                                                                                                                                                    <div class=\"namespace-wrapper\">\\CAsciiArt</div>\n                            </dd>\n\n                        \n                        \n                        \n                        \n                                                                        </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                            <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                        </table>\n                </aside>\n            </div>\n\n                        \n                                    <a id=\"properties\" name=\"properties\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Properties</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_characterSet\" name=\"property_characterSet\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$characterSet</h3>\n                <pre class=\"signature\">$characterSet : </pre>\n                <p><em>Character set to use.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_characters\" name=\"property_characters\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$characters</h3>\n                <pre class=\"signature\">$characters : </pre>\n                <p><em>Current character set.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_charCount\" name=\"property_charCount\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$charCount</h3>\n                <pre class=\"signature\">$charCount : </pre>\n                <p><em>Length of current character set.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_scale\" name=\"property_scale\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$scale</h3>\n                <pre class=\"signature\">$scale : </pre>\n                <p><em>Scale of the area to swap to a character.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_luminanceStrategy\" name=\"property_luminanceStrategy\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$luminanceStrategy</h3>\n                <pre class=\"signature\">$luminanceStrategy : </pre>\n                <p><em>Strategy to calculate luminance.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"methods\" name=\"methods\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\"><h2>Methods</h2></div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method___construct\" name=\"method___construct\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">__construct()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">__construct() </pre>\n                <p><em>Constructor which sets default options.</em></p>\n                \n\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_addCharacterSet\" name=\"method_addCharacterSet\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">addCharacterSet()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">addCharacterSet(string  <span class=\"argument\">$key</span>, string  <span class=\"argument\">$value</span>) : $this</pre>\n                <p><em>Add a custom character set.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$key </td>\n                                <td><p>for the character set.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$value </td>\n                                <td><p>for the character set.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setOptions\" name=\"method_setOptions\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setOptions()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setOptions(array  <span class=\"argument\">$options = array()</span>) : $this</pre>\n                <p><em>Set options for processing, defaults are available.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>array</td>\n                                <td>$options </td>\n                                <td><p>to use as default settings.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_createFromFile\" name=\"method_createFromFile\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">createFromFile()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">createFromFile(string  <span class=\"argument\">$filename</span>) : string</pre>\n                <p><em>Create an Ascii image from an image file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$filename </td>\n                                <td><p>of the image to use.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>$ascii with the ASCII image.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_luminanceAreaAverage\" name=\"method_luminanceAreaAverage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">luminanceAreaAverage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">luminanceAreaAverage(string  <span class=\"argument\">$img</span>, integer  <span class=\"argument\">$x1</span>, integer  <span class=\"argument\">$y1</span>, integer  <span class=\"argument\">$x2</span>, integer  <span class=\"argument\">$y2</span>) : integer</pre>\n                <p><em>Get the luminance from a region of an image using average color value.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$img </td>\n                                <td><p>the image.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$x1 </td>\n                                <td><p>the area to get pixels from.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$y1 </td>\n                                <td><p>the area to get pixels from.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$x2 </td>\n                                <td><p>the area to get pixels from.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$y2 </td>\n                                <td><p>the area to get pixels from.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>$luminance with a value between 0 and 100.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getLuminance\" name=\"method_getLuminance\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getLuminance()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getLuminance(integer  <span class=\"argument\">$red</span>, integer  <span class=\"argument\">$green</span>, integer  <span class=\"argument\">$blue</span>) : float</pre>\n                <p><em>Calculate luminance value with different strategies.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$red </td>\n                                <td><p>The color red.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$green </td>\n                                <td><p>The color green.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$blue </td>\n                                <td><p>The color blue.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    float\n                                            &mdash; <p>$luminance with a value between 0 and 1.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_luminance2character\" name=\"method_luminance2character\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">luminance2character()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">luminance2character(  <span class=\"argument\">$luminance</span>) : string</pre>\n                <p><em>Translate the luminance value to a character.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td></td>\n                                <td>$luminance </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>with the ascii character.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                                    </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\">CAsciiArt.php</h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CAsciiArt.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/classes/CHttpGet.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    <script type=\"text/javascript\">\n    function loadExternalCodeSnippets() {\n        Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n            var src = pre.getAttribute('data-src');\n            var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n            var language = 'php';\n\n            var code = document.createElement('code');\n            code.className = 'language-' + language;\n\n            pre.textContent = '';\n\n            code.textContent = 'Loading…';\n\n            pre.appendChild(code);\n\n            var xhr = new XMLHttpRequest();\n\n            xhr.open('GET', src, true);\n\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState == 4) {\n\n                    if (xhr.status < 400 && xhr.responseText) {\n                        code.textContent = xhr.responseText;\n\n                        Prism.highlightElement(code);\n                    }\n                    else if (xhr.status >= 400) {\n                        code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                    }\n                    else {\n                        code.textContent = '✖ Error: File does not exist or is empty';\n                    }\n                }\n            };\n\n            xhr.send(null);\n        });\n    }\n\n    $(document).ready(function(){\n        loadExternalCodeSnippets();\n    });\n    $('#source-view').on('shown', function () {\n        loadExternalCodeSnippets();\n    })\n</script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-603682456\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-603682456\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <nav>\n                                                <a href=\"../namespaces/default.html\">\\</a> <i class=\"icon-level-up\"></i>\n                                            </nav>\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n\n                    <h1><small>\\</small>CHttpGet</h1>\n                    <p><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></p>\n                    \n                    \n                                        \n                    <section id=\"summary\">\n                        <h2>Summary</h2>\n                        <section class=\"row-fluid heading\">\n                            <section class=\"span4\">\n                                <a href=\"#methods\">Methods</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#properties\">Properties</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#constants\">Constants</a>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid public\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CHttpGet.html#method___construct\" class=\"\">__construct()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_buildUrl\" class=\"\">buildUrl()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_setUrl\" class=\"\">setUrl()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_setHeader\" class=\"\">setHeader()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_parseHeader\" class=\"\">parseHeader()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_doGet\" class=\"\">doGet()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_getStatus\" class=\"\">getStatus()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_getLastModified\" class=\"\">getLastModified()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_getContentType\" class=\"\">getContentType()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_getDate\" class=\"\">getDate()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_getMaxAge\" class=\"\">getMaxAge()</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#method_getBody\" class=\"\">getBody()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No public properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No constants found</em>\n                                                            </section>\n                        </section>\n                        <section class=\"row-fluid protected\">\n                            <section class=\"span4\">\n                                                                    <em>No protected methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No protected properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid private\">\n                            <section class=\"span4\">\n                                                                    <em>No private methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CHttpGet.html#property_request\" class=\"\">$request</a><br />\n                                                                    <a href=\"../classes/CHttpGet.html#property_response\" class=\"\">$response</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                    </section>\n                </div>\n                <aside class=\"span4 detailsbar\">\n                                        \n                    \n                    <dl>\n                        <dt>File</dt>\n                            <dd><a href=\"../files/CHttpGet.html\"><div class=\"path-wrapper\">CHttpGet.php</div></a></dd>\n                                                <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">Default</div></dd>\n                                                <dt>Class hierarchy</dt>\n                            <dd class=\"hierarchy\">\n                                                                                                                                                                    <div class=\"namespace-wrapper\">\\CHttpGet</div>\n                            </dd>\n\n                        \n                        \n                        \n                        \n                                                                        </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                            <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                        </table>\n                </aside>\n            </div>\n\n                        \n                                    <a id=\"properties\" name=\"properties\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Properties</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_request\" name=\"property_request\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$request</h3>\n                <pre class=\"signature\">$request : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_response\" name=\"property_response\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$response</h3>\n                <pre class=\"signature\">$response : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"methods\" name=\"methods\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\"><h2>Methods</h2></div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method___construct\" name=\"method___construct\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">__construct()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">__construct() </pre>\n                <p><em>Constructor</em></p>\n                \n\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_buildUrl\" name=\"method_buildUrl\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">buildUrl()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">buildUrl(string  <span class=\"argument\">$baseUrl</span>, string  <span class=\"argument\">$merge</span>) : string</pre>\n                <p><em>Build an encoded url.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$baseUrl </td>\n                                <td><p>This is the original url which will be merged.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$merge </td>\n                                <td><p>Thse parts should be merged into the baseUrl,\nthe format is as parse_url.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>$url as the modified url.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setUrl\" name=\"method_setUrl\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setUrl()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setUrl(string  <span class=\"argument\">$url</span>) : $this</pre>\n                <p><em>Set the url for the request.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$url </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setHeader\" name=\"method_setHeader\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setHeader()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setHeader(string  <span class=\"argument\">$field</span>, string  <span class=\"argument\">$value</span>) : $this</pre>\n                <p><em>Set custom header field for the request.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$field </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$value </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_parseHeader\" name=\"method_parseHeader\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">parseHeader()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">parseHeader() : $this</pre>\n                <p><em>Set header fields for the request.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_doGet\" name=\"method_doGet\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">doGet()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">doGet(boolean  <span class=\"argument\">$debug = false</span>) : boolean</pre>\n                <p><em>Perform the request.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$debug </td>\n                                <td><p>set to true to dump headers.</p></td>\n                            </tr>\n                                            </table>\n                \n                                    <h4>Throws</h4>\n                    <dl>\n                                                    <dt>\\Exception</dt>\n                            <dd><p>when curl fails to retrieve url.</p></dd>\n                                                                    </dl>\n                \n                                    <h4>Returns</h4>\n                    boolean\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getStatus\" name=\"method_getStatus\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getStatus()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getStatus() : integer</pre>\n                <p><em>Get HTTP code of response.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>as HTTP status code or null if not available.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getLastModified\" name=\"method_getLastModified\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getLastModified()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getLastModified() : integer</pre>\n                <p><em>Get file modification time of response.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>as timestamp.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getContentType\" name=\"method_getContentType\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getContentType()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getContentType() : string</pre>\n                <p><em>Get content type.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as the content type or null if not existing or invalid.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDate\" name=\"method_getDate\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getDate()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDate(mixed  <span class=\"argument\">$default = false</span>) : integer</pre>\n                <p><em>Get file modification time of response.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>as default value (int seconds) if date is\nmissing in response header.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>as timestamp or $default if Date is missing in\nresponse header.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getMaxAge\" name=\"method_getMaxAge\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getMaxAge()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getMaxAge(mixed  <span class=\"argument\">$default = false</span>) : integer</pre>\n                <p><em>Get max age of cachable item.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>as default value if date is missing in response\nheader.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>as timestamp or false if not available.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getBody\" name=\"method_getBody\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getBody()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getBody() : string</pre>\n                <p><em>Get body of response.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as body.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                                    </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\">CHttpGet.php</h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CHttpGet.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/classes/CImage.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    <script type=\"text/javascript\">\n    function loadExternalCodeSnippets() {\n        Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n            var src = pre.getAttribute('data-src');\n            var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n            var language = 'php';\n\n            var code = document.createElement('code');\n            code.className = 'language-' + language;\n\n            pre.textContent = '';\n\n            code.textContent = 'Loading…';\n\n            pre.appendChild(code);\n\n            var xhr = new XMLHttpRequest();\n\n            xhr.open('GET', src, true);\n\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState == 4) {\n\n                    if (xhr.status < 400 && xhr.responseText) {\n                        code.textContent = xhr.responseText;\n\n                        Prism.highlightElement(code);\n                    }\n                    else if (xhr.status >= 400) {\n                        code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                    }\n                    else {\n                        code.textContent = '✖ Error: File does not exist or is empty';\n                    }\n                }\n            };\n\n            xhr.send(null);\n        });\n    }\n\n    $(document).ready(function(){\n        loadExternalCodeSnippets();\n    });\n    $('#source-view').on('shown', function () {\n        loadExternalCodeSnippets();\n    })\n</script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-972863959\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-972863959\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <nav>\n                                                <a href=\"../namespaces/default.html\">\\</a> <i class=\"icon-level-up\"></i>\n                                            </nav>\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n\n                    <h1><small>\\</small>CImage</h1>\n                    <p><em>Resize and crop images on the fly, store generated images in a cache.</em></p>\n                    \n                    \n                                                                        <h3>Examples</h3>\n                                                                            <h4></h4>\n                            <pre class=\"pre-scrollable\">** File not found : http://dbwebb.se/opensource/cimage **</pre>\n                                                                \n                    <section id=\"summary\">\n                        <h2>Summary</h2>\n                        <section class=\"row-fluid heading\">\n                            <section class=\"span4\">\n                                <a href=\"#methods\">Methods</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#properties\">Properties</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#constants\">Constants</a>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid public\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage.html#method___construct\" class=\"\">__construct()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setVerbose\" class=\"\">setVerbose()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setSaveFolder\" class=\"\">setSaveFolder()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_useCache\" class=\"\">useCache()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_createDummyImage\" class=\"\">createDummyImage()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setRemoteDownload\" class=\"\">setRemoteDownload()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_isRemoteSource\" class=\"\">isRemoteSource()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setRemoteHostWhitelist\" class=\"\">setRemoteHostWhitelist()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_isRemoteSourceOnWhitelist\" class=\"\">isRemoteSourceOnWhitelist()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_downloadRemoteSource\" class=\"\">downloadRemoteSource()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setSource\" class=\"\">setSource()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setTarget\" class=\"\">setTarget()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_getTarget\" class=\"\">getTarget()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setOptions\" class=\"\">setOptions()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_loadImageDetails\" class=\"\">loadImageDetails()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_initDimensions\" class=\"\">initDimensions()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_calculateNewWidthAndHeight\" class=\"\">calculateNewWidthAndHeight()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_reCalculateDimensions\" class=\"\">reCalculateDimensions()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setSaveAsExtension\" class=\"\">setSaveAsExtension()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setJpegQuality\" class=\"\">setJpegQuality()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setPngCompression\" class=\"\">setPngCompression()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_useOriginalIfPossible\" class=\"\">useOriginalIfPossible()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_generateFilename\" class=\"\">generateFilename()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_useCacheIfPossible\" class=\"\">useCacheIfPossible()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_load\" class=\"\">load()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_getPngType\" class=\"\">getPngType()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_preResize\" class=\"\">preResize()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setCopyResizeStrategy\" class=\"\">setCopyResizeStrategy()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_imageCopyResampled\" class=\"\">imageCopyResampled()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_resize\" class=\"\">resize()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_postResize\" class=\"\">postResize()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_rotate\" class=\"\">rotate()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_rotateExif\" class=\"\">rotateExif()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_trueColorToPalette\" class=\"\">trueColorToPalette()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_sharpenImage\" class=\"\">sharpenImage()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_embossImage\" class=\"\">embossImage()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_blurImage\" class=\"\">blurImage()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_createConvolveArguments\" class=\"\">createConvolveArguments()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_addConvolveExpressions\" class=\"\">addConvolveExpressions()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_imageConvolution\" class=\"\">imageConvolution()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setDefaultBackgroundColor\" class=\"\">setDefaultBackgroundColor()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setPostProcessingOptions\" class=\"\">setPostProcessingOptions()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_save\" class=\"\">save()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_linkToCacheFile\" class=\"\">linkToCacheFile()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_addHTTPHeader\" class=\"\">addHTTPHeader()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_output\" class=\"\">output()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_json\" class=\"\">json()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setAsciiOptions\" class=\"\">setAsciiOptions()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_ascii\" class=\"\">ascii()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_log\" class=\"\">log()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_setVerboseToFile\" class=\"\">setVerboseToFile()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage.html#property_crop\" class=\"\">$crop</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_cropOrig\" class=\"\">$cropOrig</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_keepRatio\" class=\"\">$keepRatio</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_cropToFit\" class=\"\">$cropToFit</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_crop_x\" class=\"\">$crop_x</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_crop_y\" class=\"\">$crop_y</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_filters\" class=\"\">$filters</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage.html#constant_PNG_GREYSCALE\" class=\"\">PNG_GREYSCALE</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_PNG_RGB\" class=\"\">PNG_RGB</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_PNG_RGB_PALETTE\" class=\"\">PNG_RGB_PALETTE</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_PNG_GREYSCALE_ALPHA\" class=\"\">PNG_GREYSCALE_ALPHA</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_PNG_RGB_ALPHA\" class=\"\">PNG_RGB_ALPHA</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_JPEG_QUALITY_DEFAULT\" class=\"\">JPEG_QUALITY_DEFAULT</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_PNG_COMPRESSION_DEFAULT\" class=\"\">PNG_COMPRESSION_DEFAULT</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_UPSCALE_DEFAULT\" class=\"\">UPSCALE_DEFAULT</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_RESIZE\" class=\"\">RESIZE</a><br />\n                                                                    <a href=\"../classes/CImage.html#constant_RESAMPLE\" class=\"\">RESAMPLE</a><br />\n                                                            </section>\n                        </section>\n                        <section class=\"row-fluid protected\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage.html#method_getTargetImageExtension\" class=\"\">getTargetImageExtension()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No protected properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid private\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage.html#method_checkFileExtension\" class=\"\">checkFileExtension()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_normalizeFileExtension\" class=\"\">normalizeFileExtension()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_mapFilter\" class=\"\">mapFilter()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_getPngTypeAsString\" class=\"\">getPngTypeAsString()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_colorsTotal\" class=\"\">colorsTotal()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_getBackgroundColor\" class=\"\">getBackgroundColor()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_createImageKeepTransparency\" class=\"\">createImageKeepTransparency()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_verboseOutput\" class=\"\">verboseOutput()</a><br />\n                                                                    <a href=\"../classes/CImage.html#method_raiseError\" class=\"\">raiseError()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage.html#property_quality\" class=\"\">$quality</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_useQuality\" class=\"\">$useQuality</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_compress\" class=\"\">$compress</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_useCompress\" class=\"\">$useCompress</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_HTTPHeader\" class=\"\">$HTTPHeader</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_bgColorDefault\" class=\"\">$bgColorDefault</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_bgColor\" class=\"\">$bgColor</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_saveFolder\" class=\"\">$saveFolder</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_image\" class=\"\">$image</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_imageSrc\" class=\"\">$imageSrc</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_pathToImage\" class=\"\">$pathToImage</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_fileType\" class=\"\">$fileType</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_extension\" class=\"\">$extension</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_outputFormat\" class=\"\">$outputFormat</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_verbose\" class=\"\">$verbose</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_log\" class=\"\">$log</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_palette\" class=\"\">$palette</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_cacheFileName\" class=\"\">$cacheFileName</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_saveAs\" class=\"\">$saveAs</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_pngFilter\" class=\"\">$pngFilter</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_pngFilterCmd\" class=\"\">$pngFilterCmd</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_pngDeflate\" class=\"\">$pngDeflate</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_pngDeflateCmd\" class=\"\">$pngDeflateCmd</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_jpegOptimize\" class=\"\">$jpegOptimize</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_jpegOptimizeCmd\" class=\"\">$jpegOptimizeCmd</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_width\" class=\"\">$width</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_height\" class=\"\">$height</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_newWidth\" class=\"\">$newWidth</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_newWidthOrig\" class=\"\">$newWidthOrig</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_newHeight\" class=\"\">$newHeight</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_newHeightOrig\" class=\"\">$newHeightOrig</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_dpr\" class=\"\">$dpr</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_upscale\" class=\"\">$upscale</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_convolve\" class=\"\">$convolve</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_convolves\" class=\"\">$convolves</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_fillToFit\" class=\"\">$fillToFit</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_scale\" class=\"\">$scale</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_rotateBefore\" class=\"\">$rotateBefore</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_rotateAfter\" class=\"\">$rotateAfter</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_autoRotate\" class=\"\">$autoRotate</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_sharpen\" class=\"\">$sharpen</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_emboss\" class=\"\">$emboss</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_blur\" class=\"\">$blur</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_offset\" class=\"\">$offset</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_fillWidth\" class=\"\">$fillWidth</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_fillHeight\" class=\"\">$fillHeight</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_allowRemote\" class=\"\">$allowRemote</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_remotePattern\" class=\"\">$remotePattern</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_useCache\" class=\"\">$useCache</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_remoteHostWhitelist\" class=\"\">$remoteHostWhitelist</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_verboseFileName\" class=\"\">$verboseFileName</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_asciiOptions\" class=\"\">$asciiOptions</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_copyStrategy\" class=\"\">$copyStrategy</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_cropWidth\" class=\"\">$cropWidth</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_cropHeight\" class=\"\">$cropHeight</a><br />\n                                                                    <a href=\"../classes/CImage.html#property_attr\" class=\"\">$attr</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                    </section>\n                </div>\n                <aside class=\"span4 detailsbar\">\n                                        \n                    \n                    <dl>\n                        <dt>File</dt>\n                            <dd><a href=\"../files/CImage.html\"><div class=\"path-wrapper\">CImage.php</div></a></dd>\n                                                <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">Default</div></dd>\n                                                <dt>Class hierarchy</dt>\n                            <dd class=\"hierarchy\">\n                                                                                                                                                                    <div class=\"namespace-wrapper\">\\CImage</div>\n                            </dd>\n\n                        \n                        \n                        \n                                                                            <dt>See also</dt>\n                                                                                    <dd><a href=\"https://github.com/mosbth/cimage\"><div class=\"namespace-wrapper\">https://github.com/mosbth/cimage</div></a></dd>\n                                                    \n                                                                        </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                            <tr>\n                            <th>\n                                author\n                            </th>\n                            <td>\n                                                                    <p>Mikael Roos mos@dbwebb.se</p>\n                                                            </td>\n                        </tr>\n                                        </table>\n                </aside>\n            </div>\n\n                                    <a id=\"constants\" name=\"constants\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Constants</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_PNG_GREYSCALE\" name=\"constant_PNG_GREYSCALE\" class=\"anchor\"></a>\n            <article id=\"constant_PNG_GREYSCALE\" class=\"constant\">\n                <h3 class=\"\">PNG_GREYSCALE</h3>\n                <pre class=\"signature\">PNG_GREYSCALE</pre>\n                <p><em>Constants type of PNG image</em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_PNG_RGB\" name=\"constant_PNG_RGB\" class=\"anchor\"></a>\n            <article id=\"constant_PNG_RGB\" class=\"constant\">\n                <h3 class=\"\">PNG_RGB</h3>\n                <pre class=\"signature\">PNG_RGB</pre>\n                <p><em></em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_PNG_RGB_PALETTE\" name=\"constant_PNG_RGB_PALETTE\" class=\"anchor\"></a>\n            <article id=\"constant_PNG_RGB_PALETTE\" class=\"constant\">\n                <h3 class=\"\">PNG_RGB_PALETTE</h3>\n                <pre class=\"signature\">PNG_RGB_PALETTE</pre>\n                <p><em></em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_PNG_GREYSCALE_ALPHA\" name=\"constant_PNG_GREYSCALE_ALPHA\" class=\"anchor\"></a>\n            <article id=\"constant_PNG_GREYSCALE_ALPHA\" class=\"constant\">\n                <h3 class=\"\">PNG_GREYSCALE_ALPHA</h3>\n                <pre class=\"signature\">PNG_GREYSCALE_ALPHA</pre>\n                <p><em></em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_PNG_RGB_ALPHA\" name=\"constant_PNG_RGB_ALPHA\" class=\"anchor\"></a>\n            <article id=\"constant_PNG_RGB_ALPHA\" class=\"constant\">\n                <h3 class=\"\">PNG_RGB_ALPHA</h3>\n                <pre class=\"signature\">PNG_RGB_ALPHA</pre>\n                <p><em></em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_JPEG_QUALITY_DEFAULT\" name=\"constant_JPEG_QUALITY_DEFAULT\" class=\"anchor\"></a>\n            <article id=\"constant_JPEG_QUALITY_DEFAULT\" class=\"constant\">\n                <h3 class=\"\">JPEG_QUALITY_DEFAULT</h3>\n                <pre class=\"signature\">JPEG_QUALITY_DEFAULT</pre>\n                <p><em>Constant for default image quality when not set</em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_PNG_COMPRESSION_DEFAULT\" name=\"constant_PNG_COMPRESSION_DEFAULT\" class=\"anchor\"></a>\n            <article id=\"constant_PNG_COMPRESSION_DEFAULT\" class=\"constant\">\n                <h3 class=\"\">PNG_COMPRESSION_DEFAULT</h3>\n                <pre class=\"signature\">PNG_COMPRESSION_DEFAULT</pre>\n                <p><em>Constant for default image quality when not set</em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_UPSCALE_DEFAULT\" name=\"constant_UPSCALE_DEFAULT\" class=\"anchor\"></a>\n            <article id=\"constant_UPSCALE_DEFAULT\" class=\"constant\">\n                <h3 class=\"\">UPSCALE_DEFAULT</h3>\n                <pre class=\"signature\">UPSCALE_DEFAULT</pre>\n                <p><em>Always upscale images, even if they are smaller than target image.</em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_RESIZE\" name=\"constant_RESIZE\" class=\"anchor\"></a>\n            <article id=\"constant_RESIZE\" class=\"constant\">\n                <h3 class=\"\">RESIZE</h3>\n                <pre class=\"signature\">RESIZE</pre>\n                <p><em></em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"constant_RESAMPLE\" name=\"constant_RESAMPLE\" class=\"anchor\"></a>\n            <article id=\"constant_RESAMPLE\" class=\"constant\">\n                <h3 class=\"\">RESAMPLE</h3>\n                <pre class=\"signature\">RESAMPLE</pre>\n                <p><em></em></p>\n                \n            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"properties\" name=\"properties\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Properties</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_crop\" name=\"property_crop\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"public \">$crop</h3>\n                <pre class=\"signature\">$crop : </pre>\n                <p><em>Array with details on how to crop, incoming as argument and calculated.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_cropOrig\" name=\"property_cropOrig\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"public \">$cropOrig</h3>\n                <pre class=\"signature\">$cropOrig : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_keepRatio\" name=\"property_keepRatio\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"public \">$keepRatio</h3>\n                <pre class=\"signature\">$keepRatio : </pre>\n                <p><em>Properties, the class is mutable and the method setOptions()\ndecides (partly) what properties are created.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            todo\n                        </th>\n                        <td>\n                                                            <p>Clean up these and check if and how they are used</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_cropToFit\" name=\"property_cropToFit\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"public \">$cropToFit</h3>\n                <pre class=\"signature\">$cropToFit : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_crop_x\" name=\"property_crop_x\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"public \">$crop_x</h3>\n                <pre class=\"signature\">$crop_x : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_crop_y\" name=\"property_crop_y\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"public \">$crop_y</h3>\n                <pre class=\"signature\">$crop_y : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_filters\" name=\"property_filters\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"public \">$filters</h3>\n                <pre class=\"signature\">$filters : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_quality\" name=\"property_quality\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$quality</h3>\n                <pre class=\"signature\">$quality : </pre>\n                <p><em>Quality level for JPEG images.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_useQuality\" name=\"property_useQuality\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$useQuality</h3>\n                <pre class=\"signature\">$useQuality : </pre>\n                <p><em>Is the quality level set from external use (true) or is it default (false)?</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_compress\" name=\"property_compress\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$compress</h3>\n                <pre class=\"signature\">$compress : </pre>\n                <p><em>Compression level for PNG images.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_useCompress\" name=\"property_useCompress\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$useCompress</h3>\n                <pre class=\"signature\">$useCompress : </pre>\n                <p><em>Is the compress level set from external use (true) or is it default (false)?</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_HTTPHeader\" name=\"property_HTTPHeader\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$HTTPHeader</h3>\n                <pre class=\"signature\">$HTTPHeader : </pre>\n                <p><em>Add HTTP headers for outputing image.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_bgColorDefault\" name=\"property_bgColorDefault\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$bgColorDefault</h3>\n                <pre class=\"signature\">$bgColorDefault : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_bgColor\" name=\"property_bgColor\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$bgColor</h3>\n                <pre class=\"signature\">$bgColor : </pre>\n                <p><em>Background color to use, specified as part of options.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_saveFolder\" name=\"property_saveFolder\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$saveFolder</h3>\n                <pre class=\"signature\">$saveFolder : </pre>\n                <p><em>Where to save the target file.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_image\" name=\"property_image\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$image</h3>\n                <pre class=\"signature\">$image : </pre>\n                <p><em>The working image object.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_imageSrc\" name=\"property_imageSrc\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$imageSrc</h3>\n                <pre class=\"signature\">$imageSrc : </pre>\n                <p><em>Image filename, may include subdirectory, relative from $imageFolder</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_pathToImage\" name=\"property_pathToImage\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$pathToImage</h3>\n                <pre class=\"signature\">$pathToImage : </pre>\n                <p><em>Actual path to the image, $imageFolder . &#039;/&#039; . $imageSrc</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_fileType\" name=\"property_fileType\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$fileType</h3>\n                <pre class=\"signature\">$fileType : </pre>\n                <p><em>File type for source image, as provided by getimagesize()</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_extension\" name=\"property_extension\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$extension</h3>\n                <pre class=\"signature\">$extension : </pre>\n                <p><em>File extension to use when saving image.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_outputFormat\" name=\"property_outputFormat\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$outputFormat</h3>\n                <pre class=\"signature\">$outputFormat : </pre>\n                <p><em>Output format, supports null (image) or json.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_verbose\" name=\"property_verbose\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$verbose</h3>\n                <pre class=\"signature\">$verbose : </pre>\n                <p><em>Verbose mode to print out a trace and display the created image</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_log\" name=\"property_log\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$log</h3>\n                <pre class=\"signature\">$log : </pre>\n                <p><em>Keep a log/trace on what happens</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_palette\" name=\"property_palette\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$palette</h3>\n                <pre class=\"signature\">$palette : </pre>\n                <p><em>Handle image as palette image</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_cacheFileName\" name=\"property_cacheFileName\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$cacheFileName</h3>\n                <pre class=\"signature\">$cacheFileName : </pre>\n                <p><em>Target filename, with path, to save resulting image in.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_saveAs\" name=\"property_saveAs\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$saveAs</h3>\n                <pre class=\"signature\">$saveAs : </pre>\n                <p><em>Set a format to save image as, or null to use original format.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_pngFilter\" name=\"property_pngFilter\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$pngFilter</h3>\n                <pre class=\"signature\">$pngFilter : </pre>\n                <p><em>Path to command for filter optimize, for example optipng or null.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_pngFilterCmd\" name=\"property_pngFilterCmd\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$pngFilterCmd</h3>\n                <pre class=\"signature\">$pngFilterCmd : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_pngDeflate\" name=\"property_pngDeflate\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$pngDeflate</h3>\n                <pre class=\"signature\">$pngDeflate : </pre>\n                <p><em>Path to command for deflate optimize, for example pngout or null.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_pngDeflateCmd\" name=\"property_pngDeflateCmd\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$pngDeflateCmd</h3>\n                <pre class=\"signature\">$pngDeflateCmd : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_jpegOptimize\" name=\"property_jpegOptimize\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$jpegOptimize</h3>\n                <pre class=\"signature\">$jpegOptimize : </pre>\n                <p><em>Path to command to optimize jpeg images, for example jpegtran or null.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_jpegOptimizeCmd\" name=\"property_jpegOptimizeCmd\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$jpegOptimizeCmd</h3>\n                <pre class=\"signature\">$jpegOptimizeCmd : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_width\" name=\"property_width\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$width</h3>\n                <pre class=\"signature\">$width : </pre>\n                <p><em>Image dimensions, calculated from loaded image.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_height\" name=\"property_height\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$height</h3>\n                <pre class=\"signature\">$height : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_newWidth\" name=\"property_newWidth\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$newWidth</h3>\n                <pre class=\"signature\">$newWidth : </pre>\n                <p><em>New image dimensions, incoming as argument or calculated.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_newWidthOrig\" name=\"property_newWidthOrig\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$newWidthOrig</h3>\n                <pre class=\"signature\">$newWidthOrig : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_newHeight\" name=\"property_newHeight\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$newHeight</h3>\n                <pre class=\"signature\">$newHeight : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_newHeightOrig\" name=\"property_newHeightOrig\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$newHeightOrig</h3>\n                <pre class=\"signature\">$newHeightOrig : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_dpr\" name=\"property_dpr\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$dpr</h3>\n                <pre class=\"signature\">$dpr : </pre>\n                <p><em>Change target height &amp; width when different dpr, dpr 2 means double image dimensions.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_upscale\" name=\"property_upscale\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$upscale</h3>\n                <pre class=\"signature\">$upscale : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_convolve\" name=\"property_convolve\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$convolve</h3>\n                <pre class=\"signature\">$convolve : </pre>\n                <p><em>String with details on how to do image convolution. String\nshould map a key in the $convolvs array or be a string of\n11 float values separated by comma. The first nine builds\nup the matrix, then divisor and last offset.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_convolves\" name=\"property_convolves\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$convolves</h3>\n                <pre class=\"signature\">$convolves : </pre>\n                <p><em>Custom convolution expressions, matrix 3x3, divisor and offset.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_fillToFit\" name=\"property_fillToFit\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$fillToFit</h3>\n                <pre class=\"signature\">$fillToFit : </pre>\n                <p><em>Resize strategy to fill extra area with background color.</em></p>\n                <p>True or false.</p>\n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_scale\" name=\"property_scale\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$scale</h3>\n                <pre class=\"signature\">$scale : </pre>\n                <p><em>To store value for option scale.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_rotateBefore\" name=\"property_rotateBefore\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$rotateBefore</h3>\n                <pre class=\"signature\">$rotateBefore : </pre>\n                <p><em>To store value for option.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_rotateAfter\" name=\"property_rotateAfter\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$rotateAfter</h3>\n                <pre class=\"signature\">$rotateAfter : </pre>\n                <p><em>To store value for option.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_autoRotate\" name=\"property_autoRotate\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$autoRotate</h3>\n                <pre class=\"signature\">$autoRotate : </pre>\n                <p><em>To store value for option.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_sharpen\" name=\"property_sharpen\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$sharpen</h3>\n                <pre class=\"signature\">$sharpen : </pre>\n                <p><em>To store value for option.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_emboss\" name=\"property_emboss\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$emboss</h3>\n                <pre class=\"signature\">$emboss : </pre>\n                <p><em>To store value for option.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_blur\" name=\"property_blur\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$blur</h3>\n                <pre class=\"signature\">$blur : </pre>\n                <p><em>To store value for option.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_offset\" name=\"property_offset\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$offset</h3>\n                <pre class=\"signature\">$offset : </pre>\n                <p><em>Used with option area to set which parts of the image to use.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_fillWidth\" name=\"property_fillWidth\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$fillWidth</h3>\n                <pre class=\"signature\">$fillWidth : </pre>\n                <p><em>Calculate target dimension for image when using fill-to-fit resize strategy.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_fillHeight\" name=\"property_fillHeight\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$fillHeight</h3>\n                <pre class=\"signature\">$fillHeight : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_allowRemote\" name=\"property_allowRemote\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$allowRemote</h3>\n                <pre class=\"signature\">$allowRemote : </pre>\n                <p><em>Allow remote file download, default is to disallow remote file download.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_remotePattern\" name=\"property_remotePattern\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$remotePattern</h3>\n                <pre class=\"signature\">$remotePattern : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_useCache\" name=\"property_useCache\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$useCache</h3>\n                <pre class=\"signature\">$useCache : </pre>\n                <p><em>Use the cache if true, set to false to ignore the cached file.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_remoteHostWhitelist\" name=\"property_remoteHostWhitelist\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$remoteHostWhitelist</h3>\n                <pre class=\"signature\">$remoteHostWhitelist : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_verboseFileName\" name=\"property_verboseFileName\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$verboseFileName</h3>\n                <pre class=\"signature\">$verboseFileName : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_asciiOptions\" name=\"property_asciiOptions\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$asciiOptions</h3>\n                <pre class=\"signature\">$asciiOptions : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_copyStrategy\" name=\"property_copyStrategy\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$copyStrategy</h3>\n                <pre class=\"signature\">$copyStrategy : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_cropWidth\" name=\"property_cropWidth\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$cropWidth</h3>\n                <pre class=\"signature\">$cropWidth : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_cropHeight\" name=\"property_cropHeight\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$cropHeight</h3>\n                <pre class=\"signature\">$cropHeight : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_attr\" name=\"property_attr\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$attr</h3>\n                <pre class=\"signature\">$attr : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"methods\" name=\"methods\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\"><h2>Methods</h2></div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method___construct\" name=\"method___construct\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">__construct()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">__construct(string  <span class=\"argument\">$imageSrc = null</span>, string  <span class=\"argument\">$imageFolder = null</span>, string  <span class=\"argument\">$saveFolder = null</span>, string  <span class=\"argument\">$saveName = null</span>) </pre>\n                <p><em>Constructor, can take arguments to init the object.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$imageSrc </td>\n                                <td><p>filename which may contain subdirectory.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$imageFolder </td>\n                                <td><p>path to root folder for images.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$saveFolder </td>\n                                <td><p>path to folder where to save the new file or null to skip saving.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$saveName </td>\n                                <td><p>name of target file when saveing.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setVerbose\" name=\"method_setVerbose\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setVerbose()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setVerbose(boolean  <span class=\"argument\">$mode = true</span>) : $this</pre>\n                <p><em>Set verbose mode.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$mode </td>\n                                <td><p>true or false to enable and disable verbose mode,\ndefault is true.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setSaveFolder\" name=\"method_setSaveFolder\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setSaveFolder()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setSaveFolder(string  <span class=\"argument\">$path</span>) : $this</pre>\n                <p><em>Set save folder, base folder for saving cache files.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$path </td>\n                                <td><p>where to store cached files.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            todo\n                        </th>\n                        <td>\n                                                                                            <p>clean up how $this-&gt;saveFolder is used in other methods.</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_useCache\" name=\"method_useCache\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">useCache()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">useCache(boolean  <span class=\"argument\">$use = true</span>) : $this</pre>\n                <p><em>Use cache or not.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$use </td>\n                                <td><p>true or false to use cache.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_createDummyImage\" name=\"method_createDummyImage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">createDummyImage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">createDummyImage(integer  <span class=\"argument\">$width = null</span>, integer  <span class=\"argument\">$height = null</span>) : $this</pre>\n                <p><em>Create and save a dummy image. Use dimensions as stated in\n$this-&gt;newWidth, or $width or default to 100 (same for height.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$width </td>\n                                <td><p>use specified width for image dimension.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$height </td>\n                                <td><p>use specified width for image dimension.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setRemoteDownload\" name=\"method_setRemoteDownload\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setRemoteDownload()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setRemoteDownload(boolean  <span class=\"argument\">$allow</span>, string  <span class=\"argument\">$pattern = null</span>) : $this</pre>\n                <p><em>Allow or disallow remote image download.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$allow </td>\n                                <td><p>true or false to enable and disable.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$pattern </td>\n                                <td><p>to use to detect if its a remote file.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_isRemoteSource\" name=\"method_isRemoteSource\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">isRemoteSource()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">isRemoteSource(string  <span class=\"argument\">$src</span>) : boolean</pre>\n                <p><em>Check if the image resource is a remote file or not.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$src </td>\n                                <td><p>check if src is remote.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    boolean\n                                            &mdash; <p>true if $src is a remote file, else false.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setRemoteHostWhitelist\" name=\"method_setRemoteHostWhitelist\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setRemoteHostWhitelist()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setRemoteHostWhitelist(array  <span class=\"argument\">$whitelist = null</span>) : $this</pre>\n                <p><em>Set whitelist for valid hostnames from where remote source can be\ndownloaded.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>array</td>\n                                <td>$whitelist </td>\n                                <td><p>with regexp hostnames to allow download from.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_isRemoteSourceOnWhitelist\" name=\"method_isRemoteSourceOnWhitelist\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">isRemoteSourceOnWhitelist()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">isRemoteSourceOnWhitelist(string  <span class=\"argument\">$src</span>) : boolean</pre>\n                <p><em>Check if the hostname for the remote image, is on a whitelist,\nif the whitelist is defined.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$src </td>\n                                <td><p>the remote source.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    boolean\n                                            &mdash; <p>true if hostname on $src is in the whitelist, else false.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_downloadRemoteSource\" name=\"method_downloadRemoteSource\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">downloadRemoteSource()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">downloadRemoteSource(string  <span class=\"argument\">$src</span>) : string</pre>\n                <p><em>Download a remote image and return path to its local copy.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$src </td>\n                                <td><p>remote path to image.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as path to downloaded remote source.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setSource\" name=\"method_setSource\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setSource()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setSource(string  <span class=\"argument\">$src</span>, string  <span class=\"argument\">$dir = null</span>) : $this</pre>\n                <p><em>Set source file to use as image source.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$src </td>\n                                <td><p>of image.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$dir </td>\n                                <td><p>as optional base directory where images are.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setTarget\" name=\"method_setTarget\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setTarget()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setTarget(string  <span class=\"argument\">$src = null</span>, string  <span class=\"argument\">$dir = null</span>) : $this</pre>\n                <p><em>Set target file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$src </td>\n                                <td><p>of target image.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$dir </td>\n                                <td><p>as optional base directory where images are stored.\nUses $this-&gt;saveFolder if null.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getTarget\" name=\"method_getTarget\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getTarget()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getTarget() : Boolean|String</pre>\n                <p><em>Get filename of target file.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    Boolean|String\n                                            &mdash; <p>as filename of target or false if not set.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setOptions\" name=\"method_setOptions\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setOptions()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setOptions(array  <span class=\"argument\">$args</span>) : $this</pre>\n                <p><em>Set options to use when processing image.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>array</td>\n                                <td>$args </td>\n                                <td><p>used when processing image.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_loadImageDetails\" name=\"method_loadImageDetails\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">loadImageDetails()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">loadImageDetails(string  <span class=\"argument\">$file = null</span>) : $this</pre>\n                <p><em>Load image details from original image file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$file </td>\n                                <td><p>the file to load or null to use $this-&gt;pathToImage.</p></td>\n                            </tr>\n                                            </table>\n                \n                                    <h4>Throws</h4>\n                    <dl>\n                                                    <dt>\\Exception</dt>\n                            <dd></dd>\n                                                                    </dl>\n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_initDimensions\" name=\"method_initDimensions\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">initDimensions()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">initDimensions() : $this</pre>\n                <p><em>Init new width and height and do some sanity checks on constraints, before any\nprocessing can be done.</em></p>\n                \n\n                \n                                    <h4>Throws</h4>\n                    <dl>\n                                                    <dt>\\Exception</dt>\n                            <dd></dd>\n                                                                    </dl>\n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_calculateNewWidthAndHeight\" name=\"method_calculateNewWidthAndHeight\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">calculateNewWidthAndHeight()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">calculateNewWidthAndHeight() : $this</pre>\n                <p><em>Calculate new width and height of image, based on settings.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_reCalculateDimensions\" name=\"method_reCalculateDimensions\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">reCalculateDimensions()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">reCalculateDimensions() : $this</pre>\n                <p><em>Re-calculate image dimensions when original image dimension has changed.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setSaveAsExtension\" name=\"method_setSaveAsExtension\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setSaveAsExtension()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setSaveAsExtension(  <span class=\"argument\">$saveAs = null</span>) : $this</pre>\n                <p><em>Set extension for filename to save as.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td></td>\n                                <td>$saveAs </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setJpegQuality\" name=\"method_setJpegQuality\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setJpegQuality()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setJpegQuality(integer  <span class=\"argument\">$quality = null</span>) : $this</pre>\n                <p><em>Set JPEG quality to use when saving image</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$quality </td>\n                                <td><p>as the quality to set.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setPngCompression\" name=\"method_setPngCompression\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setPngCompression()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setPngCompression(integer  <span class=\"argument\">$compress = null</span>) : $this</pre>\n                <p><em>Set PNG compressen algorithm to use when saving image</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$compress </td>\n                                <td><p>as the algorithm to use.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_useOriginalIfPossible\" name=\"method_useOriginalIfPossible\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">useOriginalIfPossible()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">useOriginalIfPossible(boolean  <span class=\"argument\">$useOrig = true</span>) : $this</pre>\n                <p><em>Use original image if possible, check options which affects image processing.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$useOrig </td>\n                                <td><p>default is to use original if possible, else set to false.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_generateFilename\" name=\"method_generateFilename\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">generateFilename()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">generateFilename(string  <span class=\"argument\">$base = null</span>, boolean  <span class=\"argument\">$useSubdir = true</span>) : $this</pre>\n                <p><em>Generate filename to save file in cache.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$base </td>\n                                <td><p>as optional basepath for storing file.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$useSubdir </td>\n                                <td><p>use or skip the subdir part when creating the\nfilename.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_useCacheIfPossible\" name=\"method_useCacheIfPossible\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">useCacheIfPossible()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">useCacheIfPossible(boolean  <span class=\"argument\">$useCache = true</span>) : $this</pre>\n                <p><em>Use cached version of image, if possible.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$useCache </td>\n                                <td><p>is default true, set to false to avoid using cached object.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_load\" name=\"method_load\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">load()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">load(string  <span class=\"argument\">$src = null</span>, string  <span class=\"argument\">$dir = null</span>) : $this</pre>\n                <p><em>Load image from disk. Try to load image without verbose error message,\nif fail, load again and display error messages.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$src </td>\n                                <td><p>of image.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$dir </td>\n                                <td><p>as base directory where images are.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getPngType\" name=\"method_getPngType\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getPngType()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getPngType(string  <span class=\"argument\">$filename = null</span>) : integer</pre>\n                <p><em>Get the type of PNG image.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$filename </td>\n                                <td><p>to use instead of default.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>as the type of the png-image</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_preResize\" name=\"method_preResize\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">preResize()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">preResize() : $this</pre>\n                <p><em>Preprocess image before rezising it.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setCopyResizeStrategy\" name=\"method_setCopyResizeStrategy\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setCopyResizeStrategy()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setCopyResizeStrategy(integer  <span class=\"argument\">$strategy</span>) : $this</pre>\n                <p><em>Resize or resample the image while resizing.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$strategy </td>\n                                <td><p>as CImage::RESIZE or CImage::RESAMPLE</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_imageCopyResampled\" name=\"method_imageCopyResampled\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">imageCopyResampled()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">imageCopyResampled(  <span class=\"argument\">$dst_image</span>,   <span class=\"argument\">$src_image</span>,   <span class=\"argument\">$dst_x</span>,   <span class=\"argument\">$dst_y</span>,   <span class=\"argument\">$src_x</span>,   <span class=\"argument\">$src_y</span>,   <span class=\"argument\">$dst_w</span>,   <span class=\"argument\">$dst_h</span>,   <span class=\"argument\">$src_w</span>,   <span class=\"argument\">$src_h</span>) : void</pre>\n                <p><em>Resize and or crop the image.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td></td>\n                                <td>$dst_image </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$src_image </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$dst_x </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$dst_y </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$src_x </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$src_y </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$dst_w </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$dst_h </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$src_w </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$src_h </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_resize\" name=\"method_resize\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">resize()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">resize() : $this</pre>\n                <p><em>Resize and or crop the image.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_postResize\" name=\"method_postResize\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">postResize()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">postResize() : $this</pre>\n                <p><em>Postprocess image after rezising image.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_rotate\" name=\"method_rotate\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">rotate()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">rotate(float  <span class=\"argument\">$angle</span>,   <span class=\"argument\">$bgColor</span>) : $this</pre>\n                <p><em>Rotate image using angle.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>float</td>\n                                <td>$angle </td>\n                                <td><p>to rotate image.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td></td>\n                                <td>$bgColor </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_rotateExif\" name=\"method_rotateExif\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">rotateExif()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">rotateExif() : $this</pre>\n                <p><em>Rotate image using information in EXIF.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_trueColorToPalette\" name=\"method_trueColorToPalette\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">trueColorToPalette()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">trueColorToPalette() : void</pre>\n                <p><em>Convert true color image to palette image, keeping alpha.</em></p>\n                <p><a href=\"http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\">http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library</a></p>\n\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_sharpenImage\" name=\"method_sharpenImage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">sharpenImage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">sharpenImage() : $this</pre>\n                <p><em>Sharpen image using image convolution.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_embossImage\" name=\"method_embossImage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">embossImage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">embossImage() : $this</pre>\n                <p><em>Emboss image using image convolution.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_blurImage\" name=\"method_blurImage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">blurImage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">blurImage() : $this</pre>\n                <p><em>Blur image using image convolution.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_createConvolveArguments\" name=\"method_createConvolveArguments\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">createConvolveArguments()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">createConvolveArguments(string  <span class=\"argument\">$expression</span>) : array</pre>\n                <p><em>Create convolve expression and return arguments for image convolution.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$expression </td>\n                                <td><p>constant string which evaluates to a list of\n11 numbers separated by komma or such a list.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                            &mdash; <p>as $matrix (3x3), $divisor and $offset</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_addConvolveExpressions\" name=\"method_addConvolveExpressions\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">addConvolveExpressions()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">addConvolveExpressions(array  <span class=\"argument\">$options</span>) : $this</pre>\n                <p><em>Add custom expressions (or overwrite existing) for image convolution.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>array</td>\n                                <td>$options </td>\n                                <td><p>Key value array with strings to be converted\nto convolution expressions.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_imageConvolution\" name=\"method_imageConvolution\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">imageConvolution()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">imageConvolution(string  <span class=\"argument\">$options = null</span>) : $this</pre>\n                <p><em>Image convolution.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$options </td>\n                                <td><p>A string with 11 float separated by comma.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setDefaultBackgroundColor\" name=\"method_setDefaultBackgroundColor\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setDefaultBackgroundColor()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setDefaultBackgroundColor(string  <span class=\"argument\">$color</span>) : $this</pre>\n                <p><em>Set default background color between 000000-FFFFFF or if using\nalpha 00000000-FFFFFF7F.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$color </td>\n                                <td><p>as hex value.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setPostProcessingOptions\" name=\"method_setPostProcessingOptions\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setPostProcessingOptions()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setPostProcessingOptions(array  <span class=\"argument\">$options</span>) : $this</pre>\n                <p><em>Set optimizing  and post-processing options.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>array</td>\n                                <td>$options </td>\n                                <td><p>with config for postprocessing with external tools.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_save\" name=\"method_save\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">save()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">save(string  <span class=\"argument\">$src = null</span>, string  <span class=\"argument\">$base = null</span>, boolean  <span class=\"argument\">$overwrite = true</span>) : $this</pre>\n                <p><em>Save image.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$src </td>\n                                <td><p>as target filename.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$base </td>\n                                <td><p>as base directory where to store images.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$overwrite </td>\n                                <td><p>or not, default to always overwrite file.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                            &mdash; <p>or false if no folder is set.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_linkToCacheFile\" name=\"method_linkToCacheFile\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">linkToCacheFile()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">linkToCacheFile(string  <span class=\"argument\">$alias</span>) : $this</pre>\n                <p><em>Create a hard link, as an alias, to the cached file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$alias </td>\n                                <td><p>where to store the link,\nfilename without extension.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_addHTTPHeader\" name=\"method_addHTTPHeader\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">addHTTPHeader()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">addHTTPHeader(string  <span class=\"argument\">$type</span>, string  <span class=\"argument\">$value</span>) : void</pre>\n                <p><em>Add HTTP header for putputting together with image.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$type </td>\n                                <td><p>the header type such as &quot;Cache-Control&quot;</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$value </td>\n                                <td><p>the value to use</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_output\" name=\"method_output\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">output()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">output(string  <span class=\"argument\">$file = null</span>, string  <span class=\"argument\">$format = null</span>) : void</pre>\n                <p><em>Output image to browser using caching.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$file </td>\n                                <td><p>to read and output, default is to\nuse $this-&gt;cacheFileName</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$format </td>\n                                <td><p>set to json to output file as json\nobject with details</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_json\" name=\"method_json\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">json()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">json(string  <span class=\"argument\">$file = null</span>) : string</pre>\n                <p><em>Create a JSON object from the image details.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$file </td>\n                                <td><p>the file to output.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>json-encoded representation of the image.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setAsciiOptions\" name=\"method_setAsciiOptions\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setAsciiOptions()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setAsciiOptions(array  <span class=\"argument\">$options = array()</span>) : \\void.</pre>\n                <p><em>Set options for creating ascii version of image.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>array</td>\n                                <td>$options </td>\n                                <td><p>empty to use default or set options to change.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    \\void.\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_ascii\" name=\"method_ascii\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">ascii()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">ascii(string  <span class=\"argument\">$file = null</span>) : string</pre>\n                <p><em>Create an ASCII version from the image details.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$file </td>\n                                <td><p>the file to output.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>ASCII representation of the image.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_log\" name=\"method_log\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">log()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">log(string  <span class=\"argument\">$message</span>) : \\this</pre>\n                <p><em>Log an event if verbose mode.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$message </td>\n                                <td><p>to log.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    \\this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setVerboseToFile\" name=\"method_setVerboseToFile\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setVerboseToFile()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setVerboseToFile(string  <span class=\"argument\">$fileName</span>) : void</pre>\n                <p><em>Do verbose output to a file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$fileName </td>\n                                <td><p>where to write the verbose output.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getTargetImageExtension\" name=\"method_getTargetImageExtension\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"protected \">getTargetImageExtension()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getTargetImageExtension() : string</pre>\n                <p><em>Find out the type (file extension) for the image to be saved.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as image extension.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_checkFileExtension\" name=\"method_checkFileExtension\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">checkFileExtension()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">checkFileExtension(string  <span class=\"argument\">$extension</span>) : $this</pre>\n                <p><em>Check if file extension is valid as a file extension.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$extension </td>\n                                <td><p>of image file.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_normalizeFileExtension\" name=\"method_normalizeFileExtension\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">normalizeFileExtension()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">normalizeFileExtension(string  <span class=\"argument\">$extension = null</span>) : string</pre>\n                <p><em>Normalize the file extension.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$extension </td>\n                                <td><p>of image file or skip to use internal.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>$extension as a normalized file extension.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_mapFilter\" name=\"method_mapFilter\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">mapFilter()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">mapFilter(string  <span class=\"argument\">$name</span>) : array</pre>\n                <p><em>Map filter name to PHP filter and id.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$name </td>\n                                <td><p>the name of the filter.</p></td>\n                            </tr>\n                                            </table>\n                \n                                    <h4>Throws</h4>\n                    <dl>\n                                                    <dt>\\Exception</dt>\n                            <dd></dd>\n                                                                    </dl>\n                \n                                    <h4>Returns</h4>\n                    array\n                                            &mdash; <p>with filter settings</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getPngTypeAsString\" name=\"method_getPngTypeAsString\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">getPngTypeAsString()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getPngTypeAsString(  <span class=\"argument\">$pngType = null</span>, string  <span class=\"argument\">$filename = null</span>) : integer</pre>\n                <p><em>Get the type of PNG image as a verbose string.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td></td>\n                                <td>$pngType </td>\n                                <td></td>\n                            </tr>\n                                                    <tr>\n                                <td>string</td>\n                                <td>$filename </td>\n                                <td><p>to use instead of default.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>as the type of the png-image</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_colorsTotal\" name=\"method_colorsTotal\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">colorsTotal()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">colorsTotal(resource  <span class=\"argument\">$im</span>) : integer</pre>\n                <p><em>Calculate number of colors in an image.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>resource</td>\n                                <td>$im </td>\n                                <td><p>the image.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getBackgroundColor\" name=\"method_getBackgroundColor\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">getBackgroundColor()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getBackgroundColor(resource  <span class=\"argument\">$img = null</span>) : \\color</pre>\n                <p><em>Get the background color.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>resource</td>\n                                <td>$img </td>\n                                <td><p>the image to work with or null if using $this-&gt;image.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    \\color\n                                            &mdash; <p>value or null if no background color is set.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_createImageKeepTransparency\" name=\"method_createImageKeepTransparency\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">createImageKeepTransparency()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">createImageKeepTransparency(integer  <span class=\"argument\">$width</span>, integer  <span class=\"argument\">$height</span>) : \\image</pre>\n                <p><em>Create a image and keep transparency for png and gifs.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$width </td>\n                                <td><p>of the new image.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>integer</td>\n                                <td>$height </td>\n                                <td><p>of the new image.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    \\image\n                                            &mdash; <p>resource.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_verboseOutput\" name=\"method_verboseOutput\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">verboseOutput()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">verboseOutput() : void</pre>\n                <p><em>Do verbose output and print out the log and the actual images.</em></p>\n                \n\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_raiseError\" name=\"method_raiseError\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"private \">raiseError()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">raiseError(string  <span class=\"argument\">$message</span>) : void</pre>\n                <p><em>Raise error, enables to implement a selection of error methods.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$message </td>\n                                <td><p>the error message to display.</p></td>\n                            </tr>\n                                            </table>\n                \n                                    <h4>Throws</h4>\n                    <dl>\n                                                    <dt>\\Exception</dt>\n                            <dd></dd>\n                                                                    </dl>\n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\">CImage.php</h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CImage.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/classes/CImage_RemoteDownloadTest.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    <script type=\"text/javascript\">\n    function loadExternalCodeSnippets() {\n        Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n            var src = pre.getAttribute('data-src');\n            var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n            var language = 'php';\n\n            var code = document.createElement('code');\n            code.className = 'language-' + language;\n\n            pre.textContent = '';\n\n            code.textContent = 'Loading…';\n\n            pre.appendChild(code);\n\n            var xhr = new XMLHttpRequest();\n\n            xhr.open('GET', src, true);\n\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState == 4) {\n\n                    if (xhr.status < 400 && xhr.responseText) {\n                        code.textContent = xhr.responseText;\n\n                        Prism.highlightElement(code);\n                    }\n                    else if (xhr.status >= 400) {\n                        code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                    }\n                    else {\n                        code.textContent = '✖ Error: File does not exist or is empty';\n                    }\n                }\n            };\n\n            xhr.send(null);\n        });\n    }\n\n    $(document).ready(function(){\n        loadExternalCodeSnippets();\n    });\n    $('#source-view').on('shown', function () {\n        loadExternalCodeSnippets();\n    })\n</script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-215373945\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-215373945\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <nav>\n                                                <a href=\"../namespaces/default.html\">\\</a> <i class=\"icon-level-up\"></i>\n                                            </nav>\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n\n                    <h1><small>\\</small>CImage_RemoteDownloadTest</h1>\n                    <p><em>A testclass</em></p>\n                    \n                    \n                                        \n                    <section id=\"summary\">\n                        <h2>Summary</h2>\n                        <section class=\"row-fluid heading\">\n                            <section class=\"span4\">\n                                <a href=\"#methods\">Methods</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#properties\">Properties</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#constants\">Constants</a>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid public\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_providerValidRemoteSource\" class=\"\">providerValidRemoteSource()</a><br />\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_providerInvalidRemoteSource\" class=\"\">providerInvalidRemoteSource()</a><br />\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_testAllowRemoteDownloadDefaultPatternValid\" class=\"\">testAllowRemoteDownloadDefaultPatternValid()</a><br />\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_testAllowRemoteDownloadDefaultPatternInvalid\" class=\"\">testAllowRemoteDownloadDefaultPatternInvalid()</a><br />\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_providerHostnameMatch\" class=\"\">providerHostnameMatch()</a><br />\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_testRemoteHostWhitelistMatch\" class=\"\">testRemoteHostWhitelistMatch()</a><br />\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_providerHostnameNoMatch\" class=\"\">providerHostnameNoMatch()</a><br />\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#method_testRemoteHostWhitelistNoMatch\" class=\"\">testRemoteHostWhitelistNoMatch()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No public properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No constants found</em>\n                                                            </section>\n                        </section>\n                        <section class=\"row-fluid protected\">\n                            <section class=\"span4\">\n                                                                    <em>No protected methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No protected properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid private\">\n                            <section class=\"span4\">\n                                                                    <em>No private methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CImage_RemoteDownloadTest.html#property_remote_whitelist\" class=\"\">$remote_whitelist</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                    </section>\n                </div>\n                <aside class=\"span4 detailsbar\">\n                                        \n                    \n                    <dl>\n                        <dt>File</dt>\n                            <dd><a href=\"../files/test.CImage_RemoteDownloadTest.html\"><div class=\"path-wrapper\">test/CImage_RemoteDownloadTest.php</div></a></dd>\n                                                <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">Default</div></dd>\n                                                <dt>Class hierarchy</dt>\n                            <dd class=\"hierarchy\">\n                                                                                                                                                                                                                                                                                                \n                                        <div class=\"namespace-wrapper\">\\PHPUnit_Framework_TestCase</div>\n                                                                                                    <div class=\"namespace-wrapper\">\\CImage_RemoteDownloadTest</div>\n                            </dd>\n\n                        \n                        \n                        \n                        \n                                                                        </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                            <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                        </table>\n                </aside>\n            </div>\n\n                        \n                                    <a id=\"properties\" name=\"properties\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Properties</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_remote_whitelist\" name=\"property_remote_whitelist\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$remote_whitelist</h3>\n                <pre class=\"signature\">$remote_whitelist : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"methods\" name=\"methods\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\"><h2>Methods</h2></div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_providerValidRemoteSource\" name=\"method_providerValidRemoteSource\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">providerValidRemoteSource()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">providerValidRemoteSource() : array</pre>\n                <p><em>Provider for valid remote sources.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_providerInvalidRemoteSource\" name=\"method_providerInvalidRemoteSource\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">providerInvalidRemoteSource()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">providerInvalidRemoteSource() : array</pre>\n                <p><em>Provider for invalid remote sources.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_testAllowRemoteDownloadDefaultPatternValid\" name=\"method_testAllowRemoteDownloadDefaultPatternValid\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">testAllowRemoteDownloadDefaultPatternValid()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">testAllowRemoteDownloadDefaultPatternValid(  <span class=\"argument\">$source</span>) : void</pre>\n                <p><em>Test</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td></td>\n                                <td>$source </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            dataProvider\n                        </th>\n                        <td>\n                                                                                            <p>providerValidRemoteSource</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_testAllowRemoteDownloadDefaultPatternInvalid\" name=\"method_testAllowRemoteDownloadDefaultPatternInvalid\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">testAllowRemoteDownloadDefaultPatternInvalid()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">testAllowRemoteDownloadDefaultPatternInvalid(  <span class=\"argument\">$source</span>) : void</pre>\n                <p><em>Test</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td></td>\n                                <td>$source </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            dataProvider\n                        </th>\n                        <td>\n                                                                                            <p>providerInvalidRemoteSource</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_providerHostnameMatch\" name=\"method_providerHostnameMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">providerHostnameMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">providerHostnameMatch() : array</pre>\n                <p><em>Provider for hostname matching the whitelist.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_testRemoteHostWhitelistMatch\" name=\"method_testRemoteHostWhitelistMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">testRemoteHostWhitelistMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">testRemoteHostWhitelistMatch(string  <span class=\"argument\">$hostname</span>) : void</pre>\n                <p><em>Test</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$hostname </td>\n                                <td><p>matches the whitelist</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            dataProvider\n                        </th>\n                        <td>\n                                                                                            <p>providerHostnameMatch</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_providerHostnameNoMatch\" name=\"method_providerHostnameNoMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">providerHostnameNoMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">providerHostnameNoMatch() : array</pre>\n                <p><em>Provider for hostname not matching the whitelist.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_testRemoteHostWhitelistNoMatch\" name=\"method_testRemoteHostWhitelistNoMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">testRemoteHostWhitelistNoMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">testRemoteHostWhitelistNoMatch(string  <span class=\"argument\">$hostname</span>) : void</pre>\n                <p><em>Test</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$hostname </td>\n                                <td><p>not matching the whitelist</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            dataProvider\n                        </th>\n                        <td>\n                                                                                            <p>providerHostnameNoMatch</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                                    </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\">CImage_RemoteDownloadTest.php</h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/test/CImage_RemoteDownloadTest.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/classes/CRemoteImage.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    <script type=\"text/javascript\">\n    function loadExternalCodeSnippets() {\n        Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n            var src = pre.getAttribute('data-src');\n            var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n            var language = 'php';\n\n            var code = document.createElement('code');\n            code.className = 'language-' + language;\n\n            pre.textContent = '';\n\n            code.textContent = 'Loading…';\n\n            pre.appendChild(code);\n\n            var xhr = new XMLHttpRequest();\n\n            xhr.open('GET', src, true);\n\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState == 4) {\n\n                    if (xhr.status < 400 && xhr.responseText) {\n                        code.textContent = xhr.responseText;\n\n                        Prism.highlightElement(code);\n                    }\n                    else if (xhr.status >= 400) {\n                        code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                    }\n                    else {\n                        code.textContent = '✖ Error: File does not exist or is empty';\n                    }\n                }\n            };\n\n            xhr.send(null);\n        });\n    }\n\n    $(document).ready(function(){\n        loadExternalCodeSnippets();\n    });\n    $('#source-view').on('shown', function () {\n        loadExternalCodeSnippets();\n    })\n</script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1171772037\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1171772037\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <nav>\n                                                <a href=\"../namespaces/default.html\">\\</a> <i class=\"icon-level-up\"></i>\n                                            </nav>\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n\n                    <h1><small>\\</small>CRemoteImage</h1>\n                    <p><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></p>\n                    \n                    \n                                        \n                    <section id=\"summary\">\n                        <h2>Summary</h2>\n                        <section class=\"row-fluid heading\">\n                            <section class=\"span4\">\n                                <a href=\"#methods\">Methods</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#properties\">Properties</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#constants\">Constants</a>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid public\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CRemoteImage.html#method_getStatus\" class=\"\">getStatus()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_getDetails\" class=\"\">getDetails()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_setCache\" class=\"\">setCache()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_isCacheWritable\" class=\"\">isCacheWritable()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_useCache\" class=\"\">useCache()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_setHeaderFields\" class=\"\">setHeaderFields()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_save\" class=\"\">save()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_updateCacheDetails\" class=\"\">updateCacheDetails()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_download\" class=\"\">download()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_loadCacheDetails\" class=\"\">loadCacheDetails()</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#method_getCachedSource\" class=\"\">getCachedSource()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No public properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No constants found</em>\n                                                            </section>\n                        </section>\n                        <section class=\"row-fluid protected\">\n                            <section class=\"span4\">\n                                                                    <em>No protected methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No protected properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid private\">\n                            <section class=\"span4\">\n                                                                    <em>No private methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CRemoteImage.html#property_saveFolder\" class=\"\">$saveFolder</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_useCache\" class=\"\">$useCache</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_http\" class=\"\">$http</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_status\" class=\"\">$status</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_defaultMaxAge\" class=\"\">$defaultMaxAge</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_url\" class=\"\">$url</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_fileName\" class=\"\">$fileName</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_fileJson\" class=\"\">$fileJson</a><br />\n                                                                    <a href=\"../classes/CRemoteImage.html#property_cache\" class=\"\">$cache</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                    </section>\n                </div>\n                <aside class=\"span4 detailsbar\">\n                                        \n                    \n                    <dl>\n                        <dt>File</dt>\n                            <dd><a href=\"../files/CRemoteImage.html\"><div class=\"path-wrapper\">CRemoteImage.php</div></a></dd>\n                                                <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">Default</div></dd>\n                                                <dt>Class hierarchy</dt>\n                            <dd class=\"hierarchy\">\n                                                                                                                                                                    <div class=\"namespace-wrapper\">\\CRemoteImage</div>\n                            </dd>\n\n                        \n                        \n                        \n                        \n                                                                        </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                            <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                        </table>\n                </aside>\n            </div>\n\n                        \n                                    <a id=\"properties\" name=\"properties\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Properties</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_saveFolder\" name=\"property_saveFolder\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$saveFolder</h3>\n                <pre class=\"signature\">$saveFolder : </pre>\n                <p><em>Path to cache files.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_useCache\" name=\"property_useCache\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$useCache</h3>\n                <pre class=\"signature\">$useCache : </pre>\n                <p><em>Use cache or not.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_http\" name=\"property_http\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$http</h3>\n                <pre class=\"signature\">$http : </pre>\n                <p><em>HTTP object to aid in download file.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_status\" name=\"property_status\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$status</h3>\n                <pre class=\"signature\">$status : </pre>\n                <p><em>Status of the HTTP request.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_defaultMaxAge\" name=\"property_defaultMaxAge\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$defaultMaxAge</h3>\n                <pre class=\"signature\">$defaultMaxAge : </pre>\n                <p><em>Defalt age for cached items 60*60*24*7.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_url\" name=\"property_url\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$url</h3>\n                <pre class=\"signature\">$url : </pre>\n                <p><em>Url of downloaded item.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_fileName\" name=\"property_fileName\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$fileName</h3>\n                <pre class=\"signature\">$fileName : </pre>\n                <p><em>Base name of cache file for downloaded item and name of image.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_fileJson\" name=\"property_fileJson\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$fileJson</h3>\n                <pre class=\"signature\">$fileJson : </pre>\n                <p><em>Filename for json-file with details of cached item.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_cache\" name=\"property_cache\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$cache</h3>\n                <pre class=\"signature\">$cache : </pre>\n                <p><em>Cache details loaded from file.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"methods\" name=\"methods\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\"><h2>Methods</h2></div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getStatus\" name=\"method_getStatus\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getStatus()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getStatus() : integer</pre>\n                <p><em>Get status of last HTTP request.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    integer\n                                            &mdash; <p>as status</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDetails\" name=\"method_getDetails\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getDetails()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDetails() : array</pre>\n                <p><em>Get JSON details for cache item.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                            &mdash; <p>with json details on cache.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setCache\" name=\"method_setCache\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setCache()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setCache(  <span class=\"argument\">$path</span>) : $this</pre>\n                <p><em>Set the path to the cache directory.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td></td>\n                                <td>$path </td>\n                                <td></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_isCacheWritable\" name=\"method_isCacheWritable\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">isCacheWritable()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">isCacheWritable() : $this</pre>\n                <p><em>Check if cache is writable or throw exception.</em></p>\n                \n\n                \n                                    <h4>Throws</h4>\n                    <dl>\n                                                    <dt>\\Exception</dt>\n                            <dd><p>if cahce folder is not writable.</p></dd>\n                                                                    </dl>\n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_useCache\" name=\"method_useCache\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">useCache()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">useCache(boolean  <span class=\"argument\">$use = true</span>) : $this</pre>\n                <p><em>Decide if the cache should be used or not before trying to download\na remote file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>boolean</td>\n                                <td>$use </td>\n                                <td><p>true to use the cache and false to ignore cache.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_setHeaderFields\" name=\"method_setHeaderFields\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">setHeaderFields()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">setHeaderFields() : $this</pre>\n                <p><em>Set header fields.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_save\" name=\"method_save\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">save()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">save() : string</pre>\n                <p><em>Save downloaded resource to cache.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as path to saved file or false if not saved.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_updateCacheDetails\" name=\"method_updateCacheDetails\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">updateCacheDetails()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">updateCacheDetails() : string</pre>\n                <p><em>Got a 304 and updates cache with new age.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as path to cached file.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_download\" name=\"method_download\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">download()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">download(string  <span class=\"argument\">$url</span>) : string</pre>\n                <p><em>Download a remote file and keep a cache of downloaded files.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$url </td>\n                                <td><p>a remote url.</p></td>\n                            </tr>\n                                            </table>\n                \n                                    <h4>Throws</h4>\n                    <dl>\n                                                    <dt>\\Exception</dt>\n                            <dd><p>when status code does not match 200 or 304.</p></dd>\n                                                                    </dl>\n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as path to downloaded file or false if failed.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_loadCacheDetails\" name=\"method_loadCacheDetails\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">loadCacheDetails()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">loadCacheDetails() : $this</pre>\n                <p><em>Get the path to the cached image file if the cache is valid.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getCachedSource\" name=\"method_getCachedSource\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">getCachedSource()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getCachedSource() : string</pre>\n                <p><em>Get the path to the cached image file if the cache is valid.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    string\n                                            &mdash; <p>as the path ot the image file or false if no cache.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                                    </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\">CRemoteImage.php</h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CRemoteImage.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/classes/CWhitelist.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    <script type=\"text/javascript\">\n    function loadExternalCodeSnippets() {\n        Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n            var src = pre.getAttribute('data-src');\n            var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n            var language = 'php';\n\n            var code = document.createElement('code');\n            code.className = 'language-' + language;\n\n            pre.textContent = '';\n\n            code.textContent = 'Loading…';\n\n            pre.appendChild(code);\n\n            var xhr = new XMLHttpRequest();\n\n            xhr.open('GET', src, true);\n\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState == 4) {\n\n                    if (xhr.status < 400 && xhr.responseText) {\n                        code.textContent = xhr.responseText;\n\n                        Prism.highlightElement(code);\n                    }\n                    else if (xhr.status >= 400) {\n                        code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                    }\n                    else {\n                        code.textContent = '✖ Error: File does not exist or is empty';\n                    }\n                }\n            };\n\n            xhr.send(null);\n        });\n    }\n\n    $(document).ready(function(){\n        loadExternalCodeSnippets();\n    });\n    $('#source-view').on('shown', function () {\n        loadExternalCodeSnippets();\n    })\n</script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1100227540\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1100227540\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <nav>\n                                                <a href=\"../namespaces/default.html\">\\</a> <i class=\"icon-level-up\"></i>\n                                            </nav>\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n\n                    <h1><small>\\</small>CWhitelist</h1>\n                    <p><em>Act as whitelist (or blacklist).</em></p>\n                    \n                    \n                                        \n                    <section id=\"summary\">\n                        <h2>Summary</h2>\n                        <section class=\"row-fluid heading\">\n                            <section class=\"span4\">\n                                <a href=\"#methods\">Methods</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#properties\">Properties</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#constants\">Constants</a>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid public\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CWhitelist.html#method_set\" class=\"\">set()</a><br />\n                                                                    <a href=\"../classes/CWhitelist.html#method_check\" class=\"\">check()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No public properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No constants found</em>\n                                                            </section>\n                        </section>\n                        <section class=\"row-fluid protected\">\n                            <section class=\"span4\">\n                                                                    <em>No protected methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No protected properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid private\">\n                            <section class=\"span4\">\n                                                                    <em>No private methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CWhitelist.html#property_whitelist\" class=\"\">$whitelist</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                    </section>\n                </div>\n                <aside class=\"span4 detailsbar\">\n                                        \n                    \n                    <dl>\n                        <dt>File</dt>\n                            <dd><a href=\"../files/CWhitelist.html\"><div class=\"path-wrapper\">CWhitelist.php</div></a></dd>\n                                                <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">Default</div></dd>\n                                                <dt>Class hierarchy</dt>\n                            <dd class=\"hierarchy\">\n                                                                                                                                                                    <div class=\"namespace-wrapper\">\\CWhitelist</div>\n                            </dd>\n\n                        \n                        \n                        \n                        \n                                                                        </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                            <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                        </table>\n                </aside>\n            </div>\n\n                        \n                                    <a id=\"properties\" name=\"properties\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Properties</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_whitelist\" name=\"property_whitelist\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$whitelist</h3>\n                <pre class=\"signature\">$whitelist : </pre>\n                <p><em>Array to contain the whitelist options.</em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"methods\" name=\"methods\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\"><h2>Methods</h2></div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_set\" name=\"method_set\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">set()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">set(array  <span class=\"argument\">$whitelist = array()</span>) : $this</pre>\n                <p><em>Set the whitelist from an array of strings, each item in the\nwhitelist should be a regexp without the surrounding / or #.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>array</td>\n                                <td>$whitelist </td>\n                                <td><p>with all valid options,\ndefault is to clear the whitelist.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    $this\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_check\" name=\"method_check\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">check()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">check(string  <span class=\"argument\">$item</span>, array  <span class=\"argument\">$whitelist = null</span>) : boolean</pre>\n                <p><em>Check if item exists in the whitelist.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$item </td>\n                                <td><p>string to check.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>array</td>\n                                <td>$whitelist </td>\n                                <td><p>optional with all valid options, default is null.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    boolean\n                                            &mdash; <p>true if item is in whitelist, else false.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                                    </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\">CWhitelist.php</h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CWhitelist.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/classes/CWhitelistTest.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    <script type=\"text/javascript\">\n    function loadExternalCodeSnippets() {\n        Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n            var src = pre.getAttribute('data-src');\n            var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n            var language = 'php';\n\n            var code = document.createElement('code');\n            code.className = 'language-' + language;\n\n            pre.textContent = '';\n\n            code.textContent = 'Loading…';\n\n            pre.appendChild(code);\n\n            var xhr = new XMLHttpRequest();\n\n            xhr.open('GET', src, true);\n\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState == 4) {\n\n                    if (xhr.status < 400 && xhr.responseText) {\n                        code.textContent = xhr.responseText;\n\n                        Prism.highlightElement(code);\n                    }\n                    else if (xhr.status >= 400) {\n                        code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                    }\n                    else {\n                        code.textContent = '✖ Error: File does not exist or is empty';\n                    }\n                }\n            };\n\n            xhr.send(null);\n        });\n    }\n\n    $(document).ready(function(){\n        loadExternalCodeSnippets();\n    });\n    $('#source-view').on('shown', function () {\n        loadExternalCodeSnippets();\n    })\n</script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1563306956\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1563306956\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <nav>\n                                                <a href=\"../namespaces/default.html\">\\</a> <i class=\"icon-level-up\"></i>\n                                            </nav>\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n\n                    <h1><small>\\</small>CWhitelistTest</h1>\n                    <p><em>A testclass</em></p>\n                    \n                    \n                                        \n                    <section id=\"summary\">\n                        <h2>Summary</h2>\n                        <section class=\"row-fluid heading\">\n                            <section class=\"span4\">\n                                <a href=\"#methods\">Methods</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#properties\">Properties</a>\n                            </section>\n                            <section class=\"span4\">\n                                <a href=\"#constants\">Constants</a>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid public\">\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CWhitelistTest.html#method_providerHostnameMatch\" class=\"\">providerHostnameMatch()</a><br />\n                                                                    <a href=\"../classes/CWhitelistTest.html#method_providerHostnameNoMatch\" class=\"\">providerHostnameNoMatch()</a><br />\n                                                                    <a href=\"../classes/CWhitelistTest.html#method_testRemoteHostWhitelistMatch\" class=\"\">testRemoteHostWhitelistMatch()</a><br />\n                                                                    <a href=\"../classes/CWhitelistTest.html#method_testRemoteHostWhitelistNoMatch\" class=\"\">testRemoteHostWhitelistNoMatch()</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No public properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No constants found</em>\n                                                            </section>\n                        </section>\n                        <section class=\"row-fluid protected\">\n                            <section class=\"span4\">\n                                                                    <em>No protected methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <em>No protected properties found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                        <section class=\"row-fluid private\">\n                            <section class=\"span4\">\n                                                                    <em>No private methods found</em>\n                                                            </section>\n                            <section class=\"span4\">\n                                                                    <a href=\"../classes/CWhitelistTest.html#property_remote_whitelist\" class=\"\">$remote_whitelist</a><br />\n                                                            </section>\n                            <section class=\"span4\">\n                                <em>N/A</em>\n                            </section>\n                        </section>\n                    </section>\n                </div>\n                <aside class=\"span4 detailsbar\">\n                                        \n                    \n                    <dl>\n                        <dt>File</dt>\n                            <dd><a href=\"../files/test.CWhitelistTest.html\"><div class=\"path-wrapper\">test/CWhitelistTest.php</div></a></dd>\n                                                <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">Default</div></dd>\n                                                <dt>Class hierarchy</dt>\n                            <dd class=\"hierarchy\">\n                                                                                                                                                                                                                                                                                                \n                                        <div class=\"namespace-wrapper\">\\PHPUnit_Framework_TestCase</div>\n                                                                                                    <div class=\"namespace-wrapper\">\\CWhitelistTest</div>\n                            </dd>\n\n                        \n                        \n                        \n                        \n                                                                        </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                            <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                        </table>\n                </aside>\n            </div>\n\n                        \n                                    <a id=\"properties\" name=\"properties\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\">\n                    <h2>Properties</h2>\n                </div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"property_remote_whitelist\" name=\"property_remote_whitelist\" class=\"anchor\"></a>\n            <article class=\"property\">\n                <h3 class=\"private \">$remote_whitelist</h3>\n                <pre class=\"signature\">$remote_whitelist : </pre>\n                <p><em></em></p>\n                \n\n                                <h4>Type</h4>\n                \n                                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                        <dl>\n                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n                                    <a id=\"methods\" name=\"methods\"></a>\n            <div class=\"row-fluid\">\n                <div class=\"span8 content class\"><h2>Methods</h2></div>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_providerHostnameMatch\" name=\"method_providerHostnameMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">providerHostnameMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">providerHostnameMatch() : array</pre>\n                <p><em>Provider for hostname matching the whitelist.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_providerHostnameNoMatch\" name=\"method_providerHostnameNoMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">providerHostnameNoMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">providerHostnameNoMatch() : array</pre>\n                <p><em>Provider for hostname not matching the whitelist.</em></p>\n                \n\n                \n                \n                                    <h4>Returns</h4>\n                    array\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_testRemoteHostWhitelistMatch\" name=\"method_testRemoteHostWhitelistMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">testRemoteHostWhitelistMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">testRemoteHostWhitelistMatch(string  <span class=\"argument\">$hostname</span>) : void</pre>\n                <p><em>Test</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$hostname </td>\n                                <td><p>matches the whitelist</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            dataProvider\n                        </th>\n                        <td>\n                                                                                            <p>providerHostnameMatch</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                    <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_testRemoteHostWhitelistNoMatch\" name=\"method_testRemoteHostWhitelistNoMatch\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\"public \">testRemoteHostWhitelistNoMatch()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">testRemoteHostWhitelistNoMatch(string  <span class=\"argument\">$hostname</span>) : void</pre>\n                <p><em>Test</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$hostname </td>\n                                <td><p>not matching the whitelist</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            dataProvider\n                        </th>\n                        <td>\n                                                                                            <p>providerHostnameNoMatch</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                                                    </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\">CWhitelistTest.php</h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/test/CWhitelistTest.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/css/jquery.iviewer.css",
    "content": ".viewer {\n    -ms-touch-action: none;\n}\n\n.iviewer_common {\n    position:absolute;\n    bottom:10px;\n    border: 1px  solid #000;\n    height: 28px;\n    z-index: 5000;\n}\n\n.iviewer_cursor {\n    cursor: url(../images/iviewer/hand.cur) 6 8, pointer;\n}\n\n.iviewer_drag_cursor {\n    cursor: url(../images/iviewer/grab.cur) 6 8, pointer;\n}\n\n.iviewer_button {\n    width: 28px;\n    cursor: pointer;\n    background-position: center center;\n    background-repeat: no-repeat;\n}\n\n.iviewer_zoom_in {\n    left: 20px;\n    background: url(../images/iviewer/iviewer.zoom_in.png);\n}\n\n.iviewer_zoom_out {\n    left: 55px;\n    background: url(../images/iviewer/iviewer.zoom_out.png);\n}\n\n.iviewer_zoom_zero {\n    left: 90px;\n    background: url(../images/iviewer/iviewer.zoom_zero.png);\n}\n\n.iviewer_zoom_fit {\n    left: 125px;\n    background: url(../images/iviewer/iviewer.zoom_fit.png);\n}\n\n.iviewer_zoom_status {\n    left: 160px;\n    font: 1em/28px Sans;\n    color: #000;\n    background-color: #fff;\n    text-align: center;\n    width: 60px;\n}\n\n.iviewer_rotate_left {\n    left: 227px;\n    background: #fff url(../images/iviewer/iviewer.rotate_left.png) center center no-repeat;\n}\n\n.iviewer_rotate_right {\n    left: 262px;\n    background: #fff url(../images/iviewer/iviewer.rotate_right.png) center center no-repeat;\n}\n"
  },
  {
    "path": "docs/api/css/phpdocumentor-clean-icons/Read Me.txt",
    "content": "To modify your generated font, use the *dev.svg* file, located in the *fonts* folder in this package. You can import this dev.svg file to the IcoMoon app. All the tags (class names) and the Unicode points of your glyphs are saved in this file.\n\nSee the documentation for more info on how to use this package: http://icomoon.io/#docs/font-face"
  },
  {
    "path": "docs/api/css/phpdocumentor-clean-icons/lte-ie7.js",
    "content": "/* Load this script using conditional IE comments if you need to support IE 7 and IE 6. */\n\nwindow.onload = function() {\n\tfunction addIcon(el, entity) {\n\t\tvar html = el.innerHTML;\n\t\tel.innerHTML = '<span style=\"font-family: \\'phpdocumentor-clean-icons\\'\">' + entity + '</span>' + html;\n\t}\n\tvar icons = {\n\t\t\t'icon-trait' : '&#xe000;',\n\t\t\t'icon-interface' : '&#xe001;',\n\t\t\t'icon-class' : '&#xe002;'\n\t\t},\n\t\tels = document.getElementsByTagName('*'),\n\t\ti, attr, html, c, el;\n\tfor (i = 0; ; i += 1) {\n\t\tel = els[i];\n\t\tif(!el) {\n\t\t\tbreak;\n\t\t}\n\t\tattr = el.getAttribute('data-icon');\n\t\tif (attr) {\n\t\t\taddIcon(el, attr);\n\t\t}\n\t\tc = el.className;\n\t\tc = c.match(/icon-[^\\s'\"]+/);\n\t\tif (c && icons[c[0]]) {\n\t\t\taddIcon(el, icons[c[0]]);\n\t\t}\n\t}\n};"
  },
  {
    "path": "docs/api/css/phpdocumentor-clean-icons/style.css",
    "content": "@font-face {\n\tfont-family: 'phpdocumentor-clean-icons';\n\tsrc:url('fonts/phpdocumentor-clean-icons.eot');\n\tsrc:url('fonts/phpdocumentor-clean-icons.eot?#iefix') format('embedded-opentype'),\n\t\turl('fonts/phpdocumentor-clean-icons.woff') format('woff'),\n\t\turl('fonts/phpdocumentor-clean-icons.ttf') format('truetype'),\n\t\turl('fonts/phpdocumentor-clean-icons.svg#phpdocumentor-clean-icons') format('svg');\n\tfont-weight: normal;\n\tfont-style: normal;\n}\n\n/* Use the following CSS code if you want to use data attributes for inserting your icons */\n[data-icon]:before {\n\tfont-family: 'phpdocumentor-clean-icons';\n\tcontent: attr(data-icon);\n\tspeak: none;\n\tfont-weight: normal;\n\tfont-variant: normal;\n\ttext-transform: none;\n\tline-height: 1;\n\t-webkit-font-smoothing: antialiased;\n}\n\n/* Use the following CSS code if you want to have a class per icon */\n/*\nInstead of a list of all class selectors,\nyou can use the generic selector below, but it's slower:\n[class*=\"icon-\"] {\n*/\n.icon-trait, .icon-interface, .icon-class {\n\tfont-family: 'phpdocumentor-clean-icons';\n\tspeak: none;\n\tfont-style: normal;\n\tfont-weight: normal;\n\tfont-variant: normal;\n\ttext-transform: none;\n\tline-height: 1;\n\t-webkit-font-smoothing: antialiased;\n}\n.icon-trait:before {\n\tcontent: \"\\e000\";\n}\n.icon-interface:before {\n\tcontent: \"\\e001\";\n}\n.icon-class:before {\n\tcontent: \"\\e002\";\n}\n"
  },
  {
    "path": "docs/api/css/prism.css",
    "content": "/**\n * prism.js default theme for JavaScript, CSS and HTML\n * Based on dabblet (http://dabblet.com)\n * @author Lea Verou\n */\n\ncode[class*=\"language-\"],\npre[class*=\"language-\"] {\n\tcolor: black;\n\ttext-shadow: 0 1px white;\n\tfont-family: Consolas, Monaco, 'Andale Mono', monospace;\n\tdirection: ltr;\n\ttext-align: left;\n\twhite-space: pre;\n\tword-spacing: normal;\n\n\t-moz-tab-size: 4;\n\t-o-tab-size: 4;\n\ttab-size: 4;\n\n\t-webkit-hyphens: none;\n\t-moz-hyphens: none;\n\t-ms-hyphens: none;\n\thyphens: none;\n}\n\n::-moz-selection {\n\ttext-shadow: none;\n\tbackground: #b3d4fc;\n}\n\n::selection {\n\ttext-shadow: none;\n\tbackground: #b3d4fc;\n}\n\n@media print {\n\tcode[class*=\"language-\"],\n\tpre[class*=\"language-\"] {\n\t\ttext-shadow: none;\n\t}\n}\n\n/* Code blocks */\npre[class*=\"language-\"] {\n\tpadding: 1em;\n\tmargin: .5em 0;\n\toverflow: auto;\n}\n\n:not(pre) > code[class*=\"language-\"],\npre[class*=\"language-\"] {\n\tbackground: #f5f2f0;\n}\n\n/* Inline code */\n:not(pre) > code[class*=\"language-\"] {\n\tpadding: .1em;\n\tborder-radius: .3em;\n}\n\n.token.comment,\n.token.prolog,\n.token.doctype,\n.token.cdata {\n\tcolor: slategray;\n}\n\n.token.punctuation {\n\tcolor: #999;\n}\n\n.namespace {\n\topacity: .7;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number {\n\tcolor: #905;\n}\n\n.token.selector,\n.token.attr-name,\n.token.string {\n\tcolor: #690;\n}\n\n.token.operator,\n.token.entity,\n.token.url,\n.language-css .token.string,\n.style .token.string {\n\tcolor: #a67f59;\n\tbackground: hsla(0,0%,100%,.5);\n}\n\n.token.atrule,\n.token.attr-value,\n.token.keyword {\n\tcolor: #07a;\n}\n\n\n.token.regex,\n.token.important {\n\tcolor: #e90;\n}\n\n.token.important {\n\tfont-weight: bold;\n}\n\n.token.entity {\n\tcursor: help;\n}\npre[data-line] {\n\tposition: relative;\n\tpadding: 1em 0 1em 3em;\n}\n\n.line-highlight {\n\tposition: absolute;\n\tleft: 0;\n\tright: 0;\n\tpadding: inherit 0;\n\tmargin-top: 1em; /* Same as .prism’s padding-top */\n\n\tbackground: hsla(24, 20%, 50%,.08);\n\tbackground: -moz-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));\n\tbackground: -webkit-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));\n\tbackground: -o-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));\n\tbackground: linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));\n\t\n\tpointer-events: none;\n\t\n\tline-height: inherit;\n\twhite-space: pre;\n}\n\n\t.line-highlight:before,\n\t.line-highlight[data-end]:after {\n\t\tcontent: attr(data-start);\n\t\tposition: absolute;\n\t\ttop: .4em;\n\t\tleft: .6em;\n\t\tmin-width: 1em;\n\t\tpadding: 0 .5em;\n\t\tbackground-color: hsla(24, 20%, 50%,.4);\n\t\tcolor: hsl(24, 20%, 95%);\n\t\tfont: bold 65%/1.5 sans-serif;\n\t\ttext-align: center;\n\t\tvertical-align: .3em;\n\t\tborder-radius: 999px;\n\t\ttext-shadow: none;\n\t\tbox-shadow: 0 1px white;\n\t}\n\t\n\t.line-highlight[data-end]:after {\n\t\tcontent: attr(data-end);\n\t\ttop: auto;\n\t\tbottom: .4em;\n\t}\npre.line-numbers {\n\tposition: relative;\n\tpadding-left: 3.8em;\n\tcounter-reset: linenumber;\n}\n\npre.line-numbers > code {\n\tposition: relative;\n}\n\n.line-numbers .line-numbers-rows {\n\tposition: absolute;\n\tpointer-events: none;\n\ttop: 0;\n\tfont-size: 100%;\n\tleft: -3.8em;\n\twidth: 3em; /* works for line-numbers below 1000 lines */\n\tletter-spacing: -1px;\n\tborder-right: 1px solid #999;\n\n\t-webkit-user-select: none;\n\t-moz-user-select: none;\n\t-ms-user-select: none;\n\tuser-select: none;\n\n}\n\n\t.line-numbers-rows > span {\n\t\tpointer-events: none;\n\t\tdisplay: block;\n\t\tcounter-increment: linenumber;\n\t}\n\n\t\t.line-numbers-rows > span:before {\n\t\t\tcontent: counter(linenumber);\n\t\t\tcolor: #999;\n\t\t\tdisplay: block;\n\t\t\tpadding-right: 0.8em;\n\t\t\ttext-align: right;\n\t\t}\n"
  },
  {
    "path": "docs/api/css/template.css",
    "content": "@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro);\n@import url('phpdocumentor-clean-icons/style.css');\n\nbody {\n    padding-top:      40px;\n    background-color: #333333;\n}\n\na {\n    color: #6495ed;\n}\na.anchor {\n    height: 40px;\n    margin-top: -40px;\n    display: block;\n}\n\nh1, h2, h3, h4, h5, h6, .brand {\n    font-family:    'Source Sans Pro', sans-serif;\n    font-weight:    normal;\n    letter-spacing: 0.05em;\n}\n\nh2, h3, .detailsbar h1 {\n    overflow:    hidden;\n    white-space: nowrap;\n    margin:      30px 0 20px 0;\n}\n\nh2:after, h3:after, .detailsbar h1:after {\n    content:        '';\n    display:        inline-block;\n    vertical-align: middle;\n    width:          100%;\n    height:         2px;\n    margin-left:    1em;\n    background:     silver;\n}\n\nh3 {\n    margin: 10px 0 20px 0;\n}\n\nh4 {\n    margin:    20px 0 10px 0;\n    color:     gray;\n    font-size: 18.5px;\n}\n\nh3.public, h3.protected, h3.private {\n    padding-left: 10px;\n    text-overflow: ellipsis;\n}\n\n.table tr:first-of-type th, .table tr:first-of-type td {\n    border-top: none;\n}\n.detailsbar {\n    color:            #eeeeee;\n    background-color: #333333;\n    font-size:        0.9em;\n    overflow:         hidden;\n    border-left:      2px solid gray;\n}\n\n.detailsbar h1 {\n    font-size:     1.5em;\n    margin-bottom: 20px;\n    margin-top:    0;\n}\n\n.detailsbar h2 {\n    font-size: 1.2em;\n    margin:    0;\n    padding:   0;\n}\n\n.detailsbar h1:after {\n    background: gray;\n}\n.detailsbar h2:after, .detailsbar h3:after {\n    background: transparent;\n}\n\n.detailsbar dt {\n    font-variant:   small-caps;\n    text-transform: lowercase;\n    font-size:      1.1em;\n    letter-spacing: 0.1em;\n    color:          silver;\n}\n\n.hierarchy div:nth-of-type(2) { margin-left: 11px; }\n.hierarchy div:nth-of-type(3) { margin-left: 22px; }\n.hierarchy div:nth-of-type(4) { margin-left: 33px; }\n.hierarchy div:nth-of-type(5) { margin-left: 44px; }\n.hierarchy div:nth-of-type(6) { margin-left: 55px; }\n.hierarchy div:nth-of-type(7) { margin-left: 66px; }\n.hierarchy div:nth-of-type(8) { margin-left: 77px; }\n.hierarchy div:nth-of-type(9) { margin-left: 88px; }\n.hierarchy div:before {\n    content: \"\\f0da\";\n    font-family: FontAwesome;\n    margin-right: 5px;\n}\n\n.row-fluid {\n    background-color: white;\n    overflow:         hidden;\n}\n\nfooter.row-fluid, footer.row-fluid * {\n    background-color: #333333;\n    color:            white;\n}\n\nfooter.row-fluid {\n    border-top: 2px dashed #555;\n    margin-top: 2px;\n}\n\n.footer-sections .span4 {\n    border:        2px solid #555;\n    text-align:    center;\n    border-radius: 10px;\n    margin-top:    70px;\n    margin-bottom: 20px;\n    background:    #373737;\n}\n\n.footer-sections .span4 h1 {\n    background: transparent;\n    margin-top: -30px;\n    margin-bottom: 20px;\n    font-size:  5em;\n}\n\n.footer-sections .span4 h1 * {\n    background: transparent;\n}\n\n.footer-sections .span4 div {\n    border-bottom-right-radius: 6px;\n    border-bottom-left-radius: 6px;\n    padding: 10px;\n    min-height: 40px;\n}\n.footer-sections .span4 div, .footer-sections .span4 div * {\n    background-color: #555;\n}\n.footer-sections .span4 ul {\n    text-align: left;\n    list-style: none;\n    margin: 0;\n    padding: 0;\n}\n\n.content {\n    background-color: white;\n    padding-right:    20px;\n}\n\n.content nav {\n    text-align:     center;\n    border-bottom:  1px solid silver;\n    margin:         5px 0 20px 0;\n    padding-bottom: 5px;\n}\n\n.content > h1 {\n    padding-bottom: 15px;\n}\n\n.content > h1 small {\n    display:        block;\n    padding-bottom: 8px;\n    font-size:      0.6em;\n}\n\n.deprecated {\n    text-decoration: line-through;\n}\n\n.method {\n    margin-bottom: 20px;\n}\n\n.method .signature .argument {\n    color:       maroon;\n    font-weight: bold;\n}\n\n.class #summary section.row-fluid {\n    overflow: hidden\n}\n\n.class #summary .heading {\n    font-weight: bold;\n    text-align:  center;\n}\n\n.class #summary section .span4 {\n    padding:        3px;\n    overflow:       hidden;\n    margin-bottom:  -9999px;\n    padding-bottom: 9999px;\n    white-space:    nowrap;\n    text-overflow:  ellipsis;\n    border-left:    5px solid transparent;\n}\n\n.class #summary section.public .span4:first-of-type:before,\n.class #summary section.public .span6:first-of-type:before,\nh3.public:before {\n    font-family: FontAwesome;\n    content:     \"\\f046\";\n    color:       green;\n    display:     inline-block;\n    width:       1.2em;\n}\n\n.class #summary section .span4:first-of-type,\n.class #summary section .span6:first-of-type {\n    padding-left: 21px;\n}\n.class #summary section .span4:first-of-type:before,\n.class #summary section .span6:first-of-type:before {\n    margin-left: -21px;\n}\n.class #summary section.protected .span4:first-of-type:before,\n.class #summary section.protected .span6:first-of-type:before,\nh3.protected:before {\n    font-family: FontAwesome;\n    content:     \"\\f132\";\n    color:       orange;\n    display:     inline-block;\n    width:       1.2em;\n}\n\n.class #summary section.private .span4:first-of-type:before,\n.class #summary section.private .span6:first-of-type:before,\nh3.private:before {\n    font-family: FontAwesome;\n    content:     \"\\f023\";\n    color:       red;\n    display:     inline-block;\n    width:       1.2em;\n}\n\n.class #summary section em {\n    font-size: 0.9em;\n    color: silver;\n}\n.class #summary .inherited {\n    color:      gray;\n    font-style: italic;\n}\n\n.accordion-group {\n    border: none;\n}\n\n.accordion {\n    margin-bottom: 0;\n}\n\n.accordion a:hover {\n    text-decoration: none;\n    background:      #333333;\n    color:           #eeeeee;\n}\n\n.accordion-heading .accordion-toggle:before {\n    content:      \"\\f078\";\n    font-family:  FontAwesome;\n    margin-right: 5px;\n}\n\n.accordion-heading .accordion-toggle.collapsed:before {\n    content: \"\\f054\";\n}\n.accordion-heading .accordion-toggle {\n    float: left;\n    width: 16px;\n    height: 16px;\n    padding: 4px 2px 4px 12px;\n}\n.accordion-heading a {\n    display: block;\n    padding: 4px 12px;\n}\n\n.accordion-inner a {\n    display: block;\n    padding: 4px 12px;\n}\n\n.accordion-inner > ul a:before {\n    font-family: 'phpdocumentor-clean-icons';\n    content:      \"\\e001\";\n    margin-right: 5px;\n}\n\n.accordion-inner li.class a:before {\n    content:      \"\\e002\";\n}\n\n.accordion-inner li.interface a:before {\n    content:      \"\\e001\";\n}\n\n.accordion-inner li.trait a:before {\n    content:      \"\\e000\";\n}\n\n.accordion-inner {\n    padding: 4px 0 4px 12px;\n}\n.accordion-inner ul {\n    list-style: none;\n    padding:    0;\n    margin:     0;\n}\n\n.row-fluid .span2 {\n    width: 16.5%;\n}\n\nbody .modal {\n    width: 90%; /* desired relative width */\n    left: 5%; /* (100%-width)/2 */\n    /* place center */\n    margin-left:auto;\n    margin-right:auto;\n}\n\n.side-nav.nav-list li a {\n    overflow: hidden;\n    white-space: nowrap;\n    text-overflow: ellipsis;\n}\n\n@media (min-width: 767px) {\n    .sidebar {\n        position:         fixed;\n        top:              40px;\n        bottom:           0;\n        background-color: #f3f3f3;\n        left:             0;\n        border-right:     1px solid #e9e9e9;\n        overflow-y:       scroll;\n        overflow-x:       hidden;\n        padding-top:      10px;\n    }\n\n    .sidebar::-webkit-scrollbar {\n        width: 10px;\n    }\n\n    .sidebar::-webkit-scrollbar-thumb {\n        background:      #cccccc;\n        background-clip: padding-box;\n        border:          3px solid #f3f3f3;\n        border-radius:   5px;\n    }\n\n    .sidebar::-webkit-scrollbar-button {\n        display: none;\n    }\n\n    .sidebar::-webkit-scrollbar-track {\n        background: #f3f3f3;\n    }\n}\n\n@media (max-width: 979px) {\n    body {\n        padding-top: 0;\n    }\n}\n\n@media (max-width: 767px) {\n    .class #summary .heading {\n        display: none;\n    }\n\n    .detailsbar h1 {\n        display: none;\n    }\n\n    body {\n        background-color: white;\n    }\n\n    footer.row-fluid, footer.row-fluid * {\n        background-color: white;\n    }\n\n    .footer-sections .span4 h1 {\n        color: #ccccd9;\n        margin-top: 0;\n    }\n\n    .detailsbar {\n        background-color: white;\n        color: #333;\n        border: none;\n    }\n\n    .row-fluid .span2 {\n        width: 100%;\n    }\n}\n\n@media (min-width: 767px) {\n    .detailsbar {\n        min-height:     100%;\n        margin-bottom:  -99999px;\n        padding-bottom: 99999px;\n        padding-left:   20px;\n        padding-top:    10px;\n    }\n}\n\n@media (min-width: 1200px) {\n    .row-fluid .span2 {\n        width: 16.5%;\n    }\n}\n"
  },
  {
    "path": "docs/api/files/CAsciiArt.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-306826089\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-306826089\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small></small>CAsciiArt.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></td>\n                            <td><em>Create an ASCII version of an image.</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CAsciiArt.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/CAsciiArt.php.txt",
    "content": "<?php\n/**\n * Create an ASCII version of an image.\n *\n */\nclass CAsciiArt\n{\n    /**\n     * Character set to use.\n     */\n    private $characterSet = array(\n        'one' => \"#0XT|:,.' \",\n        'two' => \"@%#*+=-:. \",\n        'three' => \"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\\\"^`'. \"\n    );\n\n\n\n    /**\n     * Current character set.\n     */\n    private $characters = null;\n\n\n\n    /**\n     * Length of current character set.\n     */\n    private $charCount = null;\n\n\n\n    /**\n     * Scale of the area to swap to a character.\n     */\n    private $scale = null;\n\n\n\n    /**\n     * Strategy to calculate luminance.\n     */\n    private $luminanceStrategy = null;\n\n\n\n    /**\n     * Constructor which sets default options.\n     */\n    public function __construct()\n    {\n        $this->setOptions();\n    }\n\n\n\n    /**\n     * Add a custom character set.\n     *\n     * @param string $key   for the character set.\n     * @param string $value for the character set.\n     *\n     * @return $this\n     */\n    public function addCharacterSet($key, $value)\n    {\n        $this->characterSet[$key] = $value;\n        return $this;\n    }\n\n\n\n    /**\n     * Set options for processing, defaults are available.\n     *\n     * @param array $options to use as default settings.\n     *\n     * @return $this\n     */\n    public function setOptions($options = array())\n    {\n        $default = array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        );\n        $default = array_merge($default, $options);\n        \n        if (!is_null($default['customCharacterSet'])) {\n            $this->addCharacterSet('custom', $default['customCharacterSet']);\n            $default['characterSet'] = 'custom';\n        }\n        \n        $this->scale = $default['scale'];\n        $this->characters = $this->characterSet[$default['characterSet']];\n        $this->charCount = strlen($this->characters);\n        $this->luminanceStrategy = $default['luminanceStrategy'];\n        \n        return $this;\n    }\n\n\n\n    /**\n     * Create an Ascii image from an image file.\n     *\n     * @param string $filename of the image to use.\n     *\n     * @return string $ascii with the ASCII image.\n     */\n    public function createFromFile($filename)\n    {\n        $img = imagecreatefromstring(file_get_contents($filename));\n        list($width, $height) = getimagesize($filename);\n\n        $ascii = null;\n        $incY = $this->scale;\n        $incX = $this->scale / 2;\n        \n        for ($y = 0; $y < $height - 1; $y += $incY) {\n            for ($x = 0; $x < $width - 1; $x += $incX) {\n                $toX = min($x + $this->scale / 2, $width - 1);\n                $toY = min($y + $this->scale, $height - 1);\n                $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);\n                $ascii .= $this->luminance2character($luminance);\n            }\n            $ascii .= PHP_EOL;\n        }\n\n        return $ascii;\n    }\n\n\n\n    /**\n     * Get the luminance from a region of an image using average color value.\n     *\n     * @param string  $img the image.\n     * @param integer $x1  the area to get pixels from.\n     * @param integer $y1  the area to get pixels from.\n     * @param integer $x2  the area to get pixels from.\n     * @param integer $y2  the area to get pixels from.\n     *\n     * @return integer $luminance with a value between 0 and 100.\n     */\n    public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2)\n    {\n        $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1);\n        $luminance = 0;\n        \n        for ($x = $x1; $x <= $x2; $x++) {\n            for ($y = $y1; $y <= $y2; $y++) {\n                $rgb   = imagecolorat($img, $x, $y);\n                $red   = (($rgb >> 16) & 0xFF);\n                $green = (($rgb >> 8) & 0xFF);\n                $blue  = ($rgb & 0xFF);\n                $luminance += $this->getLuminance($red, $green, $blue);\n            }\n        }\n        \n        return $luminance / $numPixels;\n    }\n\n\n\n    /**\n     * Calculate luminance value with different strategies.\n     *\n     * @param integer $red   The color red.\n     * @param integer $green The color green.\n     * @param integer $blue  The color blue.\n     *\n     * @return float $luminance with a value between 0 and 1.\n     */\n    public function getLuminance($red, $green, $blue)\n    {\n        switch($this->luminanceStrategy) {\n            case 1:\n                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;\n                break;\n            case 2:\n                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;\n                break;\n            case 3:\n                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;\n                break;\n            case 0:\n            default:\n                $luminance = ($red + $green + $blue) / (255 * 3);\n        }\n\n        return $luminance;\n    }\n\n\n\n    /**\n     * Translate the luminance value to a character.\n     *\n     * @param string $position a value between 0-100 representing the\n     *                         luminance.\n     *\n     * @return string with the ascii character.\n     */\n    public function luminance2character($luminance)\n    {\n        $position = (int) round($luminance * ($this->charCount - 1));\n        $char = $this->characters[$position];\n        return $char;\n    }\n}\n\n"
  },
  {
    "path": "docs/api/files/CHttpGet.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1589006485\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1589006485\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small></small>CHttpGet.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CHttpGet.html\">CHttpGet</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CHttpGet.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/CHttpGet.php.txt",
    "content": "<?php\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CHttpGet\n{\n    private $request  = array();\n    private $response = array();\n\n\n\n    /**\n    * Constructor\n    *\n    */\n    public function __construct()\n    {\n        $this->request['header'] = array();\n    }\n\n\n\n    /**\n     * Build an encoded url.\n     *\n     * @param string $baseUrl This is the original url which will be merged.\n     * @param string $merge   Thse parts should be merged into the baseUrl,\n     *                        the format is as parse_url.\n     *\n     * @return string $url as the modified url.\n     */\n    public function buildUrl($baseUrl, $merge)\n    {\n        $parts = parse_url($baseUrl);\n        $parts = array_merge($parts, $merge);\n\n        $url  = $parts['scheme'];\n        $url .= \"://\";\n        $url .= $parts['host'];\n        $url .= isset($parts['port'])\n            ? \":\" . $parts['port']\n            : \"\" ;\n        $url .= $parts['path'];\n\n        return $url;\n    }\n\n\n\n    /**\n     * Set the url for the request.\n     *\n     * @param string $url\n     *\n     * @return $this\n     */\n    public function setUrl($url)\n    {\n        $parts = parse_url($url);\n        \n        $path = \"\";\n        if (isset($parts['path'])) {\n            $pathParts = explode('/', $parts['path']);\n            unset($pathParts[0]);\n            foreach ($pathParts as $value) {\n                $path .= \"/\" . rawurlencode($value);\n            }\n        }\n        $url = $this->buildUrl($url, array(\"path\" => $path));\n\n        $this->request['url'] = $url;\n        return $this;\n    }\n\n\n\n    /**\n     * Set custom header field for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function setHeader($field, $value)\n    {\n        $this->request['header'][] = \"$field: $value\";\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function parseHeader()\n    {\n        //$header = explode(\"\\r\\n\", rtrim($this->response['headerRaw'], \"\\r\\n\"));\n        \n        $rawHeaders = rtrim($this->response['headerRaw'], \"\\r\\n\");\n        # Handle multiple responses e.g. with redirections (proxies too)\n        $headerGroups = explode(\"\\r\\n\\r\\n\", $rawHeaders);\n        # We're only interested in the last one\n        $header = explode(\"\\r\\n\", end($headerGroups));\n\n        $output = array();\n\n        if ('HTTP' === substr($header[0], 0, 4)) {\n            list($output['version'], $output['status']) = explode(' ', $header[0]);\n            unset($header[0]);\n        }\n\n        foreach ($header as $entry) {\n            $pos = strpos($entry, ':');\n            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));\n        }\n\n        $this->response['header'] = $output;\n        return $this;\n    }\n\n\n\n    /**\n     * Perform the request.\n     *\n     * @param boolean $debug set to true to dump headers.\n     *\n     * @throws Exception when curl fails to retrieve url.\n     *\n     * @return boolean\n     */\n    public function doGet($debug = false)\n    {\n        $options = array(\n            CURLOPT_URL             => $this->request['url'],\n            CURLOPT_HEADER          => 1,\n            CURLOPT_HTTPHEADER      => $this->request['header'],\n            CURLOPT_AUTOREFERER     => true,\n            CURLOPT_RETURNTRANSFER  => true,\n            CURLINFO_HEADER_OUT     => $debug,\n            CURLOPT_CONNECTTIMEOUT  => 5,\n            CURLOPT_TIMEOUT         => 5,\n            CURLOPT_FOLLOWLOCATION  => true,\n            CURLOPT_MAXREDIRS       => 2,\n        );\n\n        $ch = curl_init();\n        curl_setopt_array($ch, $options);\n        $response = curl_exec($ch);\n\n        if (!$response) {\n            throw new Exception(\"Failed retrieving url, details follows: \" . curl_error($ch));\n        }\n\n        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n        $this->response['headerRaw'] = substr($response, 0, $headerSize);\n        $this->response['body']      = substr($response, $headerSize);\n\n        $this->parseHeader();\n\n        if ($debug) {\n            $info = curl_getinfo($ch);\n            echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\";\n            echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\";\n            echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\";\n        }\n\n        curl_close($ch);\n        return true;\n    }\n\n\n\n    /**\n     * Get HTTP code of response.\n     *\n     * @return integer as HTTP status code or null if not available.\n     */\n    public function getStatus()\n    {\n        return isset($this->response['header']['status'])\n            ? (int) $this->response['header']['status']\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @return int as timestamp.\n     */\n    public function getLastModified()\n    {\n        return isset($this->response['header']['Last-Modified'])\n            ? strtotime($this->response['header']['Last-Modified'])\n            : null;\n    }\n\n\n\n    /**\n     * Get content type.\n     *\n     * @return string as the content type or null if not existing or invalid.\n     */\n    public function getContentType()\n    {\n        $type = isset($this->response['header']['Content-Type'])\n            ? $this->response['header']['Content-Type']\n            : null;\n\n        return preg_match('#[a-z]+/[a-z]+#', $type)\n            ? $type\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @param mixed $default as default value (int seconds) if date is\n     *                       missing in response header.\n     *\n     * @return int as timestamp or $default if Date is missing in\n     *             response header.\n     */\n    public function getDate($default = false)\n    {\n        return isset($this->response['header']['Date'])\n            ? strtotime($this->response['header']['Date'])\n            : $default;\n    }\n\n\n\n    /**\n     * Get max age of cachable item.\n     *\n     * @param mixed $default as default value if date is missing in response\n     *                       header.\n     *\n     * @return int as timestamp or false if not available.\n     */\n    public function getMaxAge($default = false)\n    {\n        $cacheControl = isset($this->response['header']['Cache-Control'])\n            ? $this->response['header']['Cache-Control']\n            : null;\n\n        $maxAge = null;\n        if ($cacheControl) {\n            // max-age=2592000\n            $part = explode('=', $cacheControl);\n            $maxAge = ($part[0] == \"max-age\")\n                ? (int) $part[1]\n                : null;\n        }\n\n        if ($maxAge) {\n            return $maxAge;\n        }\n\n        $expire = isset($this->response['header']['Expires'])\n            ? strtotime($this->response['header']['Expires'])\n            : null;\n\n        return $expire ? $expire : $default;\n    }\n\n\n\n    /**\n     * Get body of response.\n     *\n     * @return string as body.\n     */\n    public function getBody()\n    {\n        return $this->response['body'];\n    }\n}\n\n"
  },
  {
    "path": "docs/api/files/CImage.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1494355388\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1494355388\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small></small>CImage.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CImage.html\">CImage</a></td>\n                            <td><em>Resize and crop images on the fly, store generated images in a cache.</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CImage.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/CImage.php.txt",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n */\nclass CImage\n{\n\n    /**\n     * Constants type of PNG image\n     */\n    const PNG_GREYSCALE         = 0;\n    const PNG_RGB               = 2;\n    const PNG_RGB_PALETTE       = 3;\n    const PNG_GREYSCALE_ALPHA   = 4;\n    const PNG_RGB_ALPHA         = 6;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const JPEG_QUALITY_DEFAULT = 60;\n\n\n\n    /**\n     * Quality level for JPEG images.\n     */\n    private $quality;\n\n\n\n    /**\n     * Is the quality level set from external use (true) or is it default (false)?\n     */\n    private $useQuality = false;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const PNG_COMPRESSION_DEFAULT = -1;\n\n\n\n    /**\n     * Compression level for PNG images.\n     */\n    private $compress;\n\n\n\n    /**\n     * Is the compress level set from external use (true) or is it default (false)?\n     */\n    private $useCompress = false;\n\n\n\n\n    /**\n     * Add HTTP headers for outputing image.\n     */\n    private $HTTPHeader = array();\n\n\n\n    /**\n     * Default background color, red, green, blue, alpha.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    /*\n    const BACKGROUND_COLOR = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );*/\n\n\n\n    /**\n     * Default background color to use.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    //private $bgColorDefault = self::BACKGROUND_COLOR;\n    private $bgColorDefault = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );\n\n\n    /**\n     * Background color to use, specified as part of options.\n     */\n    private $bgColor;\n\n\n\n    /**\n     * Where to save the target file.\n     */\n    private $saveFolder;\n\n\n\n    /**\n     * The working image object.\n     */\n    private $image;\n\n\n\n    /**\n     * Image filename, may include subdirectory, relative from $imageFolder\n     */\n    private $imageSrc;\n\n\n\n    /**\n     * Actual path to the image, $imageFolder . '/' . $imageSrc\n     */\n    private $pathToImage;\n\n\n\n    /**\n     * File type for source image, as provided by getimagesize()\n     */\n    private $fileType;\n\n\n\n    /**\n     * File extension to use when saving image.\n     */\n    private $extension;\n\n\n\n    /**\n     * Output format, supports null (image) or json.\n     */\n    private $outputFormat = null;\n\n\n\n    /**\n     * Verbose mode to print out a trace and display the created image\n     */\n    private $verbose = false;\n\n\n\n    /**\n     * Keep a log/trace on what happens\n     */\n    private $log = array();\n\n\n\n    /**\n     * Handle image as palette image\n     */\n    private $palette;\n\n\n\n    /**\n     * Target filename, with path, to save resulting image in.\n     */\n    private $cacheFileName;\n\n\n\n    /**\n     * Set a format to save image as, or null to use original format.\n     */\n    private $saveAs;\n\n\n    /**\n     * Path to command for filter optimize, for example optipng or null.\n     */\n    private $pngFilter;\n    private $pngFilterCmd;\n\n\n\n    /**\n     * Path to command for deflate optimize, for example pngout or null.\n     */\n    private $pngDeflate;\n    private $pngDeflateCmd;\n\n\n\n    /**\n     * Path to command to optimize jpeg images, for example jpegtran or null.\n     */\n     private $jpegOptimize;\n     private $jpegOptimizeCmd;\n\n\n\n    /**\n     * Image dimensions, calculated from loaded image.\n     */\n    private $width;  // Calculated from source image\n    private $height; // Calculated from source image\n\n\n    /**\n     * New image dimensions, incoming as argument or calculated.\n     */\n    private $newWidth;\n    private $newWidthOrig;  // Save original value\n    private $newHeight;\n    private $newHeightOrig; // Save original value\n\n\n    /**\n     * Change target height & width when different dpr, dpr 2 means double image dimensions.\n     */\n    private $dpr = 1;\n\n\n    /**\n     * Always upscale images, even if they are smaller than target image.\n     */\n    const UPSCALE_DEFAULT = true;\n    private $upscale = self::UPSCALE_DEFAULT;\n\n\n\n    /**\n     * Array with details on how to crop, incoming as argument and calculated.\n     */\n    public $crop;\n    public $cropOrig; // Save original value\n\n\n    /**\n     * String with details on how to do image convolution. String\n     * should map a key in the $convolvs array or be a string of\n     * 11 float values separated by comma. The first nine builds\n     * up the matrix, then divisor and last offset.\n     */\n    private $convolve;\n\n\n    /**\n     * Custom convolution expressions, matrix 3x3, divisor and offset.\n     */\n    private $convolves = array(\n        'lighten'       => '0,0,0, 0,12,0, 0,0,0, 9, 0',\n        'darken'        => '0,0,0, 0,6,0, 0,0,0, 9, 0',\n        'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n        'emboss'        => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0',\n        'emboss-alt'    => '-2,-1,0, -1,1,1, 0,1,2, 1, 0',\n        'blur'          => '1,1,1, 1,15,1, 1,1,1, 23, 0',\n        'gblur'         => '1,2,1, 2,4,2, 1,2,1, 16, 0',\n        'edge'          => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0',\n        'edge-alt'      => '0,1,0, 1,-4,1, 0,1,0, 1, 0',\n        'draw'          => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0',\n        'mean'          => '1,1,1, 1,1,1, 1,1,1, 9, 0',\n        'motion'        => '1,0,0, 0,1,0, 0,0,1, 3, 0',\n    );\n\n\n    /**\n     * Resize strategy to fill extra area with background color.\n     * True or false.\n     */\n    private $fillToFit;\n\n\n\n    /**\n     * To store value for option scale.\n     */\n    private $scale;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateBefore;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateAfter;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $autoRotate;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $sharpen;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $emboss;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $blur;\n\n\n\n    /**\n     * Used with option area to set which parts of the image to use.\n     */\n    private $offset;\n\n\n\n    /**\n    * Calculate target dimension for image when using fill-to-fit resize strategy.\n    */\n    private $fillWidth;\n    private $fillHeight;\n\n\n\n    /**\n    * Allow remote file download, default is to disallow remote file download.\n    */\n    private $allowRemote = false;\n\n\n\n    /**\n     * Pattern to recognize a remote file.\n     */\n    //private $remotePattern = '#^[http|https]://#';\n    private $remotePattern = '#^https?://#';\n\n\n\n    /**\n     * Use the cache if true, set to false to ignore the cached file.\n     */\n    private $useCache = true;\n\n\n\n    /*\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     */\n    private $remoteHostWhitelist = null;\n\n\n\n    /*\n     * Do verbose logging to file by setting this to a filename.\n     */\n    private $verboseFileName = null;\n\n\n\n    /*\n     * Output to ascii can take som options as an array.\n     */\n    private $asciiOptions = array();\n\n\n\n    /*\n     * Image copy strategy, defaults to RESAMPLE.\n     */\n     const RESIZE = 1;\n     const RESAMPLE = 2;\n     private $copyStrategy = NULL;\n\n\n\n    /**\n     * Properties, the class is mutable and the method setOptions()\n     * decides (partly) what properties are created.\n     *\n     * @todo Clean up these and check if and how they are used\n     */\n\n    public $keepRatio;\n    public $cropToFit;\n    private $cropWidth;\n    private $cropHeight;\n    public $crop_x;\n    public $crop_y;\n    public $filters;\n    private $attr; // Calculated from source image\n\n\n\n\n    /**\n     * Constructor, can take arguments to init the object.\n     *\n     * @param string $imageSrc    filename which may contain subdirectory.\n     * @param string $imageFolder path to root folder for images.\n     * @param string $saveFolder  path to folder where to save the new file or null to skip saving.\n     * @param string $saveName    name of target file when saveing.\n     */\n    public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null)\n    {\n        $this->setSource($imageSrc, $imageFolder);\n        $this->setTarget($saveFolder, $saveName);\n    }\n\n\n\n    /**\n     * Set verbose mode.\n     *\n     * @param boolean $mode true or false to enable and disable verbose mode,\n     *                      default is true.\n     *\n     * @return $this\n     */\n    public function setVerbose($mode = true)\n    {\n        $this->verbose = $mode;\n        return $this;\n    }\n\n\n\n    /**\n     * Set save folder, base folder for saving cache files.\n     *\n     * @todo clean up how $this->saveFolder is used in other methods.\n     *\n     * @param string $path where to store cached files.\n     *\n     * @return $this\n     */\n    public function setSaveFolder($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Use cache or not.\n     *\n     * @param boolean $use true or false to use cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Create and save a dummy image. Use dimensions as stated in\n     * $this->newWidth, or $width or default to 100 (same for height.\n     *\n     * @param integer $width  use specified width for image dimension.\n     * @param integer $height use specified width for image dimension.\n     *\n     * @return $this\n     */\n    public function createDummyImage($width = null, $height = null)\n    {\n        $this->newWidth  = $this->newWidth  ?: $width  ?: 100;\n        $this->newHeight = $this->newHeight ?: $height ?: 100;\n\n        $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Allow or disallow remote image download.\n     *\n     * @param boolean $allow   true or false to enable and disable.\n     * @param string  $pattern to use to detect if its a remote file.\n     *\n     * @return $this\n     */\n    public function setRemoteDownload($allow, $pattern = null)\n    {\n        $this->allowRemote = $allow;\n        $this->remotePattern = is_null($pattern) ? $this->remotePattern : $pattern;\n\n        $this->log(\n            \"Set remote download to: \"\n            . ($this->allowRemote ? \"true\" : \"false\")\n            . \" using pattern \"\n            . $this->remotePattern\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the image resource is a remote file or not.\n     *\n     * @param string $src check if src is remote.\n     *\n     * @return boolean true if $src is a remote file, else false.\n     */\n    public function isRemoteSource($src)\n    {\n        $remote = preg_match($this->remotePattern, $src);\n        $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\"));\n        return !!$remote;\n    }\n\n\n\n    /**\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     *\n     * @param array $whitelist with regexp hostnames to allow download from.\n     *\n     * @return $this\n     */\n    public function setRemoteHostWhitelist($whitelist = null)\n    {\n        $this->remoteHostWhitelist = $whitelist;\n        $this->log(\n            \"Setting remote host whitelist to: \"\n            . (is_null($whitelist) ? \"null\" : print_r($whitelist, 1))\n        );\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the hostname for the remote image, is on a whitelist,\n     * if the whitelist is defined.\n     *\n     * @param string $src the remote source.\n     *\n     * @return boolean true if hostname on $src is in the whitelist, else false.\n     */\n    public function isRemoteSourceOnWhitelist($src)\n    {\n        if (is_null($this->remoteHostWhitelist)) {\n            $this->log(\"Remote host on whitelist not configured - allowing.\");\n            return true;\n        }\n\n        $whitelist = new CWhitelist();\n        $hostname = parse_url($src, PHP_URL_HOST);\n        $allow = $whitelist->check($hostname, $this->remoteHostWhitelist);\n\n        $this->log(\n            \"Remote host is on whitelist: \"\n            . ($allow ? \"true\" : \"false\")\n        );\n        return $allow;\n    }\n\n\n\n    /**\n     * Check if file extension is valid as a file extension.\n     *\n     * @param string $extension of image file.\n     *\n     * @return $this\n     */\n    private function checkFileExtension($extension)\n    {\n        $valid = array('jpg', 'jpeg', 'png', 'gif');\n\n        in_array(strtolower($extension), $valid)\n            or $this->raiseError('Not a valid file extension.');\n\n        return $this;\n    }\n\n\n\n    /**\n     * Normalize the file extension.\n     *\n     * @param string $extension of image file or skip to use internal.\n     *\n     * @return string $extension as a normalized file extension.\n     */\n    private function normalizeFileExtension($extension = null)\n    {\n        $extension = strtolower($extension ? $extension : $this->extension);\n        \n        if ($extension == 'jpeg') {\n                $extension = 'jpg';\n            }\n\n        return $extension;\n    }\n\n\n\n    /**\n     * Download a remote image and return path to its local copy.\n     *\n     * @param string $src remote path to image.\n     *\n     * @return string as path to downloaded remote source.\n     */\n    public function downloadRemoteSource($src)\n    {\n        if (!$this->isRemoteSourceOnWhitelist($src)) {\n            throw new Exception(\"Hostname is not on whitelist for remote sources.\");\n        }\n        \n        $remote = new CRemoteImage();\n        $cache  = $this->saveFolder . \"/remote/\";\n\n        if (!is_dir($cache)) {\n            if (!is_writable($this->saveFolder)) {\n                throw new Exception(\"Can not create remote cache, cachefolder not writable.\");\n            }\n            mkdir($cache);\n            $this->log(\"The remote cache does not exists, creating it.\");\n        }\n\n        if (!is_writable($cache)) {\n            $this->log(\"The remote cache is not writable.\");\n        }\n\n        $remote->setCache($cache);\n        $remote->useCache($this->useCache);\n        $src = $remote->download($src);\n\n        $this->log(\"Remote HTTP status: \" . $remote->getStatus());\n        $this->log(\"Remote item is in local cache: $src\");\n        $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true));\n\n        return $src;\n    }\n\n\n\n    /**\n     * Set source file to use as image source.\n     *\n     * @param string $src of image.\n     * @param string $dir as optional base directory where images are.\n     *\n     * @return $this\n     */\n    public function setSource($src, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->imageSrc = null;\n            $this->pathToImage = null;\n            return $this;\n        }\n\n        if ($this->allowRemote && $this->isRemoteSource($src)) {\n            $src = $this->downloadRemoteSource($src);\n            $dir = null;\n        }\n\n        if (!isset($dir)) {\n            $dir = dirname($src);\n            $src = basename($src);\n        }\n\n        $this->imageSrc     = ltrim($src, '/');\n        $imageFolder        = rtrim($dir, '/');\n        $this->pathToImage  = $imageFolder . '/' . $this->imageSrc;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set target file.\n     *\n     * @param string $src of target image.\n     * @param string $dir as optional base directory where images are stored.\n     *                    Uses $this->saveFolder if null.\n     *\n     * @return $this\n     */\n    public function setTarget($src = null, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->cacheFileName = null;\n            return $this;\n        }\n\n        if (isset($dir)) {\n            $this->saveFolder = rtrim($dir, '/');\n        }\n\n        $this->cacheFileName  = $this->saveFolder . '/' . $src;\n\n        // Sanitize filename\n        $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName);\n        $this->log(\"The cache file name is: \" . $this->cacheFileName);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get filename of target file.\n     *\n     * @return Boolean|String as filename of target or false if not set.\n     */\n    public function getTarget()\n    {\n        return $this->cacheFileName;\n    }\n\n\n\n    /**\n     * Set options to use when processing image.\n     *\n     * @param array $args used when processing image.\n     *\n     * @return $this\n     */\n    public function setOptions($args)\n    {\n        $this->log(\"Set new options for processing image.\");\n\n        $defaults = array(\n            // Options for calculate dimensions\n            'newWidth'    => null,\n            'newHeight'   => null,\n            'aspectRatio' => null,\n            'keepRatio'   => true,\n            'cropToFit'   => false,\n            'fillToFit'   => null,\n            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),\n            'area'        => null, //'0,0,0,0',\n            'upscale'     => self::UPSCALE_DEFAULT,\n\n            // Options for caching or using original\n            'useCache'    => true,\n            'useOriginal' => true,\n\n            // Pre-processing, before resizing is done\n            'scale'        => null,\n            'rotateBefore' => null,\n            'autoRotate'  => false,\n\n            // General options\n            'bgColor'     => null,\n\n            // Post-processing, after resizing is done\n            'palette'     => null,\n            'filters'     => null,\n            'sharpen'     => null,\n            'emboss'      => null,\n            'blur'        => null,\n            'convolve'       => null,\n            'rotateAfter' => null,\n\n            // Output format\n            'outputFormat' => null,\n            'dpr'          => 1,\n        );\n\n        // Convert crop settings from string to array\n        if (isset($args['crop']) && !is_array($args['crop'])) {\n            $pices = explode(',', $args['crop']);\n            $args['crop'] = array(\n                'width'   => $pices[0],\n                'height'  => $pices[1],\n                'start_x' => $pices[2],\n                'start_y' => $pices[3],\n            );\n        }\n\n        // Convert area settings from string to array\n        if (isset($args['area']) && !is_array($args['area'])) {\n                $pices = explode(',', $args['area']);\n                $args['area'] = array(\n                    'top'    => $pices[0],\n                    'right'  => $pices[1],\n                    'bottom' => $pices[2],\n                    'left'   => $pices[3],\n                );\n        }\n\n        // Convert filter settings from array of string to array of array\n        if (isset($args['filters']) && is_array($args['filters'])) {\n            foreach ($args['filters'] as $key => $filterStr) {\n                $parts = explode(',', $filterStr);\n                $filter = $this->mapFilter($parts[0]);\n                $filter['str'] = $filterStr;\n                for ($i=1; $i<=$filter['argc']; $i++) {\n                    if (isset($parts[$i])) {\n                        $filter[\"arg{$i}\"] = $parts[$i];\n                    } else {\n                        throw new Exception(\n                            'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php'\n                        );\n                    }\n                }\n                $args['filters'][$key] = $filter;\n            }\n        }\n\n        // Merge default arguments with incoming and set properties.\n        //$args = array_merge_recursive($defaults, $args);\n        $args = array_merge($defaults, $args);\n        foreach ($defaults as $key => $val) {\n            $this->{$key} = $args[$key];\n        }\n\n        if ($this->bgColor) {\n            $this->setDefaultBackgroundColor($this->bgColor);\n        }\n\n        // Save original values to enable re-calculating\n        $this->newWidthOrig  = $this->newWidth;\n        $this->newHeightOrig = $this->newHeight;\n        $this->cropOrig      = $this->crop;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Map filter name to PHP filter and id.\n     *\n     * @param string $name the name of the filter.\n     *\n     * @return array with filter settings\n     * @throws Exception\n     */\n    private function mapFilter($name)\n    {\n        $map = array(\n            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),\n            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),\n            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),\n            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),\n            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),\n            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),\n            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),\n            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),\n            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),\n            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),\n            'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),\n            'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),\n        );\n\n        if (isset($map[$name])) {\n            return $map[$name];\n        } else {\n            throw new Exception('No such filter.');\n        }\n    }\n\n\n\n    /**\n     * Load image details from original image file.\n     *\n     * @param string $file the file to load or null to use $this->pathToImage.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function loadImageDetails($file = null)\n    {\n        $file = $file ? $file : $this->pathToImage;\n\n        is_readable($file)\n            or $this->raiseError('Image file does not exist.');\n\n        // Get details on image\n        $info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);\n        if (empty($info)) {\n            throw new Exception(\"The file doesn't seem to be a valid image.\");\n        }\n\n        if ($this->verbose) {\n            $this->log(\"Loading image details for: {$file}\");\n            $this->log(\" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType}).\");\n            $this->log(\" Image filesize: \" . filesize($file) . \" bytes.\");\n            $this->log(\" Image mimetype: \" . image_type_to_mime_type($this->fileType));\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Init new width and height and do some sanity checks on constraints, before any\n     * processing can be done.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function initDimensions()\n    {\n        $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // width as %\n        if ($this->newWidth[strlen($this->newWidth)-1] == '%') {\n            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;\n            $this->log(\"Setting new width based on % to {$this->newWidth}\");\n        }\n\n        // height as %\n        if ($this->newHeight[strlen($this->newHeight)-1] == '%') {\n            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;\n            $this->log(\"Setting new height based on % to {$this->newHeight}\");\n        }\n\n        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');\n\n        // width & height from aspect ratio\n        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {\n            if ($this->aspectRatio >= 1) {\n                $this->newWidth   = $this->width;\n                $this->newHeight  = $this->width / $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n\n            } else {\n                $this->newHeight  = $this->height;\n                $this->newWidth   = $this->height * $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n            }\n\n        } elseif ($this->aspectRatio && is_null($this->newWidth)) {\n            $this->newWidth   = $this->newHeight * $this->aspectRatio;\n            $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\");\n\n        } elseif ($this->aspectRatio && is_null($this->newHeight)) {\n            $this->newHeight  = $this->newWidth / $this->aspectRatio;\n            $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\");\n        }\n\n        // Change width & height based on dpr\n        if ($this->dpr != 1) {\n            if (!is_null($this->newWidth)) {\n                $this->newWidth  = round($this->newWidth * $this->dpr);\n                $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\");\n            }\n            if (!is_null($this->newHeight)) {\n                $this->newHeight = round($this->newHeight * $this->dpr);\n                $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\");\n            }\n        }\n\n        // Check values to be within domain\n        is_null($this->newWidth)\n            or is_numeric($this->newWidth)\n            or $this->raiseError('Width not numeric');\n\n        is_null($this->newHeight)\n            or is_numeric($this->newHeight)\n            or $this->raiseError('Height not numeric');\n\n        $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Calculate new width and height of image, based on settings.\n     *\n     * @return $this\n     */\n    public function calculateNewWidthAndHeight()\n    {\n        // Crop, use cropped width and height as base for calulations\n        $this->log(\"Calculate new width and height.\");\n        $this->log(\"Original width x height is {$this->width} x {$this->height}.\");\n        $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // Check if there is an area to crop off\n        if (isset($this->area)) {\n            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);\n            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);\n            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);\n            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);\n            $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];\n            $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];\n            $this->width  = $this->offset['width'];\n            $this->height = $this->offset['height'];\n            $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\");\n            $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\");\n        }\n\n        $width  = $this->width;\n        $height = $this->height;\n\n        // Check if crop is set\n        if ($this->crop) {\n            $width  = $this->crop['width']  = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];\n            $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];\n\n            if ($this->crop['start_x'] == 'left') {\n                $this->crop['start_x'] = 0;\n            } elseif ($this->crop['start_x'] == 'right') {\n                $this->crop['start_x'] = $this->width - $width;\n            } elseif ($this->crop['start_x'] == 'center') {\n                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);\n            }\n\n            if ($this->crop['start_y'] == 'top') {\n                $this->crop['start_y'] = 0;\n            } elseif ($this->crop['start_y'] == 'bottom') {\n                $this->crop['start_y'] = $this->height - $height;\n            } elseif ($this->crop['start_y'] == 'center') {\n                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);\n            }\n\n            $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\");\n        }\n\n        // Calculate new width and height if keeping aspect-ratio.\n        if ($this->keepRatio) {\n\n            $this->log(\"Keep aspect ratio.\");\n\n            // Crop-to-fit and both new width and height are set.\n            if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Use newWidth and newHeigh as width/height, image should fit in box.\n                $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\");\n\n            } elseif (isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Both new width and height are set.\n                // Use newWidth and newHeigh as max width/height, image should not be larger.\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n                $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;\n                $this->newWidth  = round($width  / $ratio);\n                $this->newHeight = round($height / $ratio);\n                $this->log(\"New width and height was set.\");\n\n            } elseif (isset($this->newWidth)) {\n\n                // Use new width as max-width\n                $factor = (float)$this->newWidth / (float)$width;\n                $this->newHeight = round($factor * $height);\n                $this->log(\"New width was set.\");\n\n            } elseif (isset($this->newHeight)) {\n\n                // Use new height as max-hight\n                $factor = (float)$this->newHeight / (float)$height;\n                $this->newWidth = round($factor * $width);\n                $this->log(\"New height was set.\");\n\n            }\n\n            // Get image dimensions for pre-resize image.\n            if ($this->cropToFit || $this->fillToFit) {\n\n                // Get relations of original & target image\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n\n                if ($this->cropToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Crop to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;\n                    $this->cropWidth  = round($width  / $ratio);\n                    $this->cropHeight = round($height / $ratio);\n                    $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\");\n\n                } elseif ($this->fillToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Fill to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;\n                    $this->fillWidth  = round($width  / $ratio);\n                    $this->fillHeight = round($height / $ratio);\n                    $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\");\n                }\n            }\n        }\n\n        // Crop, ensure to set new width and height\n        if ($this->crop) {\n            $this->log(\"Crop.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }\n\n        // Fill to fit, ensure to set new width and height\n        /*if ($this->fillToFit) {\n            $this->log(\"FillToFit.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }*/\n\n        // No new height or width is set, use existing measures.\n        $this->newWidth  = round(isset($this->newWidth) ? $this->newWidth : $this->width);\n        $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height);\n        $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Re-calculate image dimensions when original image dimension has changed.\n     *\n     * @return $this\n     */\n    public function reCalculateDimensions()\n    {\n        $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight);\n\n        $this->newWidth  = $this->newWidthOrig;\n        $this->newHeight = $this->newHeightOrig;\n        $this->crop      = $this->cropOrig;\n\n        $this->initDimensions()\n             ->calculateNewWidthAndHeight();\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set extension for filename to save as.\n     *\n     * @param string $saveas extension to save image as\n     *\n     * @return $this\n     */\n    public function setSaveAsExtension($saveAs = null)\n    {\n        if (isset($saveAs)) {\n            $saveAs = strtolower($saveAs);\n            $this->checkFileExtension($saveAs);\n            $this->saveAs = $saveAs;\n            $this->extension = $saveAs;\n        }\n\n        $this->log(\"Prepare to save image as: \" . $this->extension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set JPEG quality to use when saving image\n     *\n     * @param int $quality as the quality to set.\n     *\n     * @return $this\n     */\n    public function setJpegQuality($quality = null)\n    {\n        if ($quality) {\n            $this->useQuality = true;\n        }\n\n        $this->quality = isset($quality)\n            ? $quality\n            : self::JPEG_QUALITY_DEFAULT;\n\n        (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting JPEG quality to {$this->quality}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set PNG compressen algorithm to use when saving image\n     *\n     * @param int $compress as the algorithm to use.\n     *\n     * @return $this\n     */\n    public function setPngCompression($compress = null)\n    {\n        if ($compress) {\n            $this->useCompress = true;\n        }\n\n        $this->compress = isset($compress)\n            ? $compress\n            : self::PNG_COMPRESSION_DEFAULT;\n\n        (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting PNG compression level to {$this->compress}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Use original image if possible, check options which affects image processing.\n     *\n     * @param boolean $useOrig default is to use original if possible, else set to false.\n     *\n     * @return $this\n     */\n    public function useOriginalIfPossible($useOrig = true)\n    {\n        if ($useOrig\n            && ($this->newWidth == $this->width)\n            && ($this->newHeight == $this->height)\n            && !$this->area\n            && !$this->crop\n            && !$this->cropToFit\n            && !$this->fillToFit\n            && !$this->filters\n            && !$this->sharpen\n            && !$this->emboss\n            && !$this->blur\n            && !$this->convolve\n            && !$this->palette\n            && !$this->useQuality\n            && !$this->useCompress\n            && !$this->saveAs\n            && !$this->rotateBefore\n            && !$this->rotateAfter\n            && !$this->autoRotate\n            && !$this->bgColor\n            && ($this->upscale === self::UPSCALE_DEFAULT)\n        ) {\n            $this->log(\"Using original image.\");\n            $this->output($this->pathToImage);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Generate filename to save file in cache.\n     *\n     * @param string  $base      as optional basepath for storing file.\n     * @param boolean $useSubdir use or skip the subdir part when creating the\n     *                           filename.\n     *\n     * @return $this\n     */\n    public function generateFilename($base = null, $useSubdir = true)\n    {\n        $filename     = basename($this->pathToImage);\n        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;\n        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;\n        $crop_x       = $this->crop_x       ? \"_x{$this->crop_x}\"        : null;\n        $crop_y       = $this->crop_y       ? \"_y{$this->crop_y}\"        : null;\n        $scale        = $this->scale        ? \"_s{$this->scale}\"         : null;\n        $bgColor      = $this->bgColor      ? \"_bgc{$this->bgColor}\"     : null;\n        $quality      = $this->quality      ? \"_q{$this->quality}\"       : null;\n        $compress     = $this->compress     ? \"_co{$this->compress}\"     : null;\n        $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null;\n        $rotateAfter  = $this->rotateAfter  ? \"_ra{$this->rotateAfter}\"  : null;\n\n        $saveAs = $this->normalizeFileExtension();\n        $saveAs = $saveAs ? \"_$saveAs\" : null;\n\n        $copyStrat = null;\n        if ($this->copyStrategy === self::RESIZE) {\n            $copyStrat = \"_rs\";\n        }\n        \n        $width  = $this->newWidth;\n        $height = $this->newHeight;\n\n        $offset = isset($this->offset)\n            ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left']\n            : null;\n\n        $crop = $this->crop\n            ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y']\n            : null;\n\n        $filters = null;\n        if (isset($this->filters)) {\n            foreach ($this->filters as $filter) {\n                if (is_array($filter)) {\n                    $filters .= \"_f{$filter['id']}\";\n                    for ($i=1; $i<=$filter['argc']; $i++) {\n                        $filters .= \"-\".$filter[\"arg{$i}\"];\n                    }\n                }\n            }\n        }\n\n        $sharpen = $this->sharpen ? 's' : null;\n        $emboss  = $this->emboss  ? 'e' : null;\n        $blur    = $this->blur    ? 'b' : null;\n        $palette = $this->palette ? 'p' : null;\n\n        $autoRotate = $this->autoRotate ? 'ar' : null;\n\n        $optimize  = $this->jpegOptimize ? 'o' : null;\n        $optimize .= $this->pngFilter    ? 'f' : null;\n        $optimize .= $this->pngDeflate   ? 'd' : null;\n\n        $convolve = null;\n        if ($this->convolve) {\n            $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve);\n        }\n\n        $upscale = null;\n        if ($this->upscale !== self::UPSCALE_DEFAULT) {\n            $upscale = '_nu';\n        }\n\n        $subdir = null;\n        if ($useSubdir === true) {\n            $subdir = str_replace('/', '-', dirname($this->imageSrc));\n            $subdir = ($subdir == '.') ? '_.' : $subdir;\n            $subdir .= '_';\n        }\n        \n        $file = $subdir . $filename . '_' . $width . '_'\n            . $height . $offset . $crop . $cropToFit . $fillToFit\n            . $crop_x . $crop_y . $upscale\n            . $quality . $filters . $sharpen . $emboss . $blur . $palette\n            . $optimize . $compress\n            . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor\n            . $convolve . $copyStrat . $saveAs;\n\n        return $this->setTarget($file, $base);\n    }\n\n\n\n    /**\n     * Use cached version of image, if possible.\n     *\n     * @param boolean $useCache is default true, set to false to avoid using cached object.\n     *\n     * @return $this\n     */\n    public function useCacheIfPossible($useCache = true)\n    {\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime   = filemtime($this->pathToImage);\n            $cacheTime  = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                if ($this->useCache) {\n                    if ($this->verbose) {\n                        $this->log(\"Use cached file.\");\n                        $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $this->output($this->cacheFileName, $this->outputFormat);\n                } else {\n                    $this->log(\"Cache is valid but ignoring it by intention.\");\n                }\n            } else {\n                $this->log(\"Original file is modified, ignoring cache.\");\n            }\n        } else {\n            $this->log(\"Cachefile does not exists or ignoring it.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Load image from disk. Try to load image without verbose error message,\n     * if fail, load again and display error messages.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     *\n     */\n    public function load($src = null, $dir = null)\n    {\n        if (isset($src)) {\n            $this->setSource($src, $dir);\n        }\n\n        $this->loadImageDetails($this->pathToImage);\n\n        $this->image = imagecreatefromstring(file_get_contents($this->pathToImage));\n        if ($this->image === false) {\n            throw new Exception(\"Could not load image.\");\n        }\n        \n        /* Removed v0.7.7\n        if (image_type_to_mime_type($this->fileType) == 'image/png') {\n            $type = $this->getPngType();\n            $hasFewColors = imagecolorstotal($this->image);\n\n            if ($type == self::PNG_RGB_PALETTE || ($hasFewColors > 0 && $hasFewColors <= 256)) {\n                if ($this->verbose) {\n                    $this->log(\"Handle this image as a palette image.\");\n                }\n                $this->palette = true;\n            }\n        }\n        */\n\n        if ($this->verbose) {\n            $this->log(\"### Image successfully loaded from file.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->colorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index >= 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the type of PNG image.\n     *\n     * @param string $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    public function getPngType($filename = null)\n    {\n        $filename = $filename ? $filename : $this->pathToImage;\n        \n        $pngType = ord(file_get_contents($filename, false, null, 25, 1));\n\n        if ($this->verbose) {\n            $this->log(\"Checking png type of: \" . $filename);\n            $this->log($this->getPngTypeAsString($pngType));\n        }\n        \n        return $pngType;\n    }\n\n\n\n    /**\n     * Get the type of PNG image as a verbose string.\n     *\n     * @param integer $type     to use, default is to check the type.\n     * @param string  $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    private function getPngTypeAsString($pngType = null, $filename = null)\n    {\n        if ($filename || !$pngType) {\n            $pngType = $this->getPngType($filename);\n        }\n\n        $index = imagecolortransparent($this->image);\n        $transparent = null;\n        if ($index != -1) {\n            $transparent = \" (transparent)\";            \n        }\n\n        switch ($pngType) {\n\n            case self::PNG_GREYSCALE:\n                $text = \"PNG is type 0, Greyscale$transparent\";\n                break;\n\n            case self::PNG_RGB:\n                $text = \"PNG is type 2, RGB$transparent\";\n                break;\n\n            case self::PNG_RGB_PALETTE:\n                $text = \"PNG is type 3, RGB with palette$transparent\";\n                break;\n\n            case self::PNG_GREYSCALE_ALPHA:\n                $text = \"PNG is type 4, Greyscale with alpha channel\";\n                break;\n\n            case self::PNG_RGB_ALPHA:\n                $text = \"PNG is type 6, RGB with alpha channel (PNG 32-bit)\";\n                break;\n\n            default:\n                $text = \"PNG is UNKNOWN type, is it really a PNG image?\";\n        }\n\n        return $text;\n    }\n\n\n\n\n    /**\n     * Calculate number of colors in an image.\n     *\n     * @param resource $im the image.\n     *\n     * @return int\n     */\n    private function colorsTotal($im)\n    {\n        if (imageistruecolor($im)) {\n            $this->log(\"Colors as true color.\");\n            $h = imagesy($im);\n            $w = imagesx($im);\n            $c = array();\n            for ($x=0; $x < $w; $x++) {\n                for ($y=0; $y < $h; $y++) {\n                    @$c['c'.imagecolorat($im, $x, $y)]++;\n                }\n            }\n            return count($c);\n        } else {\n            $this->log(\"Colors as palette.\");\n            return imagecolorstotal($im);\n        }\n    }\n\n\n\n    /**\n     * Preprocess image before rezising it.\n     *\n     * @return $this\n     */\n    public function preResize()\n    {\n        $this->log(\"### Pre-process before resizing\");\n\n        // Rotate image\n        if ($this->rotateBefore) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateBefore, $this->bgColor)\n                 ->reCalculateDimensions();\n        }\n\n        // Auto-rotate image\n        if ($this->autoRotate) {\n            $this->log(\"Auto rotating image.\");\n            $this->rotateExif()\n                 ->reCalculateDimensions();\n        }\n\n        // Scale the original image before starting\n        if (isset($this->scale)) {\n            $this->log(\"Scale by {$this->scale}%\");\n            $newWidth  = $this->width * $this->scale / 100;\n            $newHeight = $this->height * $this->scale / 100;\n            $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);\n            imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);\n            $this->image = $img;\n            $this->width = $newWidth;\n            $this->height = $newHeight;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Resize or resample the image while resizing.\n     *\n     * @param int $strategy as CImage::RESIZE or CImage::RESAMPLE\n     *\n     * @return $this\n     */\n     public function setCopyResizeStrategy($strategy)\n     {\n         $this->copyStrategy = $strategy;\n         return $this;\n     }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return void\n     */\n    public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)\n    {\n        if($this->copyStrategy == self::RESIZE) {\n            $this->log(\"Copy by resize\");\n            imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        } else {\n            $this->log(\"Copy by resample\");\n            imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        }\n    }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return $this\n     */\n    public function resize()\n    {\n\n        $this->log(\"### Starting to Resize()\");\n        $this->log(\"Upscale = '$this->upscale'\");\n\n        // Only use a specified area of the image, $this->offset is defining the area to use\n        if (isset($this->offset)) {\n\n            $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\");\n            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);\n            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);\n            $this->image = $img;\n            $this->width = $this->offset['width'];\n            $this->height = $this->offset['height'];\n        }\n\n        if ($this->crop) {\n\n            // Do as crop, take only part of image\n            $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\");\n            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);\n            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);\n            $this->image = $img;\n            $this->width = $this->crop['width'];\n            $this->height = $this->crop['height'];\n        }\n\n        if (!$this->upscale) {\n            // Consider rewriting the no-upscale code to fit within this if-statement,\n            // likely to be more readable code.\n            // The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch\n        }\n\n        if ($this->cropToFit) {\n\n            // Resize by crop to fit\n            $this->log(\"Resizing using strategy - Crop to fit\");\n\n            if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight)) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n\n                $posX = 0;\n                $posY = 0;\n\n                if ($this->newWidth > $this->width) {\n                    $posX = round(($this->newWidth - $this->width) / 2);\n                }\n\n                if ($this->newHeight > $this->height) {\n                    $posY = round(($this->newHeight - $this->height) / 2);\n                }\n\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            } else {\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n                $imgPreCrop   = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif ($this->fillToFit) {\n\n            // Resize by fill to fit\n            $this->log(\"Resizing using strategy - Fill to fit\");\n\n            $posX = 0;\n            $posY = 0;\n\n            $ratioOrig = $this->width / $this->height;\n            $ratioNew  = $this->newWidth / $this->newHeight;\n\n            // Check ratio for landscape or portrait\n            if ($ratioOrig < $ratioNew) {\n                $posX = round(($this->newWidth - $this->fillWidth) / 2);\n            } else {\n                $posY = round(($this->newHeight - $this->fillHeight) / 2);\n            }\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n                $posX = round(($this->fillWidth - $this->width) / 2);\n                $posY = round(($this->fillHeight - $this->height) / 2);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n\n            } else {\n                $imgPreFill   = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {\n\n            // Resize it\n            $this->log(\"Resizing, new height and/or width\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                if (!$this->keepRatio) {\n                    $this->log(\"Resizing - stretch to fit selected.\");\n\n                    $posX = 0;\n                    $posY = 0;\n                    $cropX = 0;\n                    $cropY = 0;\n\n                    if ($this->newWidth > $this->width && $this->newHeight > $this->height) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                    } elseif ($this->newWidth > $this->width) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $cropY = round(($this->height - $this->newHeight) / 2);\n                    } elseif ($this->newHeight > $this->height) {\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                        $cropX = round(($this->width - $this->newWidth) / 2);\n                    }\n\n                    //$this->log(\"posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY.\");\n                    $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                    imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n                    $this->image = $imageResized;\n                    $this->width = $this->newWidth;\n                    $this->height = $this->newHeight;\n                }\n            } else {\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);\n                $this->image = $imageResized;\n                $this->width = $this->newWidth;\n                $this->height = $this->newHeight;\n            }\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Postprocess image after rezising image.\n     *\n     * @return $this\n     */\n    public function postResize()\n    {\n        $this->log(\"### Post-process after resizing\");\n\n        // Rotate image\n        if ($this->rotateAfter) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateAfter, $this->bgColor);\n        }\n\n        // Apply filters\n        if (isset($this->filters) && is_array($this->filters)) {\n\n            foreach ($this->filters as $filter) {\n                $this->log(\"Applying filter {$filter['type']}.\");\n\n                switch ($filter['argc']) {\n\n                    case 0:\n                        imagefilter($this->image, $filter['type']);\n                        break;\n\n                    case 1:\n                        imagefilter($this->image, $filter['type'], $filter['arg1']);\n                        break;\n\n                    case 2:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']);\n                        break;\n\n                    case 3:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']);\n                        break;\n\n                    case 4:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']);\n                        break;\n                }\n            }\n        }\n\n        // Convert to palette image\n        if ($this->palette) {\n            $this->log(\"Converting to palette image.\");\n            $this->trueColorToPalette();\n        }\n\n        // Blur the image\n        if ($this->blur) {\n            $this->log(\"Blur.\");\n            $this->blurImage();\n        }\n\n        // Emboss the image\n        if ($this->emboss) {\n            $this->log(\"Emboss.\");\n            $this->embossImage();\n        }\n\n        // Sharpen the image\n        if ($this->sharpen) {\n            $this->log(\"Sharpen.\");\n            $this->sharpenImage();\n        }\n\n        // Custom convolution\n        if ($this->convolve) {\n            //$this->log(\"Convolve: \" . $this->convolve);\n            $this->imageConvolution();\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using angle.\n     *\n     * @param float $angle        to rotate image.\n     * @param int   $anglebgColor to fill image with if needed.\n     *\n     * @return $this\n     */\n    public function rotate($angle, $bgColor)\n    {\n        $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\");\n\n        $color = $this->getBackgroundColor();\n        $this->image = imagerotate($this->image, $angle, $color);\n\n        $this->width  = imagesx($this->image);\n        $this->height = imagesy($this->image);\n\n        $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using information in EXIF.\n     *\n     * @return $this\n     */\n    public function rotateExif()\n    {\n        if (!in_array($this->fileType, array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) {\n            $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\");\n            return $this;\n        }\n\n        $exif = exif_read_data($this->pathToImage);\n\n        if (!empty($exif['Orientation'])) {\n            switch ($exif['Orientation']) {\n                case 3:\n                    $this->log(\"Autorotate 180.\");\n                    $this->rotate(180, $this->bgColor);\n                    break;\n\n                case 6:\n                    $this->log(\"Autorotate -90.\");\n                    $this->rotate(-90, $this->bgColor);\n                    break;\n\n                case 8:\n                    $this->log(\"Autorotate 90.\");\n                    $this->rotate(90, $this->bgColor);\n                    break;\n\n                default:\n                    $this->log(\"Autorotate ignored, unknown value as orientation.\");\n            }\n        } else {\n            $this->log(\"Autorotate ignored, no orientation in EXIF.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert true color image to palette image, keeping alpha.\n     * http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\n     *\n     * @return void\n     */\n    public function trueColorToPalette()\n    {\n        $img = imagecreatetruecolor($this->width, $this->height);\n        $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);\n        imagecolortransparent($img, $bga);\n        imagefill($img, 0, 0, $bga);\n        imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);\n        imagetruecolortopalette($img, false, 255);\n        imagesavealpha($img, true);\n\n        if (imageistruecolor($this->image)) {\n            $this->log(\"Matching colors with true color image.\");\n            imagecolormatch($this->image, $img);\n        }\n\n        $this->image = $img;\n    }\n\n\n\n    /**\n     * Sharpen image using image convolution.\n     *\n     * @return $this\n     */\n    public function sharpenImage()\n    {\n        $this->imageConvolution('sharpen');\n        return $this;\n    }\n\n\n\n    /**\n     * Emboss image using image convolution.\n     *\n     * @return $this\n     */\n    public function embossImage()\n    {\n        $this->imageConvolution('emboss');\n        return $this;\n    }\n\n\n\n    /**\n     * Blur image using image convolution.\n     *\n     * @return $this\n     */\n    public function blurImage()\n    {\n        $this->imageConvolution('blur');\n        return $this;\n    }\n\n\n\n    /**\n     * Create convolve expression and return arguments for image convolution.\n     *\n     * @param string $expression constant string which evaluates to a list of\n     *                           11 numbers separated by komma or such a list.\n     *\n     * @return array as $matrix (3x3), $divisor and $offset\n     */\n    public function createConvolveArguments($expression)\n    {\n        // Check of matching constant\n        if (isset($this->convolves[$expression])) {\n            $expression = $this->convolves[$expression];\n        }\n\n        $part = explode(',', $expression);\n        $this->log(\"Creating convolution expressen: $expression\");\n\n        // Expect list of 11 numbers, split by , and build up arguments\n        if (count($part) != 11) {\n            throw new Exception(\n                \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\"\n            );\n        }\n\n        array_walk($part, function ($item, $key) {\n            if (!is_numeric($item)) {\n                throw new Exception(\"Argument to convolve expression should be float but is not.\");\n            }\n        });\n\n        return array(\n            array(\n                array($part[0], $part[1], $part[2]),\n                array($part[3], $part[4], $part[5]),\n                array($part[6], $part[7], $part[8]),\n            ),\n            $part[9],\n            $part[10],\n        );\n    }\n\n\n\n    /**\n     * Add custom expressions (or overwrite existing) for image convolution.\n     *\n     * @param array $options Key value array with strings to be converted\n     *                       to convolution expressions.\n     *\n     * @return $this\n     */\n    public function addConvolveExpressions($options)\n    {\n        $this->convolves = array_merge($this->convolves, $options);\n        return $this;\n    }\n\n\n\n    /**\n     * Image convolution.\n     *\n     * @param string $options A string with 11 float separated by comma.\n     *\n     * @return $this\n     */\n    public function imageConvolution($options = null)\n    {\n        // Use incoming options or use $this.\n        $options = $options ? $options : $this->convolve;\n\n        // Treat incoming as string, split by +\n        $this->log(\"Convolution with '$options'\");\n        $options = explode(\":\", $options);\n\n        // Check each option if it matches constant value\n        foreach ($options as $option) {\n            list($matrix, $divisor, $offset) = $this->createConvolveArguments($option);\n            imageconvolution($this->image, $matrix, $divisor, $offset);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set default background color between 000000-FFFFFF or if using\n     * alpha 00000000-FFFFFF7F.\n     *\n     * @param string $color as hex value.\n     *\n     * @return $this\n    */\n    public function setDefaultBackgroundColor($color)\n    {\n        $this->log(\"Setting default background color to '$color'.\");\n\n        if (!(strlen($color) == 6 || strlen($color) == 8)) {\n            throw new Exception(\n                \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $red    = hexdec(substr($color, 0, 2));\n        $green  = hexdec(substr($color, 2, 2));\n        $blue   = hexdec(substr($color, 4, 2));\n\n        $alpha = (strlen($color) == 8)\n            ? hexdec(substr($color, 6, 2))\n            : null;\n\n        if (($red < 0 || $red > 255)\n            || ($green < 0 || $green > 255)\n            || ($blue < 0 || $blue > 255)\n            || ($alpha < 0 || $alpha > 127)\n        ) {\n            throw new Exception(\n                \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $this->bgColor = strtolower($color);\n        $this->bgColorDefault = array(\n            'red'   => $red,\n            'green' => $green,\n            'blue'  => $blue,\n            'alpha' => $alpha\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the background color.\n     *\n     * @param resource $img the image to work with or null if using $this->image.\n     *\n     * @return color value or null if no background color is set.\n    */\n    private function getBackgroundColor($img = null)\n    {\n        $img = isset($img) ? $img : $this->image;\n\n        if ($this->bgColorDefault) {\n\n            $red   = $this->bgColorDefault['red'];\n            $green = $this->bgColorDefault['green'];\n            $blue  = $this->bgColorDefault['blue'];\n            $alpha = $this->bgColorDefault['alpha'];\n\n            if ($alpha) {\n                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);\n            } else {\n                $color = imagecolorallocate($img, $red, $green, $blue);\n            }\n\n            return $color;\n\n        } else {\n            return 0;\n        }\n    }\n\n\n\n    /**\n     * Create a image and keep transparency for png and gifs.\n     *\n     * @param int $width of the new image.\n     * @param int $height of the new image.\n     *\n     * @return image resource.\n    */\n    private function createImageKeepTransparency($width, $height)\n    {\n        $this->log(\"Creating a new working image width={$width}px, height={$height}px.\");\n        $img = imagecreatetruecolor($width, $height);\n        imagealphablending($img, false);\n        imagesavealpha($img, true);\n\n        $index = $this->image\n            ? imagecolortransparent($this->image)\n            : -1;\n            \n        if ($index != -1) {\n\n            imagealphablending($img, true);\n            $transparent = imagecolorsforindex($this->image, $index);\n            $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']);\n            imagefill($img, 0, 0, $color);\n            $index = imagecolortransparent($img, $color);\n            $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\");\n\n        } elseif ($this->bgColorDefault) {\n\n            $color = $this->getBackgroundColor($img);\n            imagefill($img, 0, 0, $color);\n            $this->Log(\"Filling image with background color.\");\n        }\n\n        return $img;\n    }\n\n\n\n    /**\n     * Set optimizing  and post-processing options.\n     *\n     * @param array $options with config for postprocessing with external tools.\n     *\n     * @return $this\n     */\n    public function setPostProcessingOptions($options)\n    {\n        if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) {\n            $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd'];\n        } else {\n            $this->jpegOptimizeCmd = null;\n        }\n\n        if (isset($options['png_filter']) && $options['png_filter']) {\n            $this->pngFilterCmd = $options['png_filter_cmd'];\n        } else {\n            $this->pngFilterCmd = null;\n        }\n\n        if (isset($options['png_deflate']) && $options['png_deflate']) {\n            $this->pngDeflateCmd = $options['png_deflate_cmd'];\n        } else {\n            $this->pngDeflateCmd = null;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Find out the type (file extension) for the image to be saved.\n     *\n     * @return string as image extension.\n     */\n    protected function getTargetImageExtension()\n    {\n        // switch on mimetype\n        if (isset($this->extension)) {\n            return strtolower($this->extension);\n        } else {\n            return substr(image_type_to_extension($this->fileType), 1);\n        }\n    }\n    \n    \n\n    /**\n     * Save image.\n     *\n     * @param string  $src       as target filename.\n     * @param string  $base      as base directory where to store images.\n     * @param boolean $overwrite or not, default to always overwrite file.\n     *\n     * @return $this or false if no folder is set.\n     */\n    public function save($src = null, $base = null, $overwrite = true)\n    {\n        if (isset($src)) {\n            $this->setTarget($src, $base);\n        }\n\n        if ($overwrite === false && is_file($this->cacheFileName)) {\n            $this->Log(\"Not overwriting file since its already exists and \\$overwrite if false.\");\n            return;\n        }\n\n        is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n\n        $type = $this->getTargetImageExtension();\n        $this->Log(\"Saving image as \" . $type);\n        switch($type) {\n\n            case 'jpeg':\n            case 'jpg':\n                $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\");\n                imagejpeg($this->image, $this->cacheFileName, $this->quality);\n\n                // Use JPEG optimize if defined\n                if ($this->jpegOptimizeCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->log($cmd);\n                    $this->log($res);\n                }\n                break;\n\n            case 'gif':\n                $this->Log(\"Saving image as GIF to cache.\");\n                imagegif($this->image, $this->cacheFileName);\n                break;\n\n            case 'png':\n            default:\n                $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\");\n\n                // Turn off alpha blending and set alpha flag\n                imagealphablending($this->image, false);\n                imagesavealpha($this->image, true);\n                imagepng($this->image, $this->cacheFileName, $this->compress);\n\n                // Use external program to filter PNG, if defined\n                if ($this->pngFilterCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngFilterCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to deflate PNG, if defined\n                if ($this->pngDeflateCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n                break;\n        }\n\n        if ($this->verbose) {\n            clearstatcache();\n            $this->log(\"Saved image to cache.\");\n            $this->log(\" Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->ColorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Create a hard link, as an alias, to the cached file.\n     *\n     * @param string $alias where to store the link,\n     *                      filename without extension.\n     *\n     * @return $this\n     */\n    public function linkToCacheFile($alias)\n    {\n        if ($alias === null) {\n            $this->log(\"Ignore creating alias.\");\n            return $this;\n        }\n\n        if (is_readable($alias)) {\n            unlink($alias);\n        }\n\n        $res = link($this->cacheFileName, $alias);\n\n        if ($res) {\n            $this->log(\"Created an alias as: $alias\");\n        } else {\n            $this->log(\"Failed to create the alias: $alias\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Add HTTP header for putputting together with image.\n     *\n     * @param string $type  the header type such as \"Cache-Control\"\n     * @param string $value the value to use\n     *\n     * @return void\n     */\n    public function addHTTPHeader($type, $value)\n    {\n        $this->HTTPHeader[$type] = $value;\n    }\n\n\n\n    /**\n     * Output image to browser using caching.\n     *\n     * @param string $file   to read and output, default is to\n     *                       use $this->cacheFileName\n     * @param string $format set to json to output file as json\n     *                       object with details\n     *\n     * @return void\n     */\n    public function output($file = null, $format = null)\n    {\n        if (is_null($file)) {\n            $file = $this->cacheFileName;\n        }\n\n        if (is_null($format)) {\n            $format = $this->outputFormat;\n        }\n\n        $this->log(\"Output format is: $format\");\n\n        if (!$this->verbose && $format == 'json') {\n            header('Content-type: application/json');\n            echo $this->json($file);\n            exit;\n        } elseif ($format == 'ascii') {\n            header('Content-type: text/plain');\n            echo $this->ascii($file);\n            exit;\n        }\n\n        $this->log(\"Outputting image: $file\");\n\n        // Get image modification time\n        clearstatcache();\n        $lastModified = filemtime($file);\n        $gmdate = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        if (!$this->verbose) {\n            header('Last-Modified: ' . $gmdate . \" GMT\");\n        }\n\n        foreach($this->HTTPHeader as $key => $val) {\n            header(\"$key: $val\");\n        }\n\n        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {\n\n            if ($this->verbose) {\n                $this->log(\"304 not modified\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            header(\"HTTP/1.0 304 Not Modified\");\n\n        } else {\n\n            // Get details on image\n            $info = getimagesize($file);\n            !empty($info) or $this->raiseError(\"The file doesn't seem to be an image.\");\n            $mime = $info['mime'];\n            $size = filesize($file);\n\n            if ($this->verbose) {\n                $this->log(\"Last-Modified: \" . $gmdate . \" GMT\");\n                $this->log(\"Content-type: \" . $mime);\n                $this->log(\"Content-length: \" . $size);\n                $this->verboseOutput();\n                \n                if (is_null($this->verboseFileName)) {\n                    exit;\n                }\n            }\n\n            header(\"Content-type: $mime\");\n            header(\"Content-length: $size\");\n            readfile($file);\n        }\n\n        exit;\n    }\n\n\n\n    /**\n     * Create a JSON object from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string json-encoded representation of the image.\n     */\n    public function json($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $details = array();\n\n        clearstatcache();\n\n        $details['src']       = $this->imageSrc;\n        $lastModified         = filemtime($this->pathToImage);\n        $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $details['cache']       = basename($this->cacheFileName);\n        $lastModified           = filemtime($this->cacheFileName);\n        $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $this->load($file);\n\n        $details['filename']    = basename($file);\n        $details['mimeType']    = image_type_to_mime_type($this->fileType);\n        $details['width']       = $this->width;\n        $details['height']      = $this->height;\n        $details['aspectRatio'] = round($this->width / $this->height, 3);\n        $details['size']        = filesize($file);\n        $details['colors'] = $this->colorsTotal($this->image);\n        $details['includedFiles'] = count(get_included_files());\n        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . \" MB\" ;\n        $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . \" MB\";\n        $details['memoryLimit'] = ini_get('memory_limit');\n        \n        if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {\n            $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . \"s\";\n        }\n\n        if ($details['mimeType'] == 'image/png') {\n            $details['pngType'] = $this->getPngTypeAsString(null, $file);\n        }\n\n        $options = null;\n        if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) {\n            $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;\n        }\n\n        return json_encode($details, $options);\n    }\n\n\n\n    /**\n     * Set options for creating ascii version of image.\n     *\n     * @param array $options empty to use default or set options to change.\n     *\n     * @return void.\n     */\n    public function setAsciiOptions($options = array())\n    {\n        $this->asciiOptions = $options;\n    }\n\n\n\n    /**\n     * Create an ASCII version from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string ASCII representation of the image.\n     */\n    public function ascii($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $asciiArt = new CAsciiArt();\n        $asciiArt->setOptions($this->asciiOptions);\n        return $asciiArt->createFromFile($file);\n    }\n\n\n\n    /**\n     * Log an event if verbose mode.\n     *\n     * @param string $message to log.\n     *\n     * @return this\n     */\n    public function log($message)\n    {\n        if ($this->verbose) {\n            $this->log[] = $message;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Do verbose output to a file.\n     *\n     * @param string $fileName where to write the verbose output.\n     *\n     * @return void\n     */\n    public function setVerboseToFile($fileName)\n    {\n        $this->log(\"Setting verbose output to file.\");\n        $this->verboseFileName = $fileName;\n    }\n\n\n\n    /**\n     * Do verbose output and print out the log and the actual images.\n     *\n     * @return void\n     */\n    private function verboseOutput()\n    {\n        $log = null;\n        $this->log(\"As JSON: \\n\" . $this->json());\n        $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\");\n        $this->log(\"Memory limit: \" . ini_get('memory_limit'));\n\n        $included = get_included_files();\n        $this->log(\"Included files: \" . count($included));\n\n        foreach ($this->log as $val) {\n            if (is_array($val)) {\n                foreach ($val as $val1) {\n                    $log .= htmlentities($val1) . '<br/>';\n                }\n            } else {\n                $log .= htmlentities($val) . '<br/>';\n            }\n        }\n\n        if (!is_null($this->verboseFileName)) {\n            file_put_contents(\n                $this->verboseFileName,\n                str_replace(\"<br/>\", \"\\n\", $log)\n            );\n        } else {\n            echo <<<EOD\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n        }\n    }\n\n\n\n    /**\n     * Raise error, enables to implement a selection of error methods.\n     *\n     * @param string $message the error message to display.\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function raiseError($message)\n    {\n        throw new Exception($message);\n    }\n}\n\n"
  },
  {
    "path": "docs/api/files/CRemoteImage.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1879794739\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1879794739\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small></small>CRemoteImage.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CRemoteImage.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/CRemoteImage.php.txt",
    "content": "<?php\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CRemoteImage\n{\n    /**\n     * Path to cache files.\n     */\n    private $saveFolder = null;\n\n\n\n    /**\n     * Use cache or not.\n     */\n    private $useCache = true;\n\n\n\n    /**\n     * HTTP object to aid in download file.\n     */\n    private $http;\n\n\n\n    /**\n     * Status of the HTTP request.\n     */\n    private $status;\n\n\n\n    /**\n     * Defalt age for cached items 60*60*24*7.\n     */\n    private $defaultMaxAge = 604800;\n\n\n\n    /**\n     * Url of downloaded item.\n     */\n    private $url;\n\n\n\n    /**\n     * Base name of cache file for downloaded item and name of image.\n     */\n    private $fileName;\n\n\n\n    /**\n     * Filename for json-file with details of cached item.\n     */\n    private $fileJson;\n\n\n\n    /**\n     * Cache details loaded from file.\n     */\n    private $cache;\n\n\n\n    /**\n     * Get status of last HTTP request.\n     *\n     * @return int as status\n     */\n    public function getStatus()\n    {\n        return $this->status;\n    }\n\n\n\n    /**\n     * Get JSON details for cache item.\n     *\n     * @return array with json details on cache.\n     */\n    public function getDetails()\n    {\n        return $this->cache;\n    }\n\n\n\n    /**\n     * Set the path to the cache directory.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function setCache($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if cache is writable or throw exception.\n     *\n     * @return $this\n     *\n     * @throws Exception if cahce folder is not writable.\n     */\n    public function isCacheWritable()\n    {\n        if (!is_writable($this->saveFolder)) {\n            throw new Exception(\"Cache folder is not writable for downloaded files.\");\n        }\n        return $this;\n    }\n\n\n\n    /**\n     * Decide if the cache should be used or not before trying to download\n     * a remote file.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields.\n     *\n     * @return $this\n     */\n    public function setHeaderFields()\n    {\n        $this->http->setHeader(\"User-Agent\", \"CImage/0.7.2 (PHP/\". phpversion() . \" cURL)\");\n        $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\");\n\n        if ($this->useCache) {\n            $this->http->setHeader(\"Cache-Control\", \"max-age=0\");\n        } else {\n            $this->http->setHeader(\"Cache-Control\", \"no-cache\");\n            $this->http->setHeader(\"Pragma\", \"no-cache\");\n        }\n    }\n\n\n\n    /**\n     * Save downloaded resource to cache.\n     *\n     * @return string as path to saved file or false if not saved.\n     */\n    public function save()\n    {\n        $this->cache = array();\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n        $type         = $this->http->getContentType();\n\n        $this->cache['Date']           = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']        = $maxAge;\n        $this->cache['Content-Type']   = $type;\n        $this->cache['Url']            = $this->url;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        // Save only if body is a valid image\n        $body = $this->http->getBody();\n        $img = imagecreatefromstring($body);\n\n        if ($img !== false) {\n            file_put_contents($this->fileName, $body);\n            file_put_contents($this->fileJson, json_encode($this->cache));\n            return $this->fileName;\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Got a 304 and updates cache with new age.\n     *\n     * @return string as path to cached file.\n     */\n    public function updateCacheDetails()\n    {\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n\n        $this->cache['Date']    = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age'] = $maxAge;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        file_put_contents($this->fileJson, json_encode($this->cache));\n        return $this->fileName;\n    }\n\n\n\n    /**\n     * Download a remote file and keep a cache of downloaded files.\n     *\n     * @param string $url a remote url.\n     *\n     * @throws Exception when status code does not match 200 or 304.\n     *\n     * @return string as path to downloaded file or false if failed.\n     */\n    public function download($url)\n    {\n        $this->http = new CHttpGet();\n        $this->url = $url;\n\n        // First check if the cache is valid and can be used\n        $this->loadCacheDetails();\n\n        if ($this->useCache) {\n            $src = $this->getCachedSource();\n            if ($src) {\n                $this->status = 1;\n                return $src;\n            }\n        }\n\n        // Do a HTTP request to download item\n        $this->setHeaderFields();\n        $this->http->setUrl($this->url);\n        $this->http->doGet();\n\n        $this->status = $this->http->getStatus();\n        if ($this->status === 200) {\n            $this->isCacheWritable();\n            return $this->save();\n        } elseif ($this->status === 304) {\n            $this->isCacheWritable();\n            return $this->updateCacheDetails();\n        }\n\n        throw new Exception(\"Unknown statuscode when downloading remote image: \" . $this->status);\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return $this\n     */\n    public function loadCacheDetails()\n    {\n        $cacheFile = md5($this->url);\n        $this->fileName = $this->saveFolder . $cacheFile;\n        $this->fileJson = $this->fileName . \".json\";\n        if (is_readable($this->fileJson)) {\n            $this->cache = json_decode(file_get_contents($this->fileJson), true);\n        }\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return string as the path ot the image file or false if no cache.\n     */\n    public function getCachedSource()\n    {\n        $imageExists = is_readable($this->fileName);\n\n        // Is cache valid?\n        $date   = strtotime($this->cache['Date']);\n        $maxAge = $this->cache['Max-Age'];\n        $now    = time();\n        \n        if ($imageExists && $date + $maxAge > $now) {\n            return $this->fileName;\n        }\n\n        // Prepare for a 304 if available\n        if ($imageExists && isset($this->cache['Last-Modified'])) {\n            $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']);\n        }\n\n        return false;\n    }\n}\n\n"
  },
  {
    "path": "docs/api/files/CWhitelist.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1920829892\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1920829892\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small></small>CWhitelist.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CWhitelist.html\">CWhitelist</a></td>\n                            <td><em>Act as whitelist (or blacklist).</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/CWhitelist.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/CWhitelist.php.txt",
    "content": "<?php\n/**\n * Act as whitelist (or blacklist).\n *\n */\nclass CWhitelist\n{\n    /**\n     * Array to contain the whitelist options.\n     */\n    private $whitelist = array();\n\n\n\n    /**\n     * Set the whitelist from an array of strings, each item in the\n     * whitelist should be a regexp without the surrounding / or #.\n     *\n     * @param array $whitelist with all valid options,\n     *                         default is to clear the whitelist.\n     *\n     * @return $this\n     */\n    public function set($whitelist = array())\n    {\n        if (!is_array($whitelist)) {\n            throw new Exception(\"Whitelist is not of a supported format.\");\n        }\n\n        $this->whitelist = $whitelist;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if item exists in the whitelist.\n     *\n     * @param string $item      string to check.\n     * @param array  $whitelist optional with all valid options, default is null.\n     *\n     * @return boolean true if item is in whitelist, else false.\n     */\n    public function check($item, $whitelist = null)\n    {\n        if ($whitelist !== null) {\n            $this->set($whitelist);\n        }\n        \n        if (empty($item) or empty($this->whitelist)) {\n            return false;\n        }\n        \n        foreach ($this->whitelist as $regexp) {\n            if (preg_match(\"#$regexp#\", $item)) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n}\n\n"
  },
  {
    "path": "docs/api/files/autoload.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-105414451\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-105414451\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small></small>autoload.php</h1>\n                    <p><em>Autoloader for CImage and related class files.</em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/autoload.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/autoload.php.txt",
    "content": "<?php\n/**\n * Autoloader for CImage and related class files.\n *\n */\n//include __DIR__ . \"/../CHttpGet.php\";\n//include __DIR__ . \"/../CRemoteImage.php\";\n//include __DIR__ . \"/../CImage.php\";\n\n/**\n * Autoloader for classes.\n *\n * @param string $class the fully-qualified class name.\n *\n * @return void\n */\nspl_autoload_register(function ($class) {\n    //$path = CIMAGE_SOURCE_PATH . \"/{$class}.php\";\n    $path = __DIR__ . \"/{$class}.php\";\n    if (is_file($path)) {\n        require($path);\n    }\n});\n\n"
  },
  {
    "path": "docs/api/files/test%2FCImage_RemoteDownloadTest.php.txt",
    "content": "<?php\n/**\n * A testclass\n * \n */\nclass CImage_RemoteDownloadTest extends \\PHPUnit_Framework_TestCase\n{\n    /*\n     * remote_whitelist\n     */\n    private $remote_whitelist = [\n        '\\.facebook\\.com$',\n        '^(?:images|photos-[a-z])\\.ak\\.instagram\\.com$',\n        '\\.google\\.com$',\n    ];\n    \n    \n    \n    /**\n     * Provider for valid remote sources.\n     *\n     * @return array\n     */\n    public function providerValidRemoteSource()\n    {\n        return [\n            [\n                \"http://dbwebb.se/img.jpg\",\n                \"https://dbwebb.se/img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Provider for invalid remote sources.\n     *\n     * @return array\n     */\n    public function providerInvalidRemoteSource()\n    {\n        return [\n            [\n                \"ftp://dbwebb.se/img.jpg\",\n                \"dbwebb.se/img.jpg\",\n                \"img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     *\n     * @dataProvider providerValidRemoteSource\n     */\n    public function testAllowRemoteDownloadDefaultPatternValid($source)\n    {\n        $img = new CImage();\n        $img->setRemoteDownload(true);\n        \n        $res = $img->isRemoteSource($source);\n        $this->assertTrue($res, \"Should be a valid remote source: '$source'.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     *\n     * @dataProvider providerInvalidRemoteSource\n     */\n    public function testAllowRemoteDownloadDefaultPatternInvalid($source)\n    {\n        $img = new CImage();\n        $img->setRemoteDownload(true);\n        \n        $res = $img->isRemoteSource($source);\n        $this->assertFalse($res, \"Should not be a valid remote source: '$source'.\");\n    }\n\n\n\n    /**\n     * Provider for hostname matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameMatch()\n    {\n        return [\n            [\n                \"any.facebook.com\",\n                \"images.ak.instagram.com\",\n                \"google.com\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname matches the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameMatch\n     *\n     */\n    public function testRemoteHostWhitelistMatch($hostname)\n    {\n        $img = new CImage();\n        $img->setRemoteHostWhitelist($this->remote_whitelist);\n        \n        $res = $img->isRemoteSourceOnWhitelist(\"http://$hostname/img.jpg\");\n        $this->assertTrue($res, \"Should be a valid hostname on the whitelist: '$hostname'.\");\n    }\n\n\n\n    /**\n     * Provider for hostname not matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameNoMatch()\n    {\n        return [\n            [\n                \"example.com\",\n                \".com\",\n                \"img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname not matching the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameNoMatch\n     *\n     */\n    public function testRemoteHostWhitelistNoMatch($hostname)\n    {\n        $img = new CImage();\n        $img->setRemoteHostWhitelist($this->remote_whitelist);\n        \n        $res = $img->isRemoteSourceOnWhitelist(\"http://$hostname/img.jpg\");\n        $this->assertFalse($res, \"Should not be a valid hostname on the whitelist: '$hostname'.\");\n    }\n}\n\n"
  },
  {
    "path": "docs/api/files/test%2FCWhitelistTest.php.txt",
    "content": "<?php\n/**\n * A testclass\n * \n */\nclass CWhitelistTest extends \\PHPUnit_Framework_TestCase\n{\n    /*\n     * remote_whitelist\n     */\n    private $remote_whitelist = [\n        '\\.facebook\\.com$',\n        '^(?:images|photos-[a-z])\\.ak\\.instagram\\.com$',\n        '\\.google\\.com$',\n    ];\n    \n    \n    \n    /**\n     * Provider for hostname matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameMatch()\n    {\n        return [\n            [\n                \"any.facebook.com\",\n                \"images.ak.instagram.com\",\n                \"google.com\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Provider for hostname not matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameNoMatch()\n    {\n        return [\n            [\n                \"example.com\",\n                \".com\",\n                \"img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname matches the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameMatch\n     *\n     */\n    public function testRemoteHostWhitelistMatch($hostname)\n    {\n        $whitelist = new CWhitelist();\n        $whitelist->set($this->remote_whitelist);\n        \n        $res = $whitelist->check($hostname);\n        $this->assertTrue($res, \"Should be a valid hostname on the whitelist: '$hostname'.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname not matching the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameNoMatch\n     *\n     */\n    public function testRemoteHostWhitelistNoMatch($hostname)\n    {\n        $whitelist = new CWhitelist();\n        $whitelist->set($this->remote_whitelist);\n        \n        $res = $whitelist->check($hostname);\n        $this->assertFalse($res, \"Should not be a valid hostname on the whitelist: '$hostname'.\");\n    }\n}\n\n"
  },
  {
    "path": "docs/api/files/test%2Fconfig.php.txt",
    "content": "<?php\n/**\n * Get all configuration details to be able to execute the test suite.\n *\n */\nrequire __DIR__ . \"/../autoload.php\";\n\n"
  },
  {
    "path": "docs/api/files/test.CImage_RemoteDownloadTest.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-265146745\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-265146745\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>test</small>CImage_RemoteDownloadTest.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></td>\n                            <td><em>A testclass</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/test/CImage_RemoteDownloadTest.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/test.CWhitelistTest.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-372562288\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-372562288\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>test</small>CWhitelistTest.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></td>\n                            <td><em>A testclass</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/test/CWhitelistTest.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/test.config.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1069179048\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1069179048\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>test</small>config.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/test/config.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot/img.php.txt",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n$version = \"v0.7.7 (2015-10-21)\";\n\n\n\n/**\n * Display error message.\n *\n * @param string $msg to display.\n *\n * @return void\n */\nfunction errorPage($msg)\n{\n    global $mode;\n\n    header(\"HTTP/1.0 500 Internal Server Error\");\n\n    if ($mode == 'development') {\n        die(\"[img.php] $msg\");\n    }\n\n    error_log(\"[img.php] $msg\");\n    die(\"HTTP/1.0 500 Internal Server Error\");\n}\n\n\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\n        \"<p><b>img.php: Uncaught exception:</b> <p>\"\n        . $exception->getMessage()\n        . \"</p><pre>\"\n        . $exception->getTraceAsString()\n        . \"</pre>\"\n    );\n});\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null)\n{\n    global $verbose, $verboseFile;\n    static $log = array();\n\n    if (!($verbose || $verboseFile)) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    $log[] = $msg;\n}\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} elseif (!isset($config)) {\n    $config = array();\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n* vf - do verbose dump to file\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\n$verboseFile = getDefined('vf', true, false);\nverbose(\"img.php version = $version\");\n\n\n\n/**\n* status - do a verbose dump of the configuration\n*/\n$status = getDefined('status', true, false);\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is nod loaded.\");\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n    \n} elseif ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n\n} elseif ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n    $verboseFile = false;\n\n} elseif ($mode == 'test') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\");\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} elseif (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwdType     = getConfig('password_type', 'text');\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwd) {\n    switch($pwdType) {\n        case 'md5':\n            $passwordMatch = ($pwdConfig === md5($pwd));\n            break;\n        case 'hash':\n            $passwordMatch = password_verify($pwd, $pwdConfig);\n            break;\n        case 'text':\n            $passwordMatch = ($pwdConfig === $pwd);\n            break;\n        default:\n            $passwordMatch = false;\n    }\n}\n\nif ($pwdAlways && $passwordMatch !== true) {\n    errorPage(\"Password required and does not match or exists.\");\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer, PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n        verbose(\"Hotlinking since passwordmatch\");\n    } elseif ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\");\n    } elseif (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\");\n    } elseif (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n        verbose(\"Hotlinking disallowed but serverName matches refererHost.\");\n    } elseif (!empty($hotlinkingWhitelist)) {\n        $whitelist = new CWhitelist();\n        $allowedByWhitelist = $whitelist->check($refererHost, $hotlinkingWhitelist);\n\n        if ($allowedByWhitelist) {\n            verbose(\"Hotlinking/leeching allowed by whitelist.\");\n        } else {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist. Referer: $referer.\");\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\");\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Get the source files.\n */\n$autoloader  = getConfig('autoloader', false);\n$cimageClass = getConfig('cimage_class', false);\n\nif ($autoloader) {\n    require $autoloader;\n} elseif ($cimageClass) {\n    require $cimageClass;\n}\n\n\n\n/**\n * Create the class for the image.\n */\n$img = new CImage();\n$img->setVerbose($verbose || $verboseFile);\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $pattern);\n\n    $whitelist = getConfig('remote_whitelist', null);\n    $img->setRemoteHostWhitelist($whitelist);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = urldecode(get('src'))\n    or errorPage('Must set src-attribute.');\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \\.:]+$#');\n\n// Dummy image feature\n$dummyEnabled  = getConfig('dummy_enabled', true);\n$dummyFilename = getConfig('dummy_filename', 'dummy');\n$dummyImage = false;\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Filename contains invalid characters.');\n\nif ($dummyEnabled && $srcImage === $dummyFilename) {\n\n    // Prepare to create a dummy image and use it as the source image.\n    $dummyImage = true;\n\n} elseif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n\n} elseif ($imagePathConstraint) {\n\n    // Check that the image is a file below the directory 'image_path'.\n    $pathToImage = realpath($imagePath . $srcImage);\n    $imageDir    = realpath($imagePath);\n\n    is_file($pathToImage)\n        or errorPage(\n            'Source image is not a valid file, check the filename and that a\n            matching file exists on the filesystem.'\n        );\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.'\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.');\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.');\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.');\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Hight out of range.');\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range');\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * Do or do not resample image when resizing.\n */\n$resizeStrategy = getDefined(array('no-resample'), true, false);\n\nif ($resizeStrategy) {\n    $img->setCopyResizeStrategy($img::RESIZE);\n    verbose(\"Setting = Resize instead of resample\");\n}\n\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n$qualityDefault = getConfig('jpg_quality', null);\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range');\n\nif (is_null($quality) && !is_null($qualityDefault)) {\n    $quality = $qualityDefault;\n}\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n$compressDefault = getConfig('png_compression', null);\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range');\n\nif (is_null($compress) && !is_null($compressDefault)) {\n    $compress = $compressDefault;\n}\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range');\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n* json -  output the image as a JSON object with details on the image.\n* ascii - output the image as ASCII art.\n */\n$outputFormat = getDefined('json', 'json', null);\n$outputFormat = getDefined('ascii', 'ascii', $outputFormat);\n\nverbose(\"outputformat = $outputFormat\");\n\nif ($outputFormat == 'ascii') {\n    $defaultOptions = getConfig(\n        'ascii-options',\n        array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        )\n    );\n    $options = get('ascii');\n    $options = explode(',', $options);\n\n    if (isset($options[0]) && !empty($options[0])) {\n        $defaultOptions['characterSet'] = $options[0];\n    }\n\n    if (isset($options[1]) && !empty($options[1])) {\n        $defaultOptions['scale'] = $options[1];\n    }\n\n    if (isset($options[2]) && !empty($options[2])) {\n        $defaultOptions['luminanceStrategy'] = $options[2];\n    }\n\n    if (count($options) > 3) {\n        // Last option is custom character string\n        unset($options[0]);\n        unset($options[1]);\n        unset($options[2]);\n        $characterString = implode($options);\n        $defaultOptions['customCharacterSet'] = $characterString;\n    }\n\n    $img->setAsciiOptions($defaultOptions);\n}\n\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\");\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.');\n\n} elseif ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.');\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Get the cachepath from config.\n */\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n\n\n\n/**\n * Get the cachepath from config.\n */\n$cacheControl = getConfig('cache_control', null);\n\nif ($cacheControl) {\n    verbose(\"cacheControl = $cacheControl\");\n    $img->addHTTPHeader(\"Cache-Control\", $cacheControl);\n}\n\n\n\n/**\n * Prepare a dummy image and use it as source image.\n */\n$dummyDir = getConfig('dummy_dir', $cachePath. \"/\" . $dummyFilename);\n\nif ($dummyImage === true) {\n    is_writable($dummyDir)\n        or verbose(\"dummy dir not writable = $dummyDir\");\n\n    $img->setSaveFolder($dummyDir)\n        ->setSource($dummyFilename, $dummyDir)\n        ->setOptions(\n            array(\n                'newWidth'  => $newWidth,\n                'newHeight' => $newHeight,\n                'bgColor'   => $bgColor,\n            )\n        )\n        ->setJpegQuality($quality)\n        ->setPngCompression($compress)\n        ->createDummyImage()\n        ->generateFilename(null, false)\n        ->save(null, null, false);\n\n    $srcImage = $img->getTarget();\n    $imagePath = null;\n    \n    verbose(\"src (updated) = $srcImage\");\n}\n\n\n\n/**\n * Display status\n */\nif ($status) {\n    $text  = \"img.php version = $version\\n\";\n    $text .= \"PHP version = \" . PHP_VERSION . \"\\n\";\n    $text .= \"Running on: \" . $_SERVER['SERVER_SOFTWARE'] . \"\\n\";\n    $text .= \"Allow remote images = $allowRemote\\n\";\n    $text .= \"Cache writable = \" . is_writable($cachePath) . \"\\n\";\n    $text .= \"Cache dummy writable = \" . is_writable($dummyDir) . \"\\n\";\n    $text .= \"Alias path writable = \" . is_writable($aliasPath) . \"\\n\";\n\n    $no = extension_loaded('exif') ? null : 'NOT';\n    $text .= \"Extension exif is $no loaded.<br>\";\n\n    $no = extension_loaded('curl') ? null : 'NOT';\n    $text .= \"Extension curl is $no loaded.<br>\";\n\n    $no = extension_loaded('gd') ? null : 'NOT';\n    $text .= \"Extension gd is $no loaded.<br>\";\n\n    if (!$no) {\n        $text .= print_r(gd_info(), 1);\n    }\n\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage status</title>\n<pre>$text</pre>\nEOD;\n    exit;\n}\n\n\n\n/**\n * Log verbose details to file\n */\nif ($verboseFile) {\n    $img->setVerboseToFile(\"$cachePath/log.txt\");\n}\n\n\n\n/**\n * Hook after img.php configuration and before processing with CImage\n */\n$hookBeforeCImage = getConfig('hook_before_CImage', null);\n\nif (is_callable($hookBeforeCImage)) {\n    verbose(\"hookBeforeCImage activated\");\n    \n    $allConfig = $hookBeforeCImage($img, array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n            \n            // Other\n            'postProcessing' => $postProcessing,\n    ));\n    verbose(print_r($allConfig, 1));\n    extract($allConfig);\n}\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\nmime type: \" + data.mimeType + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio + ( data.pngType ? \"\\\\npng-type: \" + data.pngType : '');\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n\n"
  },
  {
    "path": "docs/api/files/webroot/img_config.php.txt",
    "content": "<?php\n/**\n * Configuration for img.php, name the config file the same as your img.php and\n * append _config. If you are testing out some in imgtest.php then label that\n * config-file imgtest_config.php.\n *\n */\nreturn array(\n\n    /**\n     * Set mode as 'strict', 'production' or 'development'.\n     *\n     * Default values:\n     *  mode: 'production'\n     */\n    //'mode' => 'production', // 'development', 'strict'\n\n\n\n    /**\n     * Where are the sources for the classfiles.\n     *\n     * Default values:\n     *  autoloader:  null     // used from v0.6.2\n     *  cimage_class: null    // used until v0.6.1\n     */\n    'autoloader'   =>  __DIR__ . '/../autoload.php',\n    //'cimage_class' =>  __DIR__ . '/../CImage.php',\n\n\n\n    /**\n     * Paths, where are the images stored and where is the cache.\n     * End all paths with a slash.\n     *\n     * Default values:\n     *  image_path: __DIR__ . '/img/'\n     *  cache_path: __DIR__ . '/../cache/'\n     *  alias_path: null\n     */\n    'image_path'   =>  __DIR__ . '/img/',\n    'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n\n\n\n    /**\n     * Use password to protect from missusage, send &pwd=... or &password=..\n     * with the request to match the password or set to false to disable.\n     * Passwords are only used together with options for remote download\n     * and aliasing.\n     *\n     * Create a passwords like this, depending on the type used:\n     *  text: 'my_password'\n     *  md5:  md5('my_password')\n     *  hash: password_hash('my_password', PASSWORD_DEFAULT)\n     *\n     * Default values.\n     *  password_always: false  // do not always require password,\n     *  password:        false  // as in do not use password\n     *  password_type:   'text' // use plain password, not encoded,\n     */\n    //'password_always' => false, // always require password,\n    //'password'        => false, // \"secret-password\",\n    //'password_type'   => 'text', // supports 'text', 'md5', 'hash',\n\n\n\n    /**\n     * Allow or disallow downloading of remote images available on\n     * remote servers. Default is to disallow remote download.\n     *\n     * When enabling remote download, the default is to allow download any\n     * link starting with http or https. This can be changed using\n     * remote_pattern.\n     *\n     * When enabling remote_whitelist a check is made that the hostname of the\n     * source to download matches the whitelist. By default the check is\n     * disabled and thereby allowing download from any hosts.\n     *\n     * Default values.\n     *  remote_allow:     false\n     *  remote_pattern:   null  // use default values from CImage which is to\n     *                          // allow download from any http- and\n     *                          // https-source.\n     *  remote_whitelist: null  // use default values from CImage which is to\n     *                          // allow download from any hosts.\n     */\n    //'remote_allow'     => true,\n    //'remote_pattern'   => '#^https?://#',\n    //'remote_whitelist' => array(\n    //    '\\.facebook\\.com$',\n    //    '^(?:images|photos-[a-z])\\.ak\\.instagram\\.com$',\n    //    '\\.google\\.com$'\n    //),\n\n\n\n    /**\n     * A regexp for validating characters in the image or alias filename.\n     *\n     * Default value:\n     *  valid_filename:  '#^[a-z0-9A-Z-/_ \\.:]+$#'\n     *  valid_aliasname: '#^[a-z0-9A-Z-_]+$#'\n     */\n     //'valid_filename'  => '#^[a-z0-9A-Z-/_ \\.:]+$#',\n     //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',\n\n\n\n     /**\n      * Change the default values for CImage quality and compression used\n      * when saving images.\n      *\n      * Default value:\n      *  jpg_quality:     null, integer between 0-100\n      *  png_compression: null, integer between 0-9\n      */\n      //'jpg_quality'  => 75,\n      //'png_compression' => 1,\n\n\n\n      /**\n       * A function (hook) can be called after img.php has processed all\n       * configuration options and before processing the image using CImage.\n       * The function receives the $img variabel and an array with the\n       * majority of current settings.\n       *\n       * Default value:\n       *  hook_before_CImage:     null\n       */\n       /*'hook_before_CImage' => function (CImage $img, Array $allConfig) {\n           if ($allConfig['newWidth'] > 10) {\n               $allConfig['newWidth'] *= 2;\n           }\n           return $allConfig;\n       },*/\n\n\n\n       /**\n        * Add header for cache control when outputting images.\n        *\n        * Default value:\n        *  cache_control: null, or set to string\n        */\n        //'cache_control' => \"max-age=86400\",\n\n\n\n     /**\n      * The name representing a dummy image which is automatically created\n      * and stored at the defined path. The dummy image can then be used\n      * inplace of an original image as a placeholder.\n      * The dummy_dir must be writable and it defaults to a subdir of the\n      * cache directory.\n      * Write protect the dummy_dir to prevent creation of new dummy images,\n      * but continue to use the existing ones.\n      *\n      * Default value:\n      *  dummy_enabled:  true as default, disable dummy feature by setting\n      *                  to false.\n      *  dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.\n      *  dummy_dir:      Defaults to subdirectory of 'cache_path',\n      *                  named the same as 'dummy_filename'\n      */\n      //'dummy_enabled' => true,\n      //'dummy_filename' => 'dummy',\n      //'dummy_dir' => 'some writable directory',\n\n\n\n     /**\n     * Check that the imagefile is a file below 'image_path' using realpath().\n     * Security constraint to avoid reaching images outside image_path.\n     * This means that symbolic links to images outside the image_path will fail.\n     *\n     * Default value:\n     *  image_path_constraint: true\n     */\n     //'image_path_constraint' => false,\n\n\n\n     /**\n     * Set default timezone.\n     *\n     * Default values.\n     *  default_timezone: ini_get('default_timezone') or 'UTC'\n     */\n    //'default_timezone' => 'UTC',\n\n\n\n    /**\n     * Max image dimensions, larger dimensions results in 404.\n     * This is basically a security constraint to avoid using resources on creating\n     * large (unwanted) images.\n     *\n     * Default values.\n     *  max_width:  2000\n     *  max_height: 2000\n     */\n    //'max_width'     => 2000,\n    //'max_height'    => 2000,\n\n\n\n    /**\n     * Set default background color for all images. Override it using\n     * option bgColor.\n     * Colorvalue is 6 digit hex string between 000000-FFFFFF\n     * or 8 digit hex string if using the alpha channel where\n     * the alpha value is between 00 (opaqe) and 7F (transparent),\n     * that is between 00000000-FFFFFF7F.\n     *\n     * Default values.\n     *  background_color: As specified by CImage\n     */\n    //'background_color' => \"FFFFFF\",\n    //'background_color' => \"FFFFFF7F\",\n\n\n\n    /**\n     * Post processing of images using external tools, set to true or false\n     * and set command to be executed.\n     *\n     * Default values.\n     *\n     *  png_filter:        false\n     *  png_filter_cmd:    '/usr/local/bin/optipng -q'\n     *\n     *  png_deflate:       false\n     *  png_deflate_cmd:   '/usr/local/bin/pngout -q'\n     *\n     *  jpeg_optimize:     false\n     *  jpeg_optimize_cmd: '/usr/local/bin/jpegtran -copy none -optimize'\n     */\n    /*\n    'postprocessing' => array(\n        'png_filter'        => false,\n        'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n        'png_deflate'       => false,\n        'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n        'jpeg_optimize'     => false,\n        'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n    ),\n    */\n\n\n\n    /**\n     * Create custom convolution expressions, matrix 3x3, divisor and\n     * offset.\n     *\n     * Default values.\n     *  convolution_constant: array()\n     */\n    /*\n    'convolution_constant' => array(\n        //'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        //'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n    ),\n    */\n\n\n\n    /**\n     * Prevent leeching of images by controlling the hostname of those who\n     * can access the images. Default is to allow hotlinking.\n     *\n     * Password apply when hotlinking is disallowed, use password to allow\n     * hotlinking.\n     *\n     * The whitelist is an array of regexpes for allowed hostnames that can\n     * hotlink images.\n     *\n     * Default values.\n     *  allow_hotlinking:     true\n     *  hotlinking_whitelist: array()\n     */\n     /*\n    'allow_hotlinking' => false,\n    'hotlinking_whitelist' => array(\n        '^dbwebb\\.se$',\n    ),\n    */\n\n\n    /**\n     * Create custom shortcuts for more advanced expressions.\n     *\n     * Default values.\n     *  shortcut: array(\n     *      'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n     *  )\n     */\n     /*\n    'shortcut' => array(\n        'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n    ),*/\n\n\n\n    /**\n     * Predefined size constants.\n     *\n     * These can be used together with &width or &height to create a constant value\n     * for a width or height where can be changed in one place.\n     * Useful when your site changes its layout or if you have a grid to fit images into.\n     *\n     * Example:\n     *  &width=w1  // results in width=613\n     *  &width=c2  // results in spanning two columns with a gutter, 30*2+10=70\n     *  &width=c24 // results in spanning whole grid 24*30+((24-1)*10)=950\n     *\n     * Default values.\n     *  size_constant: As specified by the function below.\n     */\n    /*\n    'size_constant' => function () {\n\n        // Set sizes to map constant to value, easier to use with width or height\n        $sizes = array(\n          'w1' => 613,\n          'w2' => 630,\n        );\n\n        // Add grid column width, useful for use as predefined size for width (or height).\n        $gridColumnWidth = 30;\n        $gridGutterWidth = 10;\n        $gridColumns     = 24;\n\n        for ($i = 1; $i <= $gridColumns; $i++) {\n            $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n        }\n\n        return $sizes;\n    },*/\n\n\n\n    /**\n     * Predefined aspect ratios.\n     *\n     * Default values.\n     *  aspect_ratio_constant: As the function below.\n     */\n    /*'aspect_ratio_constant' => function () {\n        return array(\n            '3:1'   => 3/1,\n            '3:2'   => 3/2,\n            '4:3'   => 4/3,\n            '8:5'   => 8/5,\n            '16:10' => 16/10,\n            '16:9'  => 16/9,\n            'golden' => 1.618,\n        );\n    },*/\n\n\n\n    /**\n     * default options for ascii image.\n     *\n     * Default values as specified below in the array.\n     *  ascii-options:\n     *   characterSet:       Choose any character set available in CAsciiArt.\n     *   scale:              How many pixels should each character\n     *                       translate to.\n     *   luminanceStrategy:  Choose any strategy available in CAsciiArt.\n     *   customCharacterSet: Define your own character set.\n     */\n    /*'ascii-options' => array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        );\n    },*/\n);\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fcheck_system.php.txt",
    "content": "<?php\n\necho 'Current PHP version: ' . phpversion() . '<br><br>';\n\necho 'Running on: ' . $_SERVER['SERVER_SOFTWARE'] . '<br><br>';\n\n$no = extension_loaded('gd') ? null : 'NOT';\necho \"Extension gd is $no loaded.<br>\";\n\n$no = extension_loaded('exif') ? null : 'NOT';\necho \"Extension exif is $no loaded.<br>\";\n\nif (!$no) {\n    echo \"<pre>\", var_dump(gd_info()), \"</pre>\";\n}\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fcompare%2Fcompare-test.php.txt",
    "content": "<?php\n$script = <<<EOD\nCImage.compare({\n    \"input1\": \"../img.php?src=car.png\",\n    \"input2\": \"../img.php?src=car.png&sharpen\",\n    \"input3\": \"../img.php?src=car.png&blur\",\n    \"input4\": \"../img.php?src=car.png&emboss\",\n    \"json\": true,\n    \"stack\": false\n});\nEOD;\n\ninclude __DIR__ . \"/compare.php\";\n"
  },
  {
    "path": "docs/api/files/webroot%2Fcompare%2Fcompare.php.txt",
    "content": "<!doctype html>\n<html lang=en>\n<head>\n<style>\n\nbody {\n}\n\ninput[type=text] {\n    width: 400px;\n}\n\n.hidden {\n    display: none;\n}\n\n#wrap {\n    position: relative;\n    overflow: visible;\n\n}\n\n.stack {\n    position: absolute;\n    left: 0;\n    top: 0;\n}\n\n.area {\n    float: left;\n    padding: 1em;\n    background-color: #fff;\n}\n\n.top {\n    z-index: 10;\n}\n\n</style>\n</head>\n\n<body>\n<h1>Compare images</h1>\n<p>Add link to images and visually compare them. Change the link och press return to load the image. <a href=\"http://dbwebb.se/opensource/cimage\">Read more...</a></p>\n\n<form>\n    <p>\n        <label>Image 1: <input type=\"text\" id=\"input1\" data-id=\"1\"></label> <img id=\"thumb1\"></br>\n        <label>Image 2: <input type=\"text\" id=\"input2\" data-id=\"2\"></label> <img id=\"thumb2\"></br>\n        <label>Image 3: <input type=\"text\" id=\"input3\" data-id=\"3\"></label> <img id=\"thumb3\"></br>\n        <label>Image 4: <input type=\"text\" id=\"input4\" data-id=\"4\"></label> <img id=\"thumb4\"></br>\n        <label><input type=\"checkbox\" id=\"viewDetails\">Hide image details?</label><br/>\n        <label><input type=\"checkbox\" id=\"stack\">Stack images?</label>\n    </p>\n</form>\n\n<div id=\"buttonWrap\" class=\"hidden\">\n    <button id=\"button1\" class=\"button\" data-id=\"1\">Image 1</button>\n    <button id=\"button2\" class=\"button\" data-id=\"2\">Image 2</button>\n    <button id=\"button3\" class=\"button\" data-id=\"3\">Image 3</button>\n    <button id=\"button4\" class=\"button\" data-id=\"4\">Image 4</button>\n</div>\n\n<div id=\"wrap\">\n\n    <div id=\"area1\" class=\"area\">\n        <code>Image 1</code><br>\n        <img id=\"img1\">\n        <pre id=\"json1\" class=\"json\"></pre>\n    </div>\n\n    <div id=\"area2\" class=\"area\">\n        <code>Image 2</code><br>\n        <img id=\"img2\">\n        <pre id=\"json2\" class=\"json\"></pre>\n    </div>\n\n    <div id=\"area3\" class=\"area\">\n        <code>Image 3</code><br>\n        <img id=\"img3\">\n        <pre id=\"json3\" class=\"json\"></pre>\n    </div>\n\n    <div id=\"area4\" class=\"area\">\n        <code>Image 4</code><br>\n        <img id=\"img4\">\n        <pre id=\"json4\" class=\"json\"></pre>\n    </div>\n\n</div>\n\n\n</body>\n\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script src=\"../js/cimage.js\"></script>\n<script>\n<?php \nif (isset($script)) {\n    echo $script; \n} else {\n    echo \"CImage.compare({});\";\n} ?>\n</script>\n\n</html>\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fimg.php.txt",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n$version = \"v0.7.0.x (latest)\";\n\n\n\n/**\n * Default configuration options, can be overridden in own config-file.\n *\n * @param string $msg to display.\n *\n * @return void\n */\nfunction errorPage($msg)\n{\n    global $mode;\n\n    header(\"HTTP/1.0 500 Internal Server Error\");\n\n    if ($mode == 'development') {\n        die(\"[img.php] $msg\");\n    } else {\n        error_log(\"[img.php] $msg\");\n        die(\"HTTP/1.0 500 Internal Server Error\");\n    }\n}\n\n\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\"<p><b>img.php: Uncaught exception:</b> <p>\" . $exception->getMessage() . \"</p><pre>\" . $exception->getTraceAsString(), \"</pre>\");\n});\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null)\n{\n    global $verbose;\n    static $log = array();\n\n    if (!$verbose) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    $log[] = $msg;\n}\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} else if (!isset($config)) {\n    $config = array();\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\nverbose(\"img.php version = $version\");\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is nod loaded.\");\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\");\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} else if (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwdAlways) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n    if (!$passwordMatch) {\n        errorPage(\"Password required and does not match or exists.\");\n    }\n\n} elseif ($pwdConfig && $pwd) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer, PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n    } else if ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\");\n    } else if (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\");\n    } else if (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n    } else if (!empty($hotlinkingWhitelist)) {\n\n        $allowedByWhitelist = false;\n        foreach ($hotlinkingWhitelist as $val) {\n            if (preg_match($val, $refererHost)) {\n                $allowedByWhitelist = true;\n            }\n        }\n\n        if (!$allowedByWhitelist) {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist.\");\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\");\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Get the source files.\n */\n$autoloader  = getConfig('autoloader', false);\n$cimageClass = getConfig('cimage_class', false);\n\nif ($autoloader) {\n    require $autoloader;\n} else if ($cimageClass) {\n    require $cimageClass;\n}\n\n\n\n/**\n * Create the class for the image.\n */\n$img = new CImage();\n$img->setVerbose($verbose);\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $pattern);\n\n    $whitelist = getConfig('remote_whitelist', null);\n    $img->setRemoteHostWhitelist($whitelist);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = get('src')\n    or errorPage('Must set src-attribute.');\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\\.:]+$#');\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Filename contains invalid characters.');\n\nif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n\n} else if ($imagePathConstraint) {\n\n    // Check that the image is a file below the directory 'image_path'.\n    $pathToImage = realpath($imagePath . $srcImage);\n    $imageDir    = realpath($imagePath);\n\n    is_file($pathToImage)\n        or errorPage(\n            'Source image is not a valid file, check the filename and that a\n            matching file exists on the filesystem.'\n        );\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.'\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.');\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.');\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.');\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Hight out of range.');\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range');\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range');\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range');\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range');\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n * json - output the image as a JSON object with details on the image.\n */\n$outputFormat = getDefined('json', 'json', null);\n\nverbose(\"json = $outputFormat\");\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\");\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.');\n\n} else if ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.');\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio;\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Get the cachepath from config.\n */\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fimg_config.php.txt",
    "content": "<?php\n/**\n * Configuration for img.php, name the config file the same as your img.php and\n * append _config. If you are testing out some in imgtest.php then label that\n * config-file imgtest_config.php.\n *\n */\nreturn array(\n\n    /**\n     * Set mode as 'strict', 'production' or 'development'.\n     *\n     * Default values:\n     *  mode: 'production'\n     */\n    'mode' => 'development',\n    //'mode' => 'production', // 'development', 'strict'\n\n\n\n    /**\n     * Where are the sources for the classfiles.\n     *\n     * Default values:\n     *  autoloader:  null     // used from v0.6.2\n     *  cimage_class: null    // used until v0.6.1\n     */\n    'autoloader'   =>  __DIR__ . '/../autoload.php',\n    //'cimage_class' =>  __DIR__ . '/../CImage.php',\n\n\n\n    /**\n     * Paths, where are the images stored and where is the cache.\n     * End all paths with a slash.\n     *\n     * Default values:\n     *  image_path: __DIR__ . '/img/'\n     *  cache_path: __DIR__ . '/../cache/'\n     *  alias_path: null\n     */\n    'image_path'   =>  __DIR__ . '/img/',\n    'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n\n\n\n    /**\n    * Use password to protect from missusage, send &pwd=... or &password=..\n    * with the request to match the password or set to false to disable.\n    * Passwords are only used together with the options for remote download\n    * and aliasing.\n    *\n    * Default values.\n    *  password:        false // as in do not use password\n    *  password_always: false // do not always require password,\n    */\n    //'password'        => false, // \"secret-password\",\n    //'password_always' => false, // always require password,\n\n\n\n    /**\n     * Allow or disallow downloading of remote images available on\n     * remote servers. Default is to disallow remote download. \n     * \n     * When enabling remote download, the default is to allow download any\n     * link starting with http or https. This can be changed using \n     * remote_pattern. \n     *\n     * When enabling remote_whitelist a check is made that the hostname of the \n     * source to download matches the whitelist. By default the check is \n     * disabled and thereby allowing download from any hosts.\n     *\n     * Default values.\n     *  remote_allow:     false\n     *  remote_pattern:   null  // use default values from CImage which is to\n     *                          // allow download from any http- and \n     *                          // https-source.\n     *  remote_whitelist: null  // use default values from CImage which is to \n     *                          // allow download from any hosts.\n     */\n    //'remote_allow'     => true,\n    //'remote_pattern'   => '#^https?://#',\n    //'remote_whitelist' => array(\n    //    '\\.facebook\\.com$',\n    //    '^(?:images|photos-[a-z])\\.ak\\.instagram\\.com$',\n    //    '\\.google\\.com$'\n    //),\n\n\n\n    /**\n     * A regexp for validating characters in the image or alias filename.\n     *\n     * Default value:\n     *  valid_filename:  '#^[a-z0-9A-Z-/_\\.:]+$#'\n     *  valid_aliasname: '#^[a-z0-9A-Z-_]+$#'\n     */\n     //'valid_filename'  => '#^[a-z0-9A-Z-/_\\.:]+$#',\n     //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',\n\n\n\n     /**\n     * Check that the imagefile is a file below 'image_path' using realpath().\n     * Security constraint to avoid reaching images outside image_path.\n     * This means that symbolic links to images outside the image_path will fail.\n     *\n     * Default value:\n     *  image_path_constraint: true\n     */\n     //'image_path_constraint' => false,\n\n\n\n     /**\n     * Set default timezone.\n     *\n     * Default values.\n     *  default_timezone: ini_get('default_timezone') or 'UTC'\n     */\n    //'default_timezone' => 'UTC',\n\n\n\n    /**\n     * Max image dimensions, larger dimensions results in 404.\n     * This is basically a security constraint to avoid using resources on creating\n     * large (unwanted) images.\n     *\n     * Default values.\n     *  max_width:  2000\n     *  max_height: 2000\n     */\n    //'max_width'     => 2000,\n    //'max_height'    => 2000,\n\n\n\n    /**\n     * Set default background color for all images. Override it using\n     * option bgColor.\n     * Colorvalue is 6 digit hex string between 000000-FFFFFF\n     * or 8 digit hex string if using the alpha channel where\n     * the alpha value is between 00 (opaqe) and 7F (transparent),\n     * that is between 00000000-FFFFFF7F.\n     *\n     * Default values.\n     *  background_color: As specified by CImage\n     */\n    //'background_color' => \"FFFFFF\",\n    //'background_color' => \"FFFFFF7F\",\n\n\n\n    /**\n     * Post processing of images using external tools, set to true or false\n     * and set command to be executed.\n     *\n     * Default values.\n     *\n     *  png_filter:        false\n     *  png_filter_cmd:    '/usr/local/bin/optipng -q'\n     *\n     *  png_deflate:       false\n     *  png_deflate_cmd:   '/usr/local/bin/pngout -q'\n     *\n     *  jpeg_optimize:     false\n     *  jpeg_optimize_cmd: '/usr/local/bin/jpegtran -copy none -optimize'\n     */\n    /*\n    'postprocessing' => array(\n        'png_filter'        => false,\n        'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n        'png_deflate'       => false,\n        'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n        'jpeg_optimize'     => false,\n        'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n    ),\n    */\n\n\n\n    /**\n     * Create custom convolution expressions, matrix 3x3, divisor and\n     * offset.\n     *\n     * Default values.\n     *  convolution_constant: array()\n     */\n    /*\n    'convolution_constant' => array(\n        //'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        //'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n    ),\n    */\n\n\n\n    /**\n     * Prevent leeching of images by controlling who can access them from where.\n     * Default it to allow hotlinking.\n     * Password apply when hotlinking is disallowed, use password to allow.\n     * The whitelist is an array of regexpes for allowed hostnames that can\n     * hotlink images.\n     *\n     * Default values.\n     *  allow_hotlinking:     true\n     *  hotlinking_whitelist: array()\n     */\n     /*\n    'allow_hotlinking' => false,\n    'hotlinking_whitelist' => array(\n        '#^localhost$#',\n        '#^dbwebb\\.se$#',\n    ),\n    */\n\n\n\n    /**\n     * Create custom shortcuts for more advanced expressions.\n     *\n     * Default values.\n     *  shortcut: array(\n     *      'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n     *  )\n     */\n     /*\n    'shortcut' => array(\n        'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n    ),*/\n\n\n\n    /**\n     * Predefined size constants.\n     *\n     * These can be used together with &width or &height to create a constant value\n     * for a width or height where can be changed in one place.\n     * Useful when your site changes its layout or if you have a grid to fit images into.\n     *\n     * Example:\n     *  &width=w1  // results in width=613\n     *  &width=c2  // results in spanning two columns with a gutter, 30*2+10=70\n     *  &width=c24 // results in spanning whole grid 24*30+((24-1)*10)=950\n     *\n     * Default values.\n     *  size_constant: As specified by the function below.\n     */\n    /*\n    'size_constant' => function () {\n\n        // Set sizes to map constant to value, easier to use with width or height\n        $sizes = array(\n          'w1' => 613,\n          'w2' => 630,\n        );\n\n        // Add grid column width, useful for use as predefined size for width (or height).\n        $gridColumnWidth = 30;\n        $gridGutterWidth = 10;\n        $gridColumns     = 24;\n\n        for ($i = 1; $i <= $gridColumns; $i++) {\n            $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n        }\n\n        return $sizes;\n    },*/\n\n\n\n    /**\n     * Predefined aspect ratios.\n     *\n     * Default values.\n     *  aspect_ratio_constant: As the function below.\n     */\n    /*'aspect_ratio_constant' => function () {\n        return array(\n            '3:1'   => 3/1,\n            '3:2'   => 3/2,\n            '4:3'   => 4/3,\n            '8:5'   => 8/5,\n            '16:10' => 16/10,\n            '16:9'  => 16/9,\n            'golden' => 1.618,\n        );\n    },*/\n);\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fimg_header.php.txt",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * This version is a all-in-one version of img.php, it is not dependant an any other file\n * so you can simply copy it to any place you want it. \n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n\n/**\n * Change configuration details in the array below or create a separate file\n * where you store the configuration details. \n *\n * The configuration file should be named the same name as this file and then \n * add '_config.php'. If this file is named 'img.php' then name the\n * config file should be named 'img_config.php'.\n *\n * The settings below are only a few of the available ones. Check the file in\n * webroot/img_config.php for a complete list of configuration options.\n */\n$config = array(\n\n    //'mode'         => 'production',               // 'production', 'development', 'strict'\n    //'image_path'   =>  __DIR__ . '/img/',\n    //'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n    //'remote_allow' => true,\n    //'password'     => false,                      // \"secret-password\",\n\n);\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fimgd.php.txt",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * This version is a all-in-one version of img.php, it is not dependant an any other file\n * so you can simply copy it to any place you want it. \n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n\n/**\n * Change configuration details in the array below or create a separate file\n * where you store the configuration details. \n *\n * The configuration file should be named the same name as this file and then \n * add '_config.php'. If this file is named 'img.php' then name the\n * config file should be named 'img_config.php'.\n *\n * The settings below are only a few of the available ones. Check the file in\n * webroot/img_config.php for a complete list of configuration options.\n */\n$config = array(\n\n    'mode'         => 'development',               // 'production', 'development', 'strict'\n    //'image_path'   =>  __DIR__ . '/img/',\n    //'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n    //'remote_allow' => true,\n    //'password'     => false,                      // \"secret-password\",\n\n);\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CHttpGet\n{\n    private $request  = array();\n    private $response = array();\n\n\n\n    /**\n    * Constructor\n    *\n    */\n    public function __construct()\n    {\n        $this->request['header'] = array();\n    }\n\n\n\n    /**\n     * Set the url for the request.\n     *\n     * @param string $url\n     *\n     * @return $this\n     */\n    public function setUrl($url)\n    {\n        $this->request['url'] = $url;\n        return $this;\n    }\n\n\n\n    /**\n     * Set custom header field for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function setHeader($field, $value)\n    {\n        $this->request['header'][] = \"$field: $value\";\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function parseHeader()\n    {\n        $header = explode(\"\\r\\n\", rtrim($this->response['headerRaw'], \"\\r\\n\"));\n        $output = array();\n\n        if ('HTTP' === substr($header[0], 0, 4)) {\n            list($output['version'], $output['status']) = explode(' ', $header[0]);\n            unset($header[0]);\n        }\n\n        foreach ($header as $entry) {\n            $pos = strpos($entry, ':');\n            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));\n        }\n\n        $this->response['header'] = $output;\n        return $this;\n    }\n\n\n\n    /**\n     * Perform the request.\n     *\n     * @param boolean $debug set to true to dump headers.\n     *\n     * @return boolean\n     */\n    public function doGet($debug = false)\n    {\n        $options = array(\n            CURLOPT_URL             => $this->request['url'],\n            CURLOPT_HEADER          => 1,\n            CURLOPT_HTTPHEADER      => $this->request['header'],\n            CURLOPT_AUTOREFERER     => true,\n            CURLOPT_RETURNTRANSFER  => true,\n            CURLINFO_HEADER_OUT     => $debug,\n            CURLOPT_CONNECTTIMEOUT  => 5,\n            CURLOPT_TIMEOUT         => 5,\n        );\n\n        $ch = curl_init();\n        curl_setopt_array($ch, $options);\n        $response = curl_exec($ch);\n\n        if (!$response) {\n            return false;\n        }\n\n        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n        $this->response['headerRaw'] = substr($response, 0, $headerSize);\n        $this->response['body']      = substr($response, $headerSize);\n\n        $this->parseHeader();\n\n        if ($debug) {\n            $info = curl_getinfo($ch);\n            echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\";\n            echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\";\n            echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\";\n        }\n\n        curl_close($ch);\n        return true;\n    }\n\n\n\n    /**\n     * Get HTTP code of response.\n     *\n     * @return integer as HTTP status code or null if not available.\n     */\n    public function getStatus()\n    {\n        return isset($this->response['header']['status'])\n            ? (int) $this->response['header']['status']\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @return int as timestamp.\n     */\n    public function getLastModified()\n    {\n        return isset($this->response['header']['Last-Modified'])\n            ? strtotime($this->response['header']['Last-Modified'])\n            : null;\n    }\n\n\n\n    /**\n     * Get content type.\n     *\n     * @return string as the content type or null if not existing or invalid.\n     */\n    public function getContentType()\n    {\n        $type = isset($this->response['header']['Content-Type'])\n            ? $this->response['header']['Content-Type']\n            : null;\n\n        return preg_match('#[a-z]+/[a-z]+#', $type)\n            ? $type\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @param mixed $default as default value (int seconds) if date is\n     *                       missing in response header.\n     *\n     * @return int as timestamp or $default if Date is missing in\n     *             response header.\n     */\n    public function getDate($default = false)\n    {\n        return isset($this->response['header']['Date'])\n            ? strtotime($this->response['header']['Date'])\n            : $default;\n    }\n\n\n\n    /**\n     * Get max age of cachable item.\n     *\n     * @param mixed $default as default value if date is missing in response\n     *                       header.\n     *\n     * @return int as timestamp or false if not available.\n     */\n    public function getMaxAge($default = false)\n    {\n        $cacheControl = isset($this->response['header']['Cache-Control'])\n            ? $this->response['header']['Cache-Control']\n            : null;\n\n        $maxAge = null;\n        if ($cacheControl) {\n            // max-age=2592000\n            $part = explode('=', $cacheControl);\n            $maxAge = ($part[0] == \"max-age\")\n                ? (int) $part[1]\n                : null;\n        }\n\n        if ($maxAge) {\n            return $maxAge;\n        }\n\n        $expire = isset($this->response['header']['Expires'])\n            ? strtotime($this->response['header']['Expires'])\n            : null;\n\n        return $expire ? $expire : $default;\n    }\n\n\n\n    /**\n     * Get body of response.\n     *\n     * @return string as body.\n     */\n    public function getBody()\n    {\n        return $this->response['body'];\n    }\n}\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CRemoteImage\n{\n    /**\n     * Path to cache files.\n     */\n    private $saveFolder = null;\n\n\n\n    /**\n     * Use cache or not.\n     */\n    private $useCache = true;\n\n\n\n    /**\n     * HTTP object to aid in download file.\n     */\n    private $http;\n\n\n\n    /**\n     * Status of the HTTP request.\n     */\n    private $status;\n\n\n\n    /**\n     * Defalt age for cached items 60*60*24*7.\n     */\n    private $defaultMaxAge = 604800;\n\n\n\n    /**\n     * Url of downloaded item.\n     */\n    private $url;\n\n\n\n    /**\n     * Base name of cache file for downloaded item.\n     */\n    private $fileName;\n\n\n\n    /**\n     * Filename for json-file with details of cached item.\n     */\n    private $fileJson;\n\n\n\n    /**\n     * Filename for image-file.\n     */\n    private $fileImage;\n\n\n\n    /**\n     * Cache details loaded from file.\n     */\n    private $cache;\n\n\n\n    /**\n     * Constructor\n     *\n     */\n    public function __construct()\n    {\n        ;\n    }\n\n\n    /**\n     * Get status of last HTTP request.\n     *\n     * @return int as status\n     */\n    public function getStatus()\n    {\n        return $this->status;\n    }\n\n\n\n    /**\n     * Get JSON details for cache item.\n     *\n     * @return array with json details on cache.\n     */\n    public function getDetails()\n    {\n        return $this->cache;\n    }\n\n\n\n    /**\n     * Set the path to the cache directory.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function setCache($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if cache is writable or throw exception.\n     *\n     * @return $this\n     *\n     * @throws Exception if cahce folder is not writable.\n     */\n    public function isCacheWritable()\n    {\n        if (!is_writable($this->saveFolder)) {\n            throw new Exception(\"Cache folder is not writable for downloaded files.\");\n        }\n        return $this;\n    }\n\n\n\n    /**\n     * Decide if the cache should be used or not before trying to download\n     * a remote file.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Translate a content type to a file extension.\n     *\n     * @param string $type a valid content type.\n     *\n     * @return string as file extension or false if no match.\n     */\n    function contentTypeToFileExtension($type) {\n        $extension = array(\n            'image/jpeg' => 'jpg',\n            'image/png'  => 'png',\n            'image/gif'  => 'gif',\n        );\n\n        return isset($extension[$type])\n        ? $extension[$type]\n        : false;\n    }\n\n\n\n    /**\n     * Set header fields.\n     *\n     * @return $this\n     */\n    function setHeaderFields() {\n        $this->http->setHeader(\"User-Agent\", \"CImage/0.6 (PHP/\". phpversion() . \" cURL)\");\n        $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\");\n\n        if ($this->useCache) {\n            $this->http->setHeader(\"Cache-Control\", \"max-age=0\");\n        } else {\n            $this->http->setHeader(\"Cache-Control\", \"no-cache\");\n            $this->http->setHeader(\"Pragma\", \"no-cache\");\n        }\n    }\n\n\n\n    /**\n     * Save downloaded resource to cache.\n     *\n     * @return string as path to saved file or false if not saved.\n     */\n    function save() {\n\n        $this->cache = array();\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n        $type         = $this->http->getContentType();\n        $extension    = $this->contentTypeToFileExtension($type);\n\n        $this->cache['Date']           = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']        = $maxAge;\n        $this->cache['Content-Type']   = $type;\n        $this->cache['File-Extension'] = $extension;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        if ($extension) {\n\n            $this->fileImage = $this->fileName . \".\" . $extension;\n\n            // Save only if body is a valid image\n            $body = $this->http->getBody();\n            $img = imagecreatefromstring($body);\n\n            if ($img !== false) {\n                file_put_contents($this->fileImage, $body);\n                file_put_contents($this->fileJson, json_encode($this->cache));\n                return $this->fileImage;\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Got a 304 and updates cache with new age.\n     *\n     * @return string as path to cached file.\n     */\n    function updateCacheDetails() {\n\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n\n        $this->cache['Date']     = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']  = $maxAge;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        file_put_contents($this->fileJson, json_encode($this->cache));\n        return $this->fileImage;\n    }\n\n\n\n    /**\n     * Download a remote file and keep a cache of downloaded files.\n     *\n     * @param string $url a remote url.\n     *\n     * @return string as path to downloaded file or false if failed.\n     */\n    function download($url) {\n\n        $this->http = new CHttpGet();\n        $this->url = $url;\n\n        // First check if the cache is valid and can be used\n        $this->loadCacheDetails();\n\n        if ($this->useCache) {\n            $src = $this->getCachedSource();\n            if ($src) {\n                $this->status = 1;\n                return $src;\n            }\n        }\n\n        // Do a HTTP request to download item\n        $this->setHeaderFields();\n        $this->http->setUrl($this->url);\n        $this->http->doGet();\n\n        $this->status = $this->http->getStatus();\n        if ($this->status === 200) {\n            $this->isCacheWritable();\n            return $this->save();\n        } else if ($this->status === 304) {\n            $this->isCacheWritable();\n            return $this->updateCacheDetails();\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return $this\n     */\n    public function loadCacheDetails()\n    {\n        $cacheFile = str_replace(array(\"/\", \":\", \"#\", \".\", \"?\"), \"-\", $this->url);\n        $this->fileName = $this->saveFolder . $cacheFile;\n        $this->fileJson = $this->fileName . \".json\";\n        if (is_readable($this->fileJson)) {\n            $this->cache = json_decode(file_get_contents($this->fileJson), true);\n        }\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return string as the path ot the image file or false if no cache.\n     */\n    public function getCachedSource()\n    {\n        $this->fileImage = $this->fileName . \".\" . $this->cache['File-Extension'];\n        $imageExists = is_readable($this->fileImage);\n\n        // Is cache valid?\n        $date   = strtotime($this->cache['Date']);\n        $maxAge = $this->cache['Max-Age'];\n        $now = time();\n        if ($imageExists && $date + $maxAge > $now) {\n            return $this->fileImage;\n        }\n\n        // Prepare for a 304 if available\n        if ($imageExists && isset($this->cache['Last-Modified'])) {\n            $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']);\n        }\n\n        return false;\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n */\nclass CImage\n{\n\n    /**\n     * Constants type of PNG image\n     */\n    const PNG_GREYSCALE         = 0;\n    const PNG_RGB               = 2;\n    const PNG_RGB_PALETTE       = 3;\n    const PNG_GREYSCALE_ALPHA   = 4;\n    const PNG_RGB_ALPHA         = 6;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const JPEG_QUALITY_DEFAULT = 60;\n\n\n\n    /**\n     * Quality level for JPEG images.\n     */\n    private $quality;\n\n\n\n    /**\n     * Is the quality level set from external use (true) or is it default (false)?\n     */\n    private $useQuality = false;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const PNG_COMPRESSION_DEFAULT = -1;\n\n\n\n    /**\n     * Compression level for PNG images.\n     */\n    private $compress;\n\n\n\n    /**\n     * Is the compress level set from external use (true) or is it default (false)?\n     */\n    private $useCompress = false;\n\n\n\n\n    /**\n     * Default background color, red, green, blue, alpha.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    /*\n    const BACKGROUND_COLOR = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );*/\n\n\n\n    /**\n     * Default background color to use.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    //private $bgColorDefault = self::BACKGROUND_COLOR;\n    private $bgColorDefault = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );\n\n\n    /**\n     * Background color to use, specified as part of options.\n     */\n    private $bgColor;\n\n\n\n    /**\n     * Where to save the target file.\n     */\n    private $saveFolder;\n\n\n\n    /**\n     * The working image object.\n     */\n    private $image;\n\n\n\n    /**\n     * The root folder of images (only used in constructor to create $pathToImage?).\n     */\n    private $imageFolder;\n\n\n\n    /**\n     * Image filename, may include subdirectory, relative from $imageFolder\n     */\n    private $imageSrc;\n\n\n\n    /**\n     * Actual path to the image, $imageFolder . '/' . $imageSrc\n     */\n    private $pathToImage;\n\n\n\n    /**\n     * Original file extension\n     */\n    private $fileExtension;\n\n\n\n    /**\n     * File extension to use when saving image.\n     */\n    private $extension;\n\n\n\n    /**\n     * Output format, supports null (image) or json.\n     */\n    private $outputFormat = null;\n\n\n\n    /**\n     * Verbose mode to print out a trace and display the created image\n     */\n    private $verbose = false;\n\n\n\n    /**\n     * Keep a log/trace on what happens\n     */\n    private $log = array();\n\n\n\n    /**\n     * Handle image as palette image\n     */\n    private $palette;\n\n\n\n    /**\n     * Target filename, with path, to save resulting image in.\n     */\n    private $cacheFileName;\n\n\n\n    /**\n     * Set a format to save image as, or null to use original format.\n     */\n    private $saveAs;\n\n\n    /**\n     * Path to command for filter optimize, for example optipng or null.\n     */\n    private $pngFilter;\n\n\n\n    /**\n     * Path to command for deflate optimize, for example pngout or null.\n     */\n    private $pngDeflate;\n\n\n\n    /**\n     * Path to command to optimize jpeg images, for example jpegtran or null.\n     */\n    private $jpegOptimize;\n\n\n    /**\n     * Image dimensions, calculated from loaded image.\n     */\n    private $width;  // Calculated from source image\n    private $height; // Calculated from source image\n\n\n    /**\n     * New image dimensions, incoming as argument or calculated.\n     */\n    private $newWidth;\n    private $newWidthOrig;  // Save original value\n    private $newHeight;\n    private $newHeightOrig; // Save original value\n\n\n    /**\n     * Change target height & width when different dpr, dpr 2 means double image dimensions.\n     */\n    private $dpr = 1;\n\n\n    /**\n     * Always upscale images, even if they are smaller than target image.\n     */\n    const UPSCALE_DEFAULT = true;\n    private $upscale = self::UPSCALE_DEFAULT;\n\n\n\n    /**\n     * Array with details on how to crop, incoming as argument and calculated.\n     */\n    public $crop;\n    public $cropOrig; // Save original value\n\n\n    /**\n     * String with details on how to do image convolution. String\n     * should map a key in the $convolvs array or be a string of\n     * 11 float values separated by comma. The first nine builds\n     * up the matrix, then divisor and last offset.\n     */\n    private $convolve;\n\n\n    /**\n     * Custom convolution expressions, matrix 3x3, divisor and offset.\n     */\n    private $convolves = array(\n        'lighten'       => '0,0,0, 0,12,0, 0,0,0, 9, 0',\n        'darken'        => '0,0,0, 0,6,0, 0,0,0, 9, 0',\n        'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n        'emboss'        => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0',\n        'emboss-alt'    => '-2,-1,0, -1,1,1, 0,1,2, 1, 0',\n        'blur'          => '1,1,1, 1,15,1, 1,1,1, 23, 0',\n        'gblur'         => '1,2,1, 2,4,2, 1,2,1, 16, 0',\n        'edge'          => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0',\n        'edge-alt'      => '0,1,0, 1,-4,1, 0,1,0, 1, 0',\n        'draw'          => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0',\n        'mean'          => '1,1,1, 1,1,1, 1,1,1, 9, 0',\n        'motion'        => '1,0,0, 0,1,0, 0,0,1, 3, 0',\n    );\n\n\n    /**\n     * Resize strategy to fill extra area with background color.\n     * True or false.\n     */\n    private $fillToFit;\n\n\n    /**\n     * Used with option area to set which parts of the image to use.\n     */\n    private $offset;\n\n\n\n    /**\n    * Calculate target dimension for image when using fill-to-fit resize strategy.\n    */\n    private $fillWidth;\n    private $fillHeight;\n\n\n\n    /**\n    * Allow remote file download, default is to disallow remote file download.\n    */\n    private $allowRemote = false;\n\n\n\n    /**\n     * Pattern to recognize a remote file.\n     */\n    //private $remotePattern = '#^[http|https]://#';\n    private $remotePattern = '#^https?://#';\n\n\n\n    /**\n     * Use the cache if true, set to false to ignore the cached file.\n     */\n    private $useCache = true;\n\n\n    /**\n     * Properties, the class is mutable and the method setOptions()\n     * decides (partly) what properties are created.\n     *\n     * @todo Clean up these and check if and how they are used\n     */\n\n    public $keepRatio;\n    public $cropToFit;\n    private $cropWidth;\n    private $cropHeight;\n    public $crop_x;\n    public $crop_y;\n    public $filters;\n    private $type; // Calculated from source image\n    private $attr; // Calculated from source image\n    private $useOriginal; // Use original image if possible\n\n\n\n\n    /**\n     * Constructor, can take arguments to init the object.\n     *\n     * @param string $imageSrc    filename which may contain subdirectory.\n     * @param string $imageFolder path to root folder for images.\n     * @param string $saveFolder  path to folder where to save the new file or null to skip saving.\n     * @param string $saveName    name of target file when saveing.\n     */\n    public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null)\n    {\n        $this->setSource($imageSrc, $imageFolder);\n        $this->setTarget($saveFolder, $saveName);\n    }\n\n\n\n    /**\n     * Set verbose mode.\n     *\n     * @param boolean $mode true or false to enable and disable verbose mode,\n     *                      default is true.\n     *\n     * @return $this\n     */\n    public function setVerbose($mode = true)\n    {\n        $this->verbose = $mode;\n        return $this;\n    }\n\n\n\n    /**\n     * Set save folder, base folder for saving cache files.\n     *\n     * @todo clean up how $this->saveFolder is used in other methods.\n     *\n     * @param string $path where to store cached files.\n     *\n     * @return $this\n     */\n    public function setSaveFolder($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Use cache or not.\n     *\n     * @todo clean up how $this->noCache is used in other methods.\n     *\n     * @param string $use true or false to use cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Allow or disallow remote image download.\n     *\n     * @param boolean $allow   true or false to enable and disable.\n     * @param string  $pattern to use to detect if its a remote file.\n     *\n     * @return $this\n     */\n    public function setRemoteDownload($allow, $pattern = null)\n    {\n        $this->allowRemote = $allow;\n        $this->remotePattern = $pattern ? $pattern : $this->remotePattern;\n\n        $this->log(\"Set remote download to: \"\n            . ($this->allowRemote ? \"true\" : \"false\")\n            . \" using pattern \"\n            . $this->remotePattern);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the image resource is a remote file or not.\n     *\n     * @param string $src check if src is remote.\n     *\n     * @return boolean true if $src is a remote file, else false.\n     */\n    public function isRemoteSource($src)\n    {\n        $remote = preg_match($this->remotePattern, $src);\n        $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\"));\n        return $remote;\n    }\n\n\n\n    /**\n     * Check if file extension is valid as a file extension.\n     *\n     * @param string $extension of image file.\n     *\n     * @return $this\n     */\n    private function checkFileExtension($extension)\n    {\n        $valid = array('jpg', 'jpeg', 'png', 'gif');\n\n        in_array(strtolower($extension), $valid)\n            or $this->raiseError('Not a valid file extension.');\n\n        return $this;\n    }\n\n\n\n    /**\n     * Download a remote image and return path to its local copy.\n     *\n     * @param string $src remote path to image.\n     *\n     * @return string as path to downloaded remote source.\n     */\n    public function downloadRemoteSource($src)\n    {\n        $remote = new CRemoteImage();\n        $cache  = $this->saveFolder . \"/remote/\";\n\n        if (!is_dir($cache)) {\n            if (!is_writable($this->saveFolder)) {\n                throw new Exception(\"Can not create remote cache, cachefolder not writable.\");\n            }\n            mkdir($cache);\n            $this->log(\"The remote cache does not exists, creating it.\");\n        }\n\n        if (!is_writable($cache)) {\n            $this->log(\"The remote cache is not writable.\");\n        }\n\n        $remote->setCache($cache);\n        $remote->useCache($this->useCache);\n        $src = $remote->download($src);\n\n        $this->log(\"Remote HTTP status: \" . $remote->getStatus());\n        $this->log(\"Remote item has local cached file: $src\");\n        $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true));\n\n        return $src;\n    }\n\n\n\n    /**\n     * Set src file.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     */\n    public function setSource($src, $dir = null)\n    {\n        if (!isset($src)) {\n            return $this;\n        }\n\n        if ($this->allowRemote && $this->isRemoteSource($src)) {\n            $src = $this->downloadRemoteSource($src);\n            $dir = null;\n        }\n\n        if (!isset($dir)) {\n            $dir = dirname($src);\n            $src = basename($src);\n        }\n\n        $this->imageSrc       = ltrim($src, '/');\n        $this->imageFolder    = rtrim($dir, '/');\n        $this->pathToImage    = $this->imageFolder . '/' . $this->imageSrc;\n        $this->fileExtension  = strtolower(pathinfo($this->pathToImage, PATHINFO_EXTENSION));\n        //$this->extension      = $this->fileExtension;\n\n        $this->checkFileExtension($this->fileExtension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set target file.\n     *\n     * @param string $src of target image.\n     * @param string $dir as base directory where images are stored.\n     *\n     * @return $this\n     */\n    public function setTarget($src = null, $dir = null)\n    {\n        if (!(isset($src) && isset($dir))) {\n            return $this;\n        }\n\n        $this->saveFolder     = $dir;\n        $this->cacheFileName  = $dir . '/' . $src;\n\n        /* Allow readonly cache\n        is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n        */\n\n        // Sanitize filename\n        $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName);\n        $this->log(\"The cache file name is: \" . $this->cacheFileName);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set options to use when processing image.\n     *\n     * @param array $args used when processing image.\n     *\n     * @return $this\n     */\n    public function setOptions($args)\n    {\n        $this->log(\"Set new options for processing image.\");\n\n        $defaults = array(\n            // Options for calculate dimensions\n            'newWidth'    => null,\n            'newHeight'   => null,\n            'aspectRatio' => null,\n            'keepRatio'   => true,\n            'cropToFit'   => false,\n            'fillToFit'   => null,\n            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),\n            'area'        => null, //'0,0,0,0',\n            'upscale'     => self::UPSCALE_DEFAULT,\n\n            // Options for caching or using original\n            'useCache'    => true,\n            'useOriginal' => true,\n\n            // Pre-processing, before resizing is done\n            'scale'        => null,\n            'rotateBefore' => null,\n            'autoRotate'  => false,\n\n            // General options\n            'bgColor'     => null,\n\n            // Post-processing, after resizing is done\n            'palette'     => null,\n            'filters'     => null,\n            'sharpen'     => null,\n            'emboss'      => null,\n            'blur'        => null,\n            'convolve'       => null,\n            'rotateAfter' => null,\n\n            // Output format\n            'outputFormat' => null,\n            'dpr'          => 1,\n\n            // Options for saving\n            //'quality'     => null,\n            //'compress'    => null,\n            //'saveAs'      => null,\n        );\n\n        // Convert crop settings from string to array\n        if (isset($args['crop']) && !is_array($args['crop'])) {\n            $pices = explode(',', $args['crop']);\n            $args['crop'] = array(\n                'width'   => $pices[0],\n                'height'  => $pices[1],\n                'start_x' => $pices[2],\n                'start_y' => $pices[3],\n            );\n        }\n\n        // Convert area settings from string to array\n        if (isset($args['area']) && !is_array($args['area'])) {\n                $pices = explode(',', $args['area']);\n                $args['area'] = array(\n                    'top'    => $pices[0],\n                    'right'  => $pices[1],\n                    'bottom' => $pices[2],\n                    'left'   => $pices[3],\n                );\n        }\n\n        // Convert filter settings from array of string to array of array\n        if (isset($args['filters']) && is_array($args['filters'])) {\n            foreach ($args['filters'] as $key => $filterStr) {\n                $parts = explode(',', $filterStr);\n                $filter = $this->mapFilter($parts[0]);\n                $filter['str'] = $filterStr;\n                for ($i=1; $i<=$filter['argc']; $i++) {\n                    if (isset($parts[$i])) {\n                        $filter[\"arg{$i}\"] = $parts[$i];\n                    } else {\n                        throw new Exception(\n                            'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php'\n                        );\n                    }\n                }\n                $args['filters'][$key] = $filter;\n            }\n        }\n\n        // Merge default arguments with incoming and set properties.\n        //$args = array_merge_recursive($defaults, $args);\n        $args = array_merge($defaults, $args);\n        foreach ($defaults as $key => $val) {\n            $this->{$key} = $args[$key];\n        }\n\n        if ($this->bgColor) {\n            $this->setDefaultBackgroundColor($this->bgColor);\n        }\n\n        // Save original values to enable re-calculating\n        $this->newWidthOrig  = $this->newWidth;\n        $this->newHeightOrig = $this->newHeight;\n        $this->cropOrig      = $this->crop;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Map filter name to PHP filter and id.\n     *\n     * @param string $name the name of the filter.\n     *\n     * @return array with filter settings\n     * @throws Exception\n     */\n    private function mapFilter($name)\n    {\n        $map = array(\n            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),\n            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),\n            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),\n            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),\n            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),\n            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),\n            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),\n            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),\n            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),\n            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),\n            'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),\n            'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),\n        );\n\n        if (isset($map[$name])) {\n            return $map[$name];\n        } else {\n            throw new Exception('No such filter.');\n        }\n    }\n\n\n\n    /**\n     * Load image details from original image file.\n     *\n     * @param string $file the file to load or null to use $this->pathToImage.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function loadImageDetails($file = null)\n    {\n        $file = $file ? $file : $this->pathToImage;\n\n        is_readable($file)\n            or $this->raiseError('Image file does not exist.');\n\n        // Get details on image\n        $info = list($this->width, $this->height, $this->type, $this->attr) = getimagesize($file);\n        !empty($info) or $this->raiseError(\"The file doesn't seem to be an image.\");\n\n        if ($this->verbose) {\n            $this->log(\"Image file: {$file}\");\n            $this->log(\"Image width x height (type): {$this->width} x {$this->height} ({$this->type}).\");\n            $this->log(\"Image filesize: \" . filesize($file) . \" bytes.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Init new width and height and do some sanity checks on constraints, before any\n     * processing can be done.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function initDimensions()\n    {\n        $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // width as %\n        if ($this->newWidth[strlen($this->newWidth)-1] == '%') {\n            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;\n            $this->log(\"Setting new width based on % to {$this->newWidth}\");\n        }\n\n        // height as %\n        if ($this->newHeight[strlen($this->newHeight)-1] == '%') {\n            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;\n            $this->log(\"Setting new height based on % to {$this->newHeight}\");\n        }\n\n        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');\n\n        // width & height from aspect ratio\n        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {\n            if ($this->aspectRatio >= 1) {\n                $this->newWidth   = $this->width;\n                $this->newHeight  = $this->width / $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n\n            } else {\n                $this->newHeight  = $this->height;\n                $this->newWidth   = $this->height * $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n            }\n\n        } elseif ($this->aspectRatio && is_null($this->newWidth)) {\n            $this->newWidth   = $this->newHeight * $this->aspectRatio;\n            $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\");\n\n        } elseif ($this->aspectRatio && is_null($this->newHeight)) {\n            $this->newHeight  = $this->newWidth / $this->aspectRatio;\n            $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\");\n        }\n\n        // Change width & height based on dpr\n        if ($this->dpr != 1) {\n            if (!is_null($this->newWidth)) {\n                $this->newWidth  = round($this->newWidth * $this->dpr);\n                $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\");\n            }\n            if (!is_null($this->newHeight)) {\n                $this->newHeight = round($this->newHeight * $this->dpr);\n                $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\");\n            }\n        }\n\n        // Check values to be within domain\n        is_null($this->newWidth)\n            or is_numeric($this->newWidth)\n            or $this->raiseError('Width not numeric');\n\n        is_null($this->newHeight)\n            or is_numeric($this->newHeight)\n            or $this->raiseError('Height not numeric');\n\n        $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Calculate new width and height of image, based on settings.\n     *\n     * @return $this\n     */\n    public function calculateNewWidthAndHeight()\n    {\n        // Crop, use cropped width and height as base for calulations\n        $this->log(\"Calculate new width and height.\");\n        $this->log(\"Original width x height is {$this->width} x {$this->height}.\");\n        $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // Check if there is an area to crop off\n        if (isset($this->area)) {\n            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);\n            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);\n            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);\n            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);\n            $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];\n            $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];\n            $this->width  = $this->offset['width'];\n            $this->height = $this->offset['height'];\n            $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\");\n            $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\");\n        }\n\n        $width  = $this->width;\n        $height = $this->height;\n\n        // Check if crop is set\n        if ($this->crop) {\n            $width  = $this->crop['width']  = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];\n            $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];\n\n            if ($this->crop['start_x'] == 'left') {\n                $this->crop['start_x'] = 0;\n            } elseif ($this->crop['start_x'] == 'right') {\n                $this->crop['start_x'] = $this->width - $width;\n            } elseif ($this->crop['start_x'] == 'center') {\n                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);\n            }\n\n            if ($this->crop['start_y'] == 'top') {\n                $this->crop['start_y'] = 0;\n            } elseif ($this->crop['start_y'] == 'bottom') {\n                $this->crop['start_y'] = $this->height - $height;\n            } elseif ($this->crop['start_y'] == 'center') {\n                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);\n            }\n\n            $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\");\n        }\n\n        // Calculate new width and height if keeping aspect-ratio.\n        if ($this->keepRatio) {\n\n            $this->log(\"Keep aspect ratio.\");\n\n            // Crop-to-fit and both new width and height are set.\n            if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Use newWidth and newHeigh as width/height, image should fit in box.\n                $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\");\n\n            } elseif (isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Both new width and height are set.\n                // Use newWidth and newHeigh as max width/height, image should not be larger.\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n                $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;\n                $this->newWidth  = round($width  / $ratio);\n                $this->newHeight = round($height / $ratio);\n                $this->log(\"New width and height was set.\");\n\n            } elseif (isset($this->newWidth)) {\n\n                // Use new width as max-width\n                $factor = (float)$this->newWidth / (float)$width;\n                $this->newHeight = round($factor * $height);\n                $this->log(\"New width was set.\");\n\n            } elseif (isset($this->newHeight)) {\n\n                // Use new height as max-hight\n                $factor = (float)$this->newHeight / (float)$height;\n                $this->newWidth = round($factor * $width);\n                $this->log(\"New height was set.\");\n\n            }\n\n            // Get image dimensions for pre-resize image.\n            if ($this->cropToFit || $this->fillToFit) {\n\n                // Get relations of original & target image\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n\n                if ($this->cropToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Crop to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;\n                    $this->cropWidth  = round($width  / $ratio);\n                    $this->cropHeight = round($height / $ratio);\n                    $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\");\n\n                } else if ($this->fillToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Fill to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;\n                    $this->fillWidth  = round($width  / $ratio);\n                    $this->fillHeight = round($height / $ratio);\n                    $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\");\n                }\n            }\n        }\n\n        // Crop, ensure to set new width and height\n        if ($this->crop) {\n            $this->log(\"Crop.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }\n\n        // Fill to fit, ensure to set new width and height\n        /*if ($this->fillToFit) {\n            $this->log(\"FillToFit.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }*/\n\n        // No new height or width is set, use existing measures.\n        $this->newWidth  = round(isset($this->newWidth) ? $this->newWidth : $this->width);\n        $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height);\n        $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Re-calculate image dimensions when original image dimension has changed.\n     *\n     * @return $this\n     */\n    public function reCalculateDimensions()\n    {\n        $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight);\n\n        $this->newWidth  = $this->newWidthOrig;\n        $this->newHeight = $this->newHeightOrig;\n        $this->crop      = $this->cropOrig;\n\n        $this->initDimensions()\n             ->calculateNewWidthAndHeight();\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set extension for filename to save as.\n     *\n     * @param string $saveas extension to save image as\n     *\n     * @return $this\n     */\n    public function setSaveAsExtension($saveAs = null)\n    {\n        if (isset($saveAs)) {\n            $saveAs = strtolower($saveAs);\n            $this->checkFileExtension($saveAs);\n            $this->saveAs = $saveAs;\n            $this->extension = $saveAs;\n        }\n\n        $this->log(\"Prepare to save image using as: \" . $this->extension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set JPEG quality to use when saving image\n     *\n     * @param int $quality as the quality to set.\n     *\n     * @return $this\n     */\n    public function setJpegQuality($quality = null)\n    {\n        if ($quality) {\n            $this->useQuality = true;\n        }\n\n        $this->quality = isset($quality)\n            ? $quality\n            : self::JPEG_QUALITY_DEFAULT;\n\n        (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting JPEG quality to {$this->quality}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set PNG compressen algorithm to use when saving image\n     *\n     * @param int $compress as the algorithm to use.\n     *\n     * @return $this\n     */\n    public function setPngCompression($compress = null)\n    {\n        if ($compress) {\n            $this->useCompress = true;\n        }\n\n        $this->compress = isset($compress)\n            ? $compress\n            : self::PNG_COMPRESSION_DEFAULT;\n\n        (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting PNG compression level to {$this->compress}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Use original image if possible, check options which affects image processing.\n     *\n     * @param boolean $useOrig default is to use original if possible, else set to false.\n     *\n     * @return $this\n     */\n    public function useOriginalIfPossible($useOrig = true)\n    {\n        if ($useOrig\n            && ($this->newWidth == $this->width)\n            && ($this->newHeight == $this->height)\n            && !$this->area\n            && !$this->crop\n            && !$this->cropToFit\n            && !$this->fillToFit\n            && !$this->filters\n            && !$this->sharpen\n            && !$this->emboss\n            && !$this->blur\n            && !$this->convolve\n            && !$this->palette\n            && !$this->useQuality\n            && !$this->useCompress\n            && !$this->saveAs\n            && !$this->rotateBefore\n            && !$this->rotateAfter\n            && !$this->autoRotate\n            && !$this->bgColor\n            && ($this->upscale === self::UPSCALE_DEFAULT)\n        ) {\n            $this->log(\"Using original image.\");\n            $this->output($this->pathToImage);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Generate filename to save file in cache.\n     *\n     * @param string $base as basepath for storing file.\n     *\n     * @return $this\n     */\n    public function generateFilename($base)\n    {\n        $parts        = pathinfo($this->pathToImage);\n        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;\n        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;\n        $crop_x       = $this->crop_x       ? \"_x{$this->crop_x}\"        : null;\n        $crop_y       = $this->crop_y       ? \"_y{$this->crop_y}\"        : null;\n        $scale        = $this->scale        ? \"_s{$this->scale}\"         : null;\n        $bgColor      = $this->bgColor      ? \"_bgc{$this->bgColor}\"     : null;\n        $quality      = $this->quality      ? \"_q{$this->quality}\"       : null;\n        $compress     = $this->compress     ? \"_co{$this->compress}\"     : null;\n        $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null;\n        $rotateAfter  = $this->rotateAfter  ? \"_ra{$this->rotateAfter}\"  : null;\n\n        $width  = $this->newWidth;\n        $height = $this->newHeight;\n\n        $offset = isset($this->offset)\n            ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left']\n            : null;\n\n        $crop = $this->crop\n            ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y']\n            : null;\n\n        $filters = null;\n        if (isset($this->filters)) {\n            foreach ($this->filters as $filter) {\n                if (is_array($filter)) {\n                    $filters .= \"_f{$filter['id']}\";\n                    for ($i=1; $i<=$filter['argc']; $i++) {\n                        $filters .= \":\".$filter[\"arg{$i}\"];\n                    }\n                }\n            }\n        }\n\n        $sharpen = $this->sharpen ? 's' : null;\n        $emboss  = $this->emboss  ? 'e' : null;\n        $blur    = $this->blur    ? 'b' : null;\n        $palette = $this->palette ? 'p' : null;\n\n        $autoRotate = $this->autoRotate ? 'ar' : null;\n\n        $this->extension = isset($this->extension)\n            ? $this->extension\n            : $parts['extension'];\n\n        $optimize = null;\n        if ($this->extension == 'jpeg' || $this->extension == 'jpg') {\n            $optimize = $this->jpegOptimize ? 'o' : null;\n        } elseif ($this->extension == 'png') {\n            $optimize .= $this->pngFilter  ? 'f' : null;\n            $optimize .= $this->pngDeflate ? 'd' : null;\n        }\n\n        $convolve = null;\n        if ($this->convolve) {\n            $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve);\n        }\n\n        $upscale = null;\n        if ($this->upscale !== self::UPSCALE_DEFAULT) {\n            $upscale = '_nu';\n        }\n\n        $subdir = str_replace('/', '-', dirname($this->imageSrc));\n        $subdir = ($subdir == '.') ? '_.' : $subdir;\n        $file = $subdir . '_' . $parts['filename'] . '_' . $width . '_'\n            . $height . $offset . $crop . $cropToFit . $fillToFit\n            . $crop_x . $crop_y . $upscale\n            . $quality . $filters . $sharpen . $emboss . $blur . $palette . $optimize\n            . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor . $convolve\n            . '.' . $this->extension;\n\n        return $this->setTarget($file, $base);\n    }\n\n\n\n    /**\n     * Use cached version of image, if possible.\n     *\n     * @param boolean $useCache is default true, set to false to avoid using cached object.\n     *\n     * @return $this\n     */\n    public function useCacheIfPossible($useCache = true)\n    {\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime   = filemtime($this->pathToImage);\n            $cacheTime  = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                if ($this->useCache) {\n                    if ($this->verbose) {\n                        $this->log(\"Use cached file.\");\n                        $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $this->output($this->cacheFileName, $this->outputFormat);\n                } else {\n                    $this->log(\"Cache is valid but ignoring it by intention.\");\n                }\n            } else {\n                $this->log(\"Original file is modified, ignoring cache.\");\n            }\n        } else {\n            $this->log(\"Cachefile does not exists or ignoring it.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Error message when failing to load somehow corrupt image.\n     *\n     * @return void\n     *\n     */\n    public function failedToLoad()\n    {\n        header(\"HTTP/1.0 404 Not Found\");\n        echo(\"CImage.php says 404: Fatal error when opening image.<br>\");\n\n        switch ($this->fileExtension) {\n            case 'jpg':\n            case 'jpeg':\n                $this->image = imagecreatefromjpeg($this->pathToImage);\n                break;\n\n            case 'gif':\n                $this->image = imagecreatefromgif($this->pathToImage);\n                break;\n\n            case 'png':\n                $this->image = imagecreatefrompng($this->pathToImage);\n                break;\n        }\n\n        exit();\n    }\n\n\n\n    /**\n     * Load image from disk.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     *\n     */\n    public function load($src = null, $dir = null)\n    {\n        if (isset($src)) {\n            $this->setSource($src, $dir);\n        }\n\n        $this->log(\"Opening file as {$this->fileExtension}.\");\n\n        switch ($this->fileExtension) {\n            case 'jpg':\n            case 'jpeg':\n                $this->image = @imagecreatefromjpeg($this->pathToImage);\n                $this->image or $this->failedToLoad();\n                break;\n\n            case 'gif':\n                $this->image = @imagecreatefromgif($this->pathToImage);\n                $this->image or $this->failedToLoad();\n                break;\n\n            case 'png':\n                $this->image = @imagecreatefrompng($this->pathToImage);\n                $this->image or $this->failedToLoad();\n\n                $type = $this->getPngType();\n                $hasFewColors = imagecolorstotal($this->image);\n\n                if ($type == self::PNG_RGB_PALETTE || ($hasFewColors > 0 && $hasFewColors <= 256)) {\n                    if ($this->verbose) {\n                        $this->log(\"Handle this image as a palette image.\");\n                    }\n                    $this->palette = true;\n                }\n                break;\n\n            default:\n                $this->image = false;\n                throw new Exception('No support for this file extension.');\n        }\n\n        if ($this->verbose) {\n            $this->log(\"imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\"imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\"Number of colors in image = \" . $this->colorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\"Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the type of PNG image.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    private function getPngType()\n    {\n        $pngType = ord(file_get_contents($this->pathToImage, false, null, 25, 1));\n\n        switch ($pngType) {\n\n            case self::PNG_GREYSCALE:\n                $this->log(\"PNG is type 0, Greyscale.\");\n                break;\n\n            case self::PNG_RGB:\n                $this->log(\"PNG is type 2, RGB\");\n                break;\n\n            case self::PNG_RGB_PALETTE:\n                $this->log(\"PNG is type 3, RGB with palette\");\n                break;\n\n            case self::PNG_GREYSCALE_ALPHA:\n                $this->Log(\"PNG is type 4, Greyscale with alpha channel\");\n                break;\n\n            case self::PNG_RGB_ALPHA:\n                $this->Log(\"PNG is type 6, RGB with alpha channel (PNG 32-bit)\");\n                break;\n\n            default:\n                $this->Log(\"PNG is UNKNOWN type, is it really a PNG image?\");\n        }\n\n        return $pngType;\n    }\n\n\n\n    /**\n     * Calculate number of colors in an image.\n     *\n     * @param resource $im the image.\n     *\n     * @return int\n     */\n    private function colorsTotal($im)\n    {\n        if (imageistruecolor($im)) {\n            $this->log(\"Colors as true color.\");\n            $h = imagesy($im);\n            $w = imagesx($im);\n            $c = array();\n            for ($x=0; $x < $w; $x++) {\n                for ($y=0; $y < $h; $y++) {\n                    @$c['c'.imagecolorat($im, $x, $y)]++;\n                }\n            }\n            return count($c);\n        } else {\n            $this->log(\"Colors as palette.\");\n            return imagecolorstotal($im);\n        }\n    }\n\n\n\n    /**\n     * Preprocess image before rezising it.\n     *\n     * @return $this\n     */\n    public function preResize()\n    {\n        $this->log(\"Pre-process before resizing\");\n\n        // Rotate image\n        if ($this->rotateBefore) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateBefore, $this->bgColor)\n                 ->reCalculateDimensions();\n        }\n\n        // Auto-rotate image\n        if ($this->autoRotate) {\n            $this->log(\"Auto rotating image.\");\n            $this->rotateExif()\n                 ->reCalculateDimensions();\n        }\n\n        // Scale the original image before starting\n        if (isset($this->scale)) {\n            $this->log(\"Scale by {$this->scale}%\");\n            $newWidth  = $this->width * $this->scale / 100;\n            $newHeight = $this->height * $this->scale / 100;\n            $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);\n            imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);\n            $this->image = $img;\n            $this->width = $newWidth;\n            $this->height = $newHeight;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return $this\n     */\n    public function resize()\n    {\n\n        $this->log(\"Starting to Resize()\");\n        $this->log(\"Upscale = '$this->upscale'\");\n\n        // Only use a specified area of the image, $this->offset is defining the area to use\n        if (isset($this->offset)) {\n\n            $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\");\n            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);\n            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);\n            $this->image = $img;\n            $this->width = $this->offset['width'];\n            $this->height = $this->offset['height'];\n        }\n\n        if ($this->crop) {\n\n            // Do as crop, take only part of image\n            $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\");\n            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);\n            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);\n            $this->image = $img;\n            $this->width = $this->crop['width'];\n            $this->height = $this->crop['height'];\n        }\n\n        if (!$this->upscale) {\n            // Consider rewriting the no-upscale code to fit within this if-statement,\n            // likely to be more readable code.\n            // The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch\n        }\n\n        if ($this->cropToFit) {\n\n            // Resize by crop to fit\n            $this->log(\"Resizing using strategy - Crop to fit\");\n\n            if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight)) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n\n                $posX = 0;\n                $posY = 0;\n\n                if ($this->newWidth > $this->width) {\n                    $posX = round(($this->newWidth - $this->width) / 2);\n                }\n\n                if ($this->newHeight > $this->height) {\n                    $posY = round(($this->newHeight - $this->height) / 2);\n                }\n\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            } else {\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n                $imgPreCrop   = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } else if ($this->fillToFit) {\n\n            // Resize by fill to fit\n            $this->log(\"Resizing using strategy - Fill to fit\");\n\n            $posX = 0;\n            $posY = 0;\n\n            $ratioOrig = $this->width / $this->height;\n            $ratioNew  = $this->newWidth / $this->newHeight;\n\n            // Check ratio for landscape or portrait\n            if ($ratioOrig < $ratioNew) {\n                $posX = round(($this->newWidth - $this->fillWidth) / 2);\n            } else {\n                $posY = round(($this->newHeight - $this->fillHeight) / 2);\n            }\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n                $posX = round(($this->fillWidth - $this->width) / 2);\n                $posY = round(($this->fillHeight - $this->height) / 2);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n\n            } else {\n                $imgPreFill   = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {\n\n            // Resize it\n            $this->log(\"Resizing, new height and/or width\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                if (!$this->keepRatio) {\n                    $this->log(\"Resizing - stretch to fit selected.\");\n\n                    $posX = 0;\n                    $posY = 0;\n                    $cropX = 0;\n                    $cropY = 0;\n\n                    if ($this->newWidth > $this->width && $this->newHeight > $this->height) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                    } else if ($this->newWidth > $this->width) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $cropY = round(($this->height - $this->newHeight) / 2);\n                    } else if ($this->newHeight > $this->height) {\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                        $cropX = round(($this->width - $this->newWidth) / 2);\n                    }\n\n                    //$this->log(\"posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY.\");\n                    $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                    imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n                    $this->image = $imageResized;\n                    $this->width = $this->newWidth;\n                    $this->height = $this->newHeight;\n                }\n            } else {\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);\n                $this->image = $imageResized;\n                $this->width = $this->newWidth;\n                $this->height = $this->newHeight;\n            }\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Postprocess image after rezising image.\n     *\n     * @return $this\n     */\n    public function postResize()\n    {\n        $this->log(\"Post-process after resizing\");\n\n        // Rotate image\n        if ($this->rotateAfter) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateAfter, $this->bgColor);\n        }\n\n        // Apply filters\n        if (isset($this->filters) && is_array($this->filters)) {\n\n            foreach ($this->filters as $filter) {\n                $this->log(\"Applying filter {$filter['type']}.\");\n\n                switch ($filter['argc']) {\n\n                    case 0:\n                        imagefilter($this->image, $filter['type']);\n                        break;\n\n                    case 1:\n                        imagefilter($this->image, $filter['type'], $filter['arg1']);\n                        break;\n\n                    case 2:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']);\n                        break;\n\n                    case 3:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']);\n                        break;\n\n                    case 4:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']);\n                        break;\n                }\n            }\n        }\n\n        // Convert to palette image\n        if ($this->palette) {\n            $this->log(\"Converting to palette image.\");\n            $this->trueColorToPalette();\n        }\n\n        // Blur the image\n        if ($this->blur) {\n            $this->log(\"Blur.\");\n            $this->blurImage();\n        }\n\n        // Emboss the image\n        if ($this->emboss) {\n            $this->log(\"Emboss.\");\n            $this->embossImage();\n        }\n\n        // Sharpen the image\n        if ($this->sharpen) {\n            $this->log(\"Sharpen.\");\n            $this->sharpenImage();\n        }\n\n        // Custom convolution\n        if ($this->convolve) {\n            //$this->log(\"Convolve: \" . $this->convolve);\n            $this->imageConvolution();\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using angle.\n     *\n     * @param float $angle        to rotate image.\n     * @param int   $anglebgColor to fill image with if needed.\n     *\n     * @return $this\n     */\n    public function rotate($angle, $bgColor)\n    {\n        $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\");\n\n        $color = $this->getBackgroundColor();\n        $this->image = imagerotate($this->image, $angle, $color);\n\n        $this->width  = imagesx($this->image);\n        $this->height = imagesy($this->image);\n\n        $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using information in EXIF.\n     *\n     * @return $this\n     */\n    public function rotateExif()\n    {\n        if (!in_array($this->fileExtension, array('jpg', 'jpeg'))) {\n            $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\");\n            return $this;\n        }\n\n        $exif = exif_read_data($this->pathToImage);\n\n        if (!empty($exif['Orientation'])) {\n            switch ($exif['Orientation']) {\n                case 3:\n                    $this->log(\"Autorotate 180.\");\n                    $this->rotate(180, $this->bgColor);\n                    break;\n\n                case 6:\n                    $this->log(\"Autorotate -90.\");\n                    $this->rotate(-90, $this->bgColor);\n                    break;\n\n                case 8:\n                    $this->log(\"Autorotate 90.\");\n                    $this->rotate(90, $this->bgColor);\n                    break;\n\n                default:\n                    $this->log(\"Autorotate ignored, unknown value as orientation.\");\n            }\n        } else {\n            $this->log(\"Autorotate ignored, no orientation in EXIF.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert true color image to palette image, keeping alpha.\n     * http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\n     *\n     * @return void\n     */\n    public function trueColorToPalette()\n    {\n        $img = imagecreatetruecolor($this->width, $this->height);\n        $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);\n        imagecolortransparent($img, $bga);\n        imagefill($img, 0, 0, $bga);\n        imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);\n        imagetruecolortopalette($img, false, 255);\n        imagesavealpha($img, true);\n\n        if (imageistruecolor($this->image)) {\n            $this->log(\"Matching colors with true color image.\");\n            imagecolormatch($this->image, $img);\n        }\n\n        $this->image = $img;\n    }\n\n\n\n    /**\n     * Sharpen image using image convolution.\n     *\n     * @return $this\n     */\n    public function sharpenImage()\n    {\n        $this->imageConvolution('sharpen');\n        return $this;\n    }\n\n\n\n    /**\n     * Emboss image using image convolution.\n     *\n     * @return $this\n     */\n    public function embossImage()\n    {\n        $this->imageConvolution('emboss');\n        return $this;\n    }\n\n\n\n    /**\n     * Blur image using image convolution.\n     *\n     * @return $this\n     */\n    public function blurImage()\n    {\n        $this->imageConvolution('blur');\n        return $this;\n    }\n\n\n\n    /**\n     * Create convolve expression and return arguments for image convolution.\n     *\n     * @param string $expression constant string which evaluates to a list of\n     *                           11 numbers separated by komma or such a list.\n     *\n     * @return array as $matrix (3x3), $divisor and $offset\n     */\n    public function createConvolveArguments($expression)\n    {\n        // Check of matching constant\n        if (isset($this->convolves[$expression])) {\n            $expression = $this->convolves[$expression];\n        }\n\n        $part = explode(',', $expression);\n        $this->log(\"Creating convolution expressen: $expression\");\n\n        // Expect list of 11 numbers, split by , and build up arguments\n        if (count($part) != 11) {\n            throw new Exception(\n                \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\"\n            );\n        }\n\n        array_walk($part, function ($item, $key) {\n            if (!is_numeric($item)) {\n                throw new Exception(\"Argument to convolve expression should be float but is not.\");\n            }\n        });\n\n        return array(\n            array(\n                array($part[0], $part[1], $part[2]),\n                array($part[3], $part[4], $part[5]),\n                array($part[6], $part[7], $part[8]),\n            ),\n            $part[9],\n            $part[10],\n        );\n    }\n\n\n\n    /**\n     * Add custom expressions (or overwrite existing) for image convolution.\n     *\n     * @param array $options Key value array with strings to be converted\n     *                       to convolution expressions.\n     *\n     * @return $this\n     */\n    public function addConvolveExpressions($options)\n    {\n        $this->convolves = array_merge($this->convolves, $options);\n        return $this;\n    }\n\n\n\n    /**\n     * Image convolution.\n     *\n     * @param string $options A string with 11 float separated by comma.\n     *\n     * @return $this\n     */\n    public function imageConvolution($options = null)\n    {\n        // Use incoming options or use $this.\n        $options = $options ? $options : $this->convolve;\n\n        // Treat incoming as string, split by +\n        $this->log(\"Convolution with '$options'\");\n        $options = explode(\":\", $options);\n\n        // Check each option if it matches constant value\n        foreach ($options as $option) {\n            list($matrix, $divisor, $offset) = $this->createConvolveArguments($option);\n            imageconvolution($this->image, $matrix, $divisor, $offset);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set default background color between 000000-FFFFFF or if using\n     * alpha 00000000-FFFFFF7F.\n     *\n     * @param string $color as hex value.\n     *\n     * @return $this\n    */\n    public function setDefaultBackgroundColor($color)\n    {\n        $this->log(\"Setting default background color to '$color'.\");\n\n        if (!(strlen($color) == 6 || strlen($color) == 8)) {\n            throw new Exception(\n                \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $red    = hexdec(substr($color, 0, 2));\n        $green  = hexdec(substr($color, 2, 2));\n        $blue   = hexdec(substr($color, 4, 2));\n\n        $alpha = (strlen($color) == 8)\n            ? hexdec(substr($color, 6, 2))\n            : null;\n\n        if (($red < 0 || $red > 255)\n            || ($green < 0 || $green > 255)\n            || ($blue < 0 || $blue > 255)\n            || ($alpha < 0 || $alpha > 127)\n        ) {\n            throw new Exception(\n                \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $this->bgColor = strtolower($color);\n        $this->bgColorDefault = array(\n            'red'   => $red,\n            'green' => $green,\n            'blue'  => $blue,\n            'alpha' => $alpha\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the background color.\n     *\n     * @param resource $img the image to work with or null if using $this->image.\n     *\n     * @return color value or null if no background color is set.\n    */\n    private function getBackgroundColor($img = null)\n    {\n        $img = isset($img) ? $img : $this->image;\n\n        if ($this->bgColorDefault) {\n\n            $red   = $this->bgColorDefault['red'];\n            $green = $this->bgColorDefault['green'];\n            $blue  = $this->bgColorDefault['blue'];\n            $alpha = $this->bgColorDefault['alpha'];\n\n            if ($alpha) {\n                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);\n            } else {\n                $color = imagecolorallocate($img, $red, $green, $blue);\n            }\n\n            return $color;\n\n        } else {\n            return 0;\n        }\n    }\n\n\n\n    /**\n     * Create a image and keep transparency for png and gifs.\n     *\n     * @param int $width of the new image.\n     * @param int $height of the new image.\n     *\n     * @return image resource.\n    */\n    private function createImageKeepTransparency($width, $height)\n    {\n        $this->log(\"Creating a new working image width={$width}px, height={$height}px.\");\n        $img = imagecreatetruecolor($width, $height);\n        imagealphablending($img, false);\n        imagesavealpha($img, true);\n\n        $index = imagecolortransparent($this->image);\n        if ($index != -1) {\n\n            imagealphablending($img, true);\n            $transparent = imagecolorsforindex($this->image, $index);\n            $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']);\n            imagefill($img, 0, 0, $color);\n            $index = imagecolortransparent($img, $color);\n            $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\");\n\n        } elseif ($this->bgColorDefault) {\n\n            $color = $this->getBackgroundColor($img);\n            imagefill($img, 0, 0, $color);\n            $this->Log(\"Filling image with background color.\");\n        }\n\n        return $img;\n    }\n\n\n\n    /**\n     * Set optimizing  and post-processing options.\n     *\n     * @param array $options with config for postprocessing with external tools.\n     *\n     * @return $this\n     */\n    public function setPostProcessingOptions($options)\n    {\n        if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) {\n            $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd'];\n        } else {\n            $this->jpegOptimizeCmd = null;\n        }\n\n        if (isset($options['png_filter']) && $options['png_filter']) {\n            $this->pngFilterCmd = $options['png_filter_cmd'];\n        } else {\n            $this->pngFilterCmd = null;\n        }\n\n        if (isset($options['png_deflate']) && $options['png_deflate']) {\n            $this->pngDeflateCmd = $options['png_deflate_cmd'];\n        } else {\n            $this->pngDeflateCmd = null;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Save image.\n     *\n     * @param string $src  as target filename.\n     * @param string $base as base directory where to store images.\n     *\n     * @return $this or false if no folder is set.\n     */\n    public function save($src = null, $base = null)\n    {\n        if (isset($src)) {\n            $this->setTarget($src, $base);\n        }\n\n        is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n\n        switch(strtolower($this->extension)) {\n\n            case 'jpeg':\n            case 'jpg':\n                $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\");\n                imagejpeg($this->image, $this->cacheFileName, $this->quality);\n\n                // Use JPEG optimize if defined\n                if ($this->jpegOptimizeCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->log($cmd);\n                    $this->log($res);\n                }\n                break;\n\n            case 'gif':\n                $this->Log(\"Saving image as GIF to cache.\");\n                imagegif($this->image, $this->cacheFileName);\n                break;\n\n            case 'png':\n                $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\");\n\n                // Turn off alpha blending and set alpha flag\n                imagealphablending($this->image, false);\n                imagesavealpha($this->image, true);\n                imagepng($this->image, $this->cacheFileName, $this->compress);\n\n                // Use external program to filter PNG, if defined\n                if ($this->pngFilterCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngFilterCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to deflate PNG, if defined\n                if ($this->pngDeflateCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n                break;\n\n            default:\n                $this->RaiseError('No support for this file extension.');\n                break;\n        }\n\n        if ($this->verbose) {\n            clearstatcache();\n            $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n            $this->log(\"imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\"imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\"Number of colors in image = \" . $this->ColorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\"Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Create a hard link, as an alias, to the cached file.\n     *\n     * @param string $alias where to store the link,\n     *                      filename without extension.\n     *\n     * @return $this\n     */\n    public function linkToCacheFile($alias)\n    {\n        if ($alias === null) {\n            $this->log(\"Ignore creating alias.\");\n            return $this;\n        }\n\n        $alias = $alias . \".\" . $this->extension;\n\n        if (is_readable($alias)) {\n            unlink($alias);\n        }\n\n        $res = link($this->cacheFileName, $alias);\n\n        if ($res) {\n            $this->log(\"Created an alias as: $alias\");\n        } else {\n            $this->log(\"Failed to create the alias: $alias\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Output image to browser using caching.\n     *\n     * @param string $file   to read and output, default is to use $this->cacheFileName\n     * @param string $format set to json to output file as json object with details\n     *\n     * @return void\n     */\n    public function output($file = null, $format = null)\n    {\n        if (is_null($file)) {\n            $file = $this->cacheFileName;\n        }\n\n        if (is_null($format)) {\n            $format = $this->outputFormat;\n        }\n\n        $this->log(\"Output format is: $format\");\n\n        if (!$this->verbose && $format == 'json') {\n            header('Content-type: application/json');\n            echo $this->json($file);\n            exit;\n        }\n\n        $this->log(\"Outputting image: $file\");\n\n        // Get image modification time\n        clearstatcache();\n        $lastModified = filemtime($file);\n        $gmdate = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        if (!$this->verbose) {\n            header('Last-Modified: ' . $gmdate . \" GMT\");\n        }\n\n        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {\n\n            if ($this->verbose) {\n                $this->log(\"304 not modified\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            header(\"HTTP/1.0 304 Not Modified\");\n\n        } else {\n\n            if ($this->verbose) {\n                $this->log(\"Last modified: \" . $gmdate . \" GMT\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            // Get details on image\n            $info = getimagesize($file);\n            !empty($info) or $this->raiseError(\"The file doesn't seem to be an image.\");\n            $mime = $info['mime'];\n\n            header('Content-type: ' . $mime);\n            readfile($file);\n        }\n\n        exit;\n    }\n\n\n\n    /**\n     * Create a JSON object from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string json-encoded representation of the image.\n     */\n    public function json($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $details = array();\n\n        clearstatcache();\n\n        $details['src']        = $this->imageSrc;\n        $lastModified          = filemtime($this->pathToImage);\n        $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $details['cache']        = basename($this->cacheFileName);\n        $lastModified            = filemtime($this->cacheFileName);\n        $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $this->loadImageDetails($file);\n\n        $details['filename'] = basename($file);\n        $details['width']  = $this->width;\n        $details['height'] = $this->height;\n        $details['aspectRatio'] = round($this->width / $this->height, 3);\n        $details['size'] = filesize($file);\n\n        $this->load($file);\n        $details['colors'] = $this->colorsTotal($this->image);\n\n        $options = null;\n        if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) {\n            $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;\n        }\n\n        return json_encode($details, $options);\n    }\n\n\n\n    /**\n     * Log an event if verbose mode.\n     *\n     * @param string $message to log.\n     *\n     * @return this\n     */\n    public function log($message)\n    {\n        if ($this->verbose) {\n            $this->log[] = $message;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Do verbose output and print out the log and the actual images.\n     *\n     * @return void\n     */\n    private function verboseOutput()\n    {\n        $log = null;\n        $this->log(\"As JSON: \\n\" . $this->json());\n        $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\");\n        $this->log(\"Memory limit: \" . ini_get('memory_limit'));\n\n        $included = get_included_files();\n        $this->log(\"Included files: \" . count($included));\n\n        foreach ($this->log as $val) {\n            if (is_array($val)) {\n                foreach ($val as $val1) {\n                    $log .= htmlentities($val1) . '<br/>';\n                }\n            } else {\n                $log .= htmlentities($val) . '<br/>';\n            }\n        }\n\n        echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n    }\n\n\n\n    /**\n     * Raise error, enables to implement a selection of error methods.\n     *\n     * @param string $message the error message to display.\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function raiseError($message)\n    {\n        throw new Exception($message);\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n$version = \"v0.7.0 (2015-02-10)\";\n\n\n\n/**\n * Default configuration options, can be overridden in own config-file.\n *\n * @param string $msg to display.\n *\n * @return void\n */\nfunction errorPage($msg)\n{\n    global $mode;\n\n    header(\"HTTP/1.0 500 Internal Server Error\");\n\n    if ($mode == 'development') {\n        die(\"[img.php] $msg\");\n    } else {\n        error_log(\"[img.php] $msg\");\n        die(\"HTTP/1.0 500 Internal Server Error\");\n    }\n}\n\n\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\"<p><b>img.php: Uncaught exception:</b> <p>\" . $exception->getMessage() . \"</p><pre>\" . $exception->getTraceAsString(), \"</pre>\");\n});\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null)\n{\n    global $verbose;\n    static $log = array();\n\n    if (!$verbose) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    $log[] = $msg;\n}\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} else if (!isset($config)) {\n    $config = array();\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\nverbose(\"img.php version = $version\");\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is nod loaded.\");\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\");\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} else if (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwdAlways) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n    if (!$passwordMatch) {\n        errorPage(\"Password required and does not match or exists.\");\n    }\n\n} elseif ($pwdConfig && $pwd) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer, PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n    } else if ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\");\n    } else if (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\");\n    } else if (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n    } else if (!empty($hotlinkingWhitelist)) {\n\n        $allowedByWhitelist = false;\n        foreach ($hotlinkingWhitelist as $val) {\n            if (preg_match($val, $refererHost)) {\n                $allowedByWhitelist = true;\n            }\n        }\n\n        if (!$allowedByWhitelist) {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist.\");\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\");\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Get the source files.\n */\n$autoloader  = getConfig('autoloader', false);\n$cimageClass = getConfig('cimage_class', false);\n\nif ($autoloader) {\n    require $autoloader;\n} else if ($cimageClass) {\n    require $cimageClass;\n}\n\n\n\n/**\n * Create the class for the image.\n */\n$img = new CImage();\n$img->setVerbose($verbose);\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $pattern);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = get('src')\n    or errorPage('Must set src-attribute.');\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\\.:]+$#');\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Filename contains invalid characters.');\n\nif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n\n} else if ($imagePathConstraint) {\n\n    // Check that the image is a file below the directory 'image_path'.\n    $pathToImage = realpath($imagePath . $srcImage);\n    $imageDir    = realpath($imagePath);\n\n    is_file($pathToImage)\n        or errorPage(\n            'Source image is not a valid file, check the filename and that a\n            matching file exists on the filesystem.'\n        );\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.'\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.');\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.');\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.');\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Hight out of range.');\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range');\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range');\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range');\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range');\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n * json - output the image as a JSON object with details on the image.\n */\n$outputFormat = getDefined('json', 'json', null);\n\nverbose(\"json = $outputFormat\");\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\");\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.');\n\n} else if ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.');\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio;\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Get the cachepath from config.\n */\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n\n\n\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fimgp.php.txt",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * This version is a all-in-one version of img.php, it is not dependant an any other file\n * so you can simply copy it to any place you want it. \n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n\n/**\n * Change configuration details in the array below or create a separate file\n * where you store the configuration details. \n *\n * The configuration file should be named the same name as this file and then \n * add '_config.php'. If this file is named 'img.php' then name the\n * config file should be named 'img_config.php'.\n *\n * The settings below are only a few of the available ones. Check the file in\n * webroot/img_config.php for a complete list of configuration options.\n */\n$config = array(\n\n    //'mode'         => 'production',               // 'production', 'development', 'strict'\n    //'image_path'   =>  __DIR__ . '/img/',\n    //'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n    //'remote_allow' => true,\n    //'password'     => false,                      // \"secret-password\",\n\n);\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CHttpGet\n{\n    private $request  = array();\n    private $response = array();\n\n\n\n    /**\n    * Constructor\n    *\n    */\n    public function __construct()\n    {\n        $this->request['header'] = array();\n    }\n\n\n\n    /**\n     * Set the url for the request.\n     *\n     * @param string $url\n     *\n     * @return $this\n     */\n    public function setUrl($url)\n    {\n        $this->request['url'] = $url;\n        return $this;\n    }\n\n\n\n    /**\n     * Set custom header field for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function setHeader($field, $value)\n    {\n        $this->request['header'][] = \"$field: $value\";\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function parseHeader()\n    {\n        $header = explode(\"\\r\\n\", rtrim($this->response['headerRaw'], \"\\r\\n\"));\n        $output = array();\n\n        if ('HTTP' === substr($header[0], 0, 4)) {\n            list($output['version'], $output['status']) = explode(' ', $header[0]);\n            unset($header[0]);\n        }\n\n        foreach ($header as $entry) {\n            $pos = strpos($entry, ':');\n            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));\n        }\n\n        $this->response['header'] = $output;\n        return $this;\n    }\n\n\n\n    /**\n     * Perform the request.\n     *\n     * @param boolean $debug set to true to dump headers.\n     *\n     * @return boolean\n     */\n    public function doGet($debug = false)\n    {\n        $options = array(\n            CURLOPT_URL             => $this->request['url'],\n            CURLOPT_HEADER          => 1,\n            CURLOPT_HTTPHEADER      => $this->request['header'],\n            CURLOPT_AUTOREFERER     => true,\n            CURLOPT_RETURNTRANSFER  => true,\n            CURLINFO_HEADER_OUT     => $debug,\n            CURLOPT_CONNECTTIMEOUT  => 5,\n            CURLOPT_TIMEOUT         => 5,\n        );\n\n        $ch = curl_init();\n        curl_setopt_array($ch, $options);\n        $response = curl_exec($ch);\n\n        if (!$response) {\n            return false;\n        }\n\n        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n        $this->response['headerRaw'] = substr($response, 0, $headerSize);\n        $this->response['body']      = substr($response, $headerSize);\n\n        $this->parseHeader();\n\n        if ($debug) {\n            $info = curl_getinfo($ch);\n            echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\";\n            echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\";\n            echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\";\n        }\n\n        curl_close($ch);\n        return true;\n    }\n\n\n\n    /**\n     * Get HTTP code of response.\n     *\n     * @return integer as HTTP status code or null if not available.\n     */\n    public function getStatus()\n    {\n        return isset($this->response['header']['status'])\n            ? (int) $this->response['header']['status']\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @return int as timestamp.\n     */\n    public function getLastModified()\n    {\n        return isset($this->response['header']['Last-Modified'])\n            ? strtotime($this->response['header']['Last-Modified'])\n            : null;\n    }\n\n\n\n    /**\n     * Get content type.\n     *\n     * @return string as the content type or null if not existing or invalid.\n     */\n    public function getContentType()\n    {\n        $type = isset($this->response['header']['Content-Type'])\n            ? $this->response['header']['Content-Type']\n            : null;\n\n        return preg_match('#[a-z]+/[a-z]+#', $type)\n            ? $type\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @param mixed $default as default value (int seconds) if date is\n     *                       missing in response header.\n     *\n     * @return int as timestamp or $default if Date is missing in\n     *             response header.\n     */\n    public function getDate($default = false)\n    {\n        return isset($this->response['header']['Date'])\n            ? strtotime($this->response['header']['Date'])\n            : $default;\n    }\n\n\n\n    /**\n     * Get max age of cachable item.\n     *\n     * @param mixed $default as default value if date is missing in response\n     *                       header.\n     *\n     * @return int as timestamp or false if not available.\n     */\n    public function getMaxAge($default = false)\n    {\n        $cacheControl = isset($this->response['header']['Cache-Control'])\n            ? $this->response['header']['Cache-Control']\n            : null;\n\n        $maxAge = null;\n        if ($cacheControl) {\n            // max-age=2592000\n            $part = explode('=', $cacheControl);\n            $maxAge = ($part[0] == \"max-age\")\n                ? (int) $part[1]\n                : null;\n        }\n\n        if ($maxAge) {\n            return $maxAge;\n        }\n\n        $expire = isset($this->response['header']['Expires'])\n            ? strtotime($this->response['header']['Expires'])\n            : null;\n\n        return $expire ? $expire : $default;\n    }\n\n\n\n    /**\n     * Get body of response.\n     *\n     * @return string as body.\n     */\n    public function getBody()\n    {\n        return $this->response['body'];\n    }\n}\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CRemoteImage\n{\n    /**\n     * Path to cache files.\n     */\n    private $saveFolder = null;\n\n\n\n    /**\n     * Use cache or not.\n     */\n    private $useCache = true;\n\n\n\n    /**\n     * HTTP object to aid in download file.\n     */\n    private $http;\n\n\n\n    /**\n     * Status of the HTTP request.\n     */\n    private $status;\n\n\n\n    /**\n     * Defalt age for cached items 60*60*24*7.\n     */\n    private $defaultMaxAge = 604800;\n\n\n\n    /**\n     * Url of downloaded item.\n     */\n    private $url;\n\n\n\n    /**\n     * Base name of cache file for downloaded item.\n     */\n    private $fileName;\n\n\n\n    /**\n     * Filename for json-file with details of cached item.\n     */\n    private $fileJson;\n\n\n\n    /**\n     * Filename for image-file.\n     */\n    private $fileImage;\n\n\n\n    /**\n     * Cache details loaded from file.\n     */\n    private $cache;\n\n\n\n    /**\n     * Constructor\n     *\n     */\n    public function __construct()\n    {\n        ;\n    }\n\n\n    /**\n     * Get status of last HTTP request.\n     *\n     * @return int as status\n     */\n    public function getStatus()\n    {\n        return $this->status;\n    }\n\n\n\n    /**\n     * Get JSON details for cache item.\n     *\n     * @return array with json details on cache.\n     */\n    public function getDetails()\n    {\n        return $this->cache;\n    }\n\n\n\n    /**\n     * Set the path to the cache directory.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function setCache($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if cache is writable or throw exception.\n     *\n     * @return $this\n     *\n     * @throws Exception if cahce folder is not writable.\n     */\n    public function isCacheWritable()\n    {\n        if (!is_writable($this->saveFolder)) {\n            throw new Exception(\"Cache folder is not writable for downloaded files.\");\n        }\n        return $this;\n    }\n\n\n\n    /**\n     * Decide if the cache should be used or not before trying to download\n     * a remote file.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Translate a content type to a file extension.\n     *\n     * @param string $type a valid content type.\n     *\n     * @return string as file extension or false if no match.\n     */\n    function contentTypeToFileExtension($type) {\n        $extension = array(\n            'image/jpeg' => 'jpg',\n            'image/png'  => 'png',\n            'image/gif'  => 'gif',\n        );\n\n        return isset($extension[$type])\n        ? $extension[$type]\n        : false;\n    }\n\n\n\n    /**\n     * Set header fields.\n     *\n     * @return $this\n     */\n    function setHeaderFields() {\n        $this->http->setHeader(\"User-Agent\", \"CImage/0.6 (PHP/\". phpversion() . \" cURL)\");\n        $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\");\n\n        if ($this->useCache) {\n            $this->http->setHeader(\"Cache-Control\", \"max-age=0\");\n        } else {\n            $this->http->setHeader(\"Cache-Control\", \"no-cache\");\n            $this->http->setHeader(\"Pragma\", \"no-cache\");\n        }\n    }\n\n\n\n    /**\n     * Save downloaded resource to cache.\n     *\n     * @return string as path to saved file or false if not saved.\n     */\n    function save() {\n\n        $this->cache = array();\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n        $type         = $this->http->getContentType();\n        $extension    = $this->contentTypeToFileExtension($type);\n\n        $this->cache['Date']           = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']        = $maxAge;\n        $this->cache['Content-Type']   = $type;\n        $this->cache['File-Extension'] = $extension;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        if ($extension) {\n\n            $this->fileImage = $this->fileName . \".\" . $extension;\n\n            // Save only if body is a valid image\n            $body = $this->http->getBody();\n            $img = imagecreatefromstring($body);\n\n            if ($img !== false) {\n                file_put_contents($this->fileImage, $body);\n                file_put_contents($this->fileJson, json_encode($this->cache));\n                return $this->fileImage;\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Got a 304 and updates cache with new age.\n     *\n     * @return string as path to cached file.\n     */\n    function updateCacheDetails() {\n\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n\n        $this->cache['Date']     = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']  = $maxAge;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        file_put_contents($this->fileJson, json_encode($this->cache));\n        return $this->fileImage;\n    }\n\n\n\n    /**\n     * Download a remote file and keep a cache of downloaded files.\n     *\n     * @param string $url a remote url.\n     *\n     * @return string as path to downloaded file or false if failed.\n     */\n    function download($url) {\n\n        $this->http = new CHttpGet();\n        $this->url = $url;\n\n        // First check if the cache is valid and can be used\n        $this->loadCacheDetails();\n\n        if ($this->useCache) {\n            $src = $this->getCachedSource();\n            if ($src) {\n                $this->status = 1;\n                return $src;\n            }\n        }\n\n        // Do a HTTP request to download item\n        $this->setHeaderFields();\n        $this->http->setUrl($this->url);\n        $this->http->doGet();\n\n        $this->status = $this->http->getStatus();\n        if ($this->status === 200) {\n            $this->isCacheWritable();\n            return $this->save();\n        } else if ($this->status === 304) {\n            $this->isCacheWritable();\n            return $this->updateCacheDetails();\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return $this\n     */\n    public function loadCacheDetails()\n    {\n        $cacheFile = str_replace(array(\"/\", \":\", \"#\", \".\", \"?\"), \"-\", $this->url);\n        $this->fileName = $this->saveFolder . $cacheFile;\n        $this->fileJson = $this->fileName . \".json\";\n        if (is_readable($this->fileJson)) {\n            $this->cache = json_decode(file_get_contents($this->fileJson), true);\n        }\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return string as the path ot the image file or false if no cache.\n     */\n    public function getCachedSource()\n    {\n        $this->fileImage = $this->fileName . \".\" . $this->cache['File-Extension'];\n        $imageExists = is_readable($this->fileImage);\n\n        // Is cache valid?\n        $date   = strtotime($this->cache['Date']);\n        $maxAge = $this->cache['Max-Age'];\n        $now = time();\n        if ($imageExists && $date + $maxAge > $now) {\n            return $this->fileImage;\n        }\n\n        // Prepare for a 304 if available\n        if ($imageExists && isset($this->cache['Last-Modified'])) {\n            $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']);\n        }\n\n        return false;\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n */\nclass CImage\n{\n\n    /**\n     * Constants type of PNG image\n     */\n    const PNG_GREYSCALE         = 0;\n    const PNG_RGB               = 2;\n    const PNG_RGB_PALETTE       = 3;\n    const PNG_GREYSCALE_ALPHA   = 4;\n    const PNG_RGB_ALPHA         = 6;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const JPEG_QUALITY_DEFAULT = 60;\n\n\n\n    /**\n     * Quality level for JPEG images.\n     */\n    private $quality;\n\n\n\n    /**\n     * Is the quality level set from external use (true) or is it default (false)?\n     */\n    private $useQuality = false;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const PNG_COMPRESSION_DEFAULT = -1;\n\n\n\n    /**\n     * Compression level for PNG images.\n     */\n    private $compress;\n\n\n\n    /**\n     * Is the compress level set from external use (true) or is it default (false)?\n     */\n    private $useCompress = false;\n\n\n\n\n    /**\n     * Default background color, red, green, blue, alpha.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    /*\n    const BACKGROUND_COLOR = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );*/\n\n\n\n    /**\n     * Default background color to use.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    //private $bgColorDefault = self::BACKGROUND_COLOR;\n    private $bgColorDefault = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );\n\n\n    /**\n     * Background color to use, specified as part of options.\n     */\n    private $bgColor;\n\n\n\n    /**\n     * Where to save the target file.\n     */\n    private $saveFolder;\n\n\n\n    /**\n     * The working image object.\n     */\n    private $image;\n\n\n\n    /**\n     * The root folder of images (only used in constructor to create $pathToImage?).\n     */\n    private $imageFolder;\n\n\n\n    /**\n     * Image filename, may include subdirectory, relative from $imageFolder\n     */\n    private $imageSrc;\n\n\n\n    /**\n     * Actual path to the image, $imageFolder . '/' . $imageSrc\n     */\n    private $pathToImage;\n\n\n\n    /**\n     * Original file extension\n     */\n    private $fileExtension;\n\n\n\n    /**\n     * File extension to use when saving image.\n     */\n    private $extension;\n\n\n\n    /**\n     * Output format, supports null (image) or json.\n     */\n    private $outputFormat = null;\n\n\n\n    /**\n     * Verbose mode to print out a trace and display the created image\n     */\n    private $verbose = false;\n\n\n\n    /**\n     * Keep a log/trace on what happens\n     */\n    private $log = array();\n\n\n\n    /**\n     * Handle image as palette image\n     */\n    private $palette;\n\n\n\n    /**\n     * Target filename, with path, to save resulting image in.\n     */\n    private $cacheFileName;\n\n\n\n    /**\n     * Set a format to save image as, or null to use original format.\n     */\n    private $saveAs;\n\n\n    /**\n     * Path to command for filter optimize, for example optipng or null.\n     */\n    private $pngFilter;\n\n\n\n    /**\n     * Path to command for deflate optimize, for example pngout or null.\n     */\n    private $pngDeflate;\n\n\n\n    /**\n     * Path to command to optimize jpeg images, for example jpegtran or null.\n     */\n    private $jpegOptimize;\n\n\n    /**\n     * Image dimensions, calculated from loaded image.\n     */\n    private $width;  // Calculated from source image\n    private $height; // Calculated from source image\n\n\n    /**\n     * New image dimensions, incoming as argument or calculated.\n     */\n    private $newWidth;\n    private $newWidthOrig;  // Save original value\n    private $newHeight;\n    private $newHeightOrig; // Save original value\n\n\n    /**\n     * Change target height & width when different dpr, dpr 2 means double image dimensions.\n     */\n    private $dpr = 1;\n\n\n    /**\n     * Always upscale images, even if they are smaller than target image.\n     */\n    const UPSCALE_DEFAULT = true;\n    private $upscale = self::UPSCALE_DEFAULT;\n\n\n\n    /**\n     * Array with details on how to crop, incoming as argument and calculated.\n     */\n    public $crop;\n    public $cropOrig; // Save original value\n\n\n    /**\n     * String with details on how to do image convolution. String\n     * should map a key in the $convolvs array or be a string of\n     * 11 float values separated by comma. The first nine builds\n     * up the matrix, then divisor and last offset.\n     */\n    private $convolve;\n\n\n    /**\n     * Custom convolution expressions, matrix 3x3, divisor and offset.\n     */\n    private $convolves = array(\n        'lighten'       => '0,0,0, 0,12,0, 0,0,0, 9, 0',\n        'darken'        => '0,0,0, 0,6,0, 0,0,0, 9, 0',\n        'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n        'emboss'        => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0',\n        'emboss-alt'    => '-2,-1,0, -1,1,1, 0,1,2, 1, 0',\n        'blur'          => '1,1,1, 1,15,1, 1,1,1, 23, 0',\n        'gblur'         => '1,2,1, 2,4,2, 1,2,1, 16, 0',\n        'edge'          => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0',\n        'edge-alt'      => '0,1,0, 1,-4,1, 0,1,0, 1, 0',\n        'draw'          => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0',\n        'mean'          => '1,1,1, 1,1,1, 1,1,1, 9, 0',\n        'motion'        => '1,0,0, 0,1,0, 0,0,1, 3, 0',\n    );\n\n\n    /**\n     * Resize strategy to fill extra area with background color.\n     * True or false.\n     */\n    private $fillToFit;\n\n\n    /**\n     * Used with option area to set which parts of the image to use.\n     */\n    private $offset;\n\n\n\n    /**\n    * Calculate target dimension for image when using fill-to-fit resize strategy.\n    */\n    private $fillWidth;\n    private $fillHeight;\n\n\n\n    /**\n    * Allow remote file download, default is to disallow remote file download.\n    */\n    private $allowRemote = false;\n\n\n\n    /**\n     * Pattern to recognize a remote file.\n     */\n    //private $remotePattern = '#^[http|https]://#';\n    private $remotePattern = '#^https?://#';\n\n\n\n    /**\n     * Use the cache if true, set to false to ignore the cached file.\n     */\n    private $useCache = true;\n\n\n    /**\n     * Properties, the class is mutable and the method setOptions()\n     * decides (partly) what properties are created.\n     *\n     * @todo Clean up these and check if and how they are used\n     */\n\n    public $keepRatio;\n    public $cropToFit;\n    private $cropWidth;\n    private $cropHeight;\n    public $crop_x;\n    public $crop_y;\n    public $filters;\n    private $type; // Calculated from source image\n    private $attr; // Calculated from source image\n    private $useOriginal; // Use original image if possible\n\n\n\n\n    /**\n     * Constructor, can take arguments to init the object.\n     *\n     * @param string $imageSrc    filename which may contain subdirectory.\n     * @param string $imageFolder path to root folder for images.\n     * @param string $saveFolder  path to folder where to save the new file or null to skip saving.\n     * @param string $saveName    name of target file when saveing.\n     */\n    public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null)\n    {\n        $this->setSource($imageSrc, $imageFolder);\n        $this->setTarget($saveFolder, $saveName);\n    }\n\n\n\n    /**\n     * Set verbose mode.\n     *\n     * @param boolean $mode true or false to enable and disable verbose mode,\n     *                      default is true.\n     *\n     * @return $this\n     */\n    public function setVerbose($mode = true)\n    {\n        $this->verbose = $mode;\n        return $this;\n    }\n\n\n\n    /**\n     * Set save folder, base folder for saving cache files.\n     *\n     * @todo clean up how $this->saveFolder is used in other methods.\n     *\n     * @param string $path where to store cached files.\n     *\n     * @return $this\n     */\n    public function setSaveFolder($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Use cache or not.\n     *\n     * @todo clean up how $this->noCache is used in other methods.\n     *\n     * @param string $use true or false to use cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Allow or disallow remote image download.\n     *\n     * @param boolean $allow   true or false to enable and disable.\n     * @param string  $pattern to use to detect if its a remote file.\n     *\n     * @return $this\n     */\n    public function setRemoteDownload($allow, $pattern = null)\n    {\n        $this->allowRemote = $allow;\n        $this->remotePattern = $pattern ? $pattern : $this->remotePattern;\n\n        $this->log(\"Set remote download to: \"\n            . ($this->allowRemote ? \"true\" : \"false\")\n            . \" using pattern \"\n            . $this->remotePattern);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the image resource is a remote file or not.\n     *\n     * @param string $src check if src is remote.\n     *\n     * @return boolean true if $src is a remote file, else false.\n     */\n    public function isRemoteSource($src)\n    {\n        $remote = preg_match($this->remotePattern, $src);\n        $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\"));\n        return $remote;\n    }\n\n\n\n    /**\n     * Check if file extension is valid as a file extension.\n     *\n     * @param string $extension of image file.\n     *\n     * @return $this\n     */\n    private function checkFileExtension($extension)\n    {\n        $valid = array('jpg', 'jpeg', 'png', 'gif');\n\n        in_array(strtolower($extension), $valid)\n            or $this->raiseError('Not a valid file extension.');\n\n        return $this;\n    }\n\n\n\n    /**\n     * Download a remote image and return path to its local copy.\n     *\n     * @param string $src remote path to image.\n     *\n     * @return string as path to downloaded remote source.\n     */\n    public function downloadRemoteSource($src)\n    {\n        $remote = new CRemoteImage();\n        $cache  = $this->saveFolder . \"/remote/\";\n\n        if (!is_dir($cache)) {\n            if (!is_writable($this->saveFolder)) {\n                throw new Exception(\"Can not create remote cache, cachefolder not writable.\");\n            }\n            mkdir($cache);\n            $this->log(\"The remote cache does not exists, creating it.\");\n        }\n\n        if (!is_writable($cache)) {\n            $this->log(\"The remote cache is not writable.\");\n        }\n\n        $remote->setCache($cache);\n        $remote->useCache($this->useCache);\n        $src = $remote->download($src);\n\n        $this->log(\"Remote HTTP status: \" . $remote->getStatus());\n        $this->log(\"Remote item has local cached file: $src\");\n        $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true));\n\n        return $src;\n    }\n\n\n\n    /**\n     * Set src file.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     */\n    public function setSource($src, $dir = null)\n    {\n        if (!isset($src)) {\n            return $this;\n        }\n\n        if ($this->allowRemote && $this->isRemoteSource($src)) {\n            $src = $this->downloadRemoteSource($src);\n            $dir = null;\n        }\n\n        if (!isset($dir)) {\n            $dir = dirname($src);\n            $src = basename($src);\n        }\n\n        $this->imageSrc       = ltrim($src, '/');\n        $this->imageFolder    = rtrim($dir, '/');\n        $this->pathToImage    = $this->imageFolder . '/' . $this->imageSrc;\n        $this->fileExtension  = strtolower(pathinfo($this->pathToImage, PATHINFO_EXTENSION));\n        //$this->extension      = $this->fileExtension;\n\n        $this->checkFileExtension($this->fileExtension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set target file.\n     *\n     * @param string $src of target image.\n     * @param string $dir as base directory where images are stored.\n     *\n     * @return $this\n     */\n    public function setTarget($src = null, $dir = null)\n    {\n        if (!(isset($src) && isset($dir))) {\n            return $this;\n        }\n\n        $this->saveFolder     = $dir;\n        $this->cacheFileName  = $dir . '/' . $src;\n\n        /* Allow readonly cache\n        is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n        */\n\n        // Sanitize filename\n        $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName);\n        $this->log(\"The cache file name is: \" . $this->cacheFileName);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set options to use when processing image.\n     *\n     * @param array $args used when processing image.\n     *\n     * @return $this\n     */\n    public function setOptions($args)\n    {\n        $this->log(\"Set new options for processing image.\");\n\n        $defaults = array(\n            // Options for calculate dimensions\n            'newWidth'    => null,\n            'newHeight'   => null,\n            'aspectRatio' => null,\n            'keepRatio'   => true,\n            'cropToFit'   => false,\n            'fillToFit'   => null,\n            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),\n            'area'        => null, //'0,0,0,0',\n            'upscale'     => self::UPSCALE_DEFAULT,\n\n            // Options for caching or using original\n            'useCache'    => true,\n            'useOriginal' => true,\n\n            // Pre-processing, before resizing is done\n            'scale'        => null,\n            'rotateBefore' => null,\n            'autoRotate'  => false,\n\n            // General options\n            'bgColor'     => null,\n\n            // Post-processing, after resizing is done\n            'palette'     => null,\n            'filters'     => null,\n            'sharpen'     => null,\n            'emboss'      => null,\n            'blur'        => null,\n            'convolve'       => null,\n            'rotateAfter' => null,\n\n            // Output format\n            'outputFormat' => null,\n            'dpr'          => 1,\n\n            // Options for saving\n            //'quality'     => null,\n            //'compress'    => null,\n            //'saveAs'      => null,\n        );\n\n        // Convert crop settings from string to array\n        if (isset($args['crop']) && !is_array($args['crop'])) {\n            $pices = explode(',', $args['crop']);\n            $args['crop'] = array(\n                'width'   => $pices[0],\n                'height'  => $pices[1],\n                'start_x' => $pices[2],\n                'start_y' => $pices[3],\n            );\n        }\n\n        // Convert area settings from string to array\n        if (isset($args['area']) && !is_array($args['area'])) {\n                $pices = explode(',', $args['area']);\n                $args['area'] = array(\n                    'top'    => $pices[0],\n                    'right'  => $pices[1],\n                    'bottom' => $pices[2],\n                    'left'   => $pices[3],\n                );\n        }\n\n        // Convert filter settings from array of string to array of array\n        if (isset($args['filters']) && is_array($args['filters'])) {\n            foreach ($args['filters'] as $key => $filterStr) {\n                $parts = explode(',', $filterStr);\n                $filter = $this->mapFilter($parts[0]);\n                $filter['str'] = $filterStr;\n                for ($i=1; $i<=$filter['argc']; $i++) {\n                    if (isset($parts[$i])) {\n                        $filter[\"arg{$i}\"] = $parts[$i];\n                    } else {\n                        throw new Exception(\n                            'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php'\n                        );\n                    }\n                }\n                $args['filters'][$key] = $filter;\n            }\n        }\n\n        // Merge default arguments with incoming and set properties.\n        //$args = array_merge_recursive($defaults, $args);\n        $args = array_merge($defaults, $args);\n        foreach ($defaults as $key => $val) {\n            $this->{$key} = $args[$key];\n        }\n\n        if ($this->bgColor) {\n            $this->setDefaultBackgroundColor($this->bgColor);\n        }\n\n        // Save original values to enable re-calculating\n        $this->newWidthOrig  = $this->newWidth;\n        $this->newHeightOrig = $this->newHeight;\n        $this->cropOrig      = $this->crop;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Map filter name to PHP filter and id.\n     *\n     * @param string $name the name of the filter.\n     *\n     * @return array with filter settings\n     * @throws Exception\n     */\n    private function mapFilter($name)\n    {\n        $map = array(\n            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),\n            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),\n            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),\n            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),\n            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),\n            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),\n            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),\n            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),\n            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),\n            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),\n            'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),\n            'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),\n        );\n\n        if (isset($map[$name])) {\n            return $map[$name];\n        } else {\n            throw new Exception('No such filter.');\n        }\n    }\n\n\n\n    /**\n     * Load image details from original image file.\n     *\n     * @param string $file the file to load or null to use $this->pathToImage.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function loadImageDetails($file = null)\n    {\n        $file = $file ? $file : $this->pathToImage;\n\n        is_readable($file)\n            or $this->raiseError('Image file does not exist.');\n\n        // Get details on image\n        $info = list($this->width, $this->height, $this->type, $this->attr) = getimagesize($file);\n        !empty($info) or $this->raiseError(\"The file doesn't seem to be an image.\");\n\n        if ($this->verbose) {\n            $this->log(\"Image file: {$file}\");\n            $this->log(\"Image width x height (type): {$this->width} x {$this->height} ({$this->type}).\");\n            $this->log(\"Image filesize: \" . filesize($file) . \" bytes.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Init new width and height and do some sanity checks on constraints, before any\n     * processing can be done.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function initDimensions()\n    {\n        $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // width as %\n        if ($this->newWidth[strlen($this->newWidth)-1] == '%') {\n            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;\n            $this->log(\"Setting new width based on % to {$this->newWidth}\");\n        }\n\n        // height as %\n        if ($this->newHeight[strlen($this->newHeight)-1] == '%') {\n            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;\n            $this->log(\"Setting new height based on % to {$this->newHeight}\");\n        }\n\n        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');\n\n        // width & height from aspect ratio\n        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {\n            if ($this->aspectRatio >= 1) {\n                $this->newWidth   = $this->width;\n                $this->newHeight  = $this->width / $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n\n            } else {\n                $this->newHeight  = $this->height;\n                $this->newWidth   = $this->height * $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n            }\n\n        } elseif ($this->aspectRatio && is_null($this->newWidth)) {\n            $this->newWidth   = $this->newHeight * $this->aspectRatio;\n            $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\");\n\n        } elseif ($this->aspectRatio && is_null($this->newHeight)) {\n            $this->newHeight  = $this->newWidth / $this->aspectRatio;\n            $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\");\n        }\n\n        // Change width & height based on dpr\n        if ($this->dpr != 1) {\n            if (!is_null($this->newWidth)) {\n                $this->newWidth  = round($this->newWidth * $this->dpr);\n                $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\");\n            }\n            if (!is_null($this->newHeight)) {\n                $this->newHeight = round($this->newHeight * $this->dpr);\n                $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\");\n            }\n        }\n\n        // Check values to be within domain\n        is_null($this->newWidth)\n            or is_numeric($this->newWidth)\n            or $this->raiseError('Width not numeric');\n\n        is_null($this->newHeight)\n            or is_numeric($this->newHeight)\n            or $this->raiseError('Height not numeric');\n\n        $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Calculate new width and height of image, based on settings.\n     *\n     * @return $this\n     */\n    public function calculateNewWidthAndHeight()\n    {\n        // Crop, use cropped width and height as base for calulations\n        $this->log(\"Calculate new width and height.\");\n        $this->log(\"Original width x height is {$this->width} x {$this->height}.\");\n        $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // Check if there is an area to crop off\n        if (isset($this->area)) {\n            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);\n            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);\n            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);\n            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);\n            $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];\n            $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];\n            $this->width  = $this->offset['width'];\n            $this->height = $this->offset['height'];\n            $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\");\n            $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\");\n        }\n\n        $width  = $this->width;\n        $height = $this->height;\n\n        // Check if crop is set\n        if ($this->crop) {\n            $width  = $this->crop['width']  = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];\n            $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];\n\n            if ($this->crop['start_x'] == 'left') {\n                $this->crop['start_x'] = 0;\n            } elseif ($this->crop['start_x'] == 'right') {\n                $this->crop['start_x'] = $this->width - $width;\n            } elseif ($this->crop['start_x'] == 'center') {\n                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);\n            }\n\n            if ($this->crop['start_y'] == 'top') {\n                $this->crop['start_y'] = 0;\n            } elseif ($this->crop['start_y'] == 'bottom') {\n                $this->crop['start_y'] = $this->height - $height;\n            } elseif ($this->crop['start_y'] == 'center') {\n                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);\n            }\n\n            $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\");\n        }\n\n        // Calculate new width and height if keeping aspect-ratio.\n        if ($this->keepRatio) {\n\n            $this->log(\"Keep aspect ratio.\");\n\n            // Crop-to-fit and both new width and height are set.\n            if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Use newWidth and newHeigh as width/height, image should fit in box.\n                $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\");\n\n            } elseif (isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Both new width and height are set.\n                // Use newWidth and newHeigh as max width/height, image should not be larger.\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n                $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;\n                $this->newWidth  = round($width  / $ratio);\n                $this->newHeight = round($height / $ratio);\n                $this->log(\"New width and height was set.\");\n\n            } elseif (isset($this->newWidth)) {\n\n                // Use new width as max-width\n                $factor = (float)$this->newWidth / (float)$width;\n                $this->newHeight = round($factor * $height);\n                $this->log(\"New width was set.\");\n\n            } elseif (isset($this->newHeight)) {\n\n                // Use new height as max-hight\n                $factor = (float)$this->newHeight / (float)$height;\n                $this->newWidth = round($factor * $width);\n                $this->log(\"New height was set.\");\n\n            }\n\n            // Get image dimensions for pre-resize image.\n            if ($this->cropToFit || $this->fillToFit) {\n\n                // Get relations of original & target image\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n\n                if ($this->cropToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Crop to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;\n                    $this->cropWidth  = round($width  / $ratio);\n                    $this->cropHeight = round($height / $ratio);\n                    $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\");\n\n                } else if ($this->fillToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Fill to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;\n                    $this->fillWidth  = round($width  / $ratio);\n                    $this->fillHeight = round($height / $ratio);\n                    $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\");\n                }\n            }\n        }\n\n        // Crop, ensure to set new width and height\n        if ($this->crop) {\n            $this->log(\"Crop.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }\n\n        // Fill to fit, ensure to set new width and height\n        /*if ($this->fillToFit) {\n            $this->log(\"FillToFit.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }*/\n\n        // No new height or width is set, use existing measures.\n        $this->newWidth  = round(isset($this->newWidth) ? $this->newWidth : $this->width);\n        $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height);\n        $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Re-calculate image dimensions when original image dimension has changed.\n     *\n     * @return $this\n     */\n    public function reCalculateDimensions()\n    {\n        $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight);\n\n        $this->newWidth  = $this->newWidthOrig;\n        $this->newHeight = $this->newHeightOrig;\n        $this->crop      = $this->cropOrig;\n\n        $this->initDimensions()\n             ->calculateNewWidthAndHeight();\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set extension for filename to save as.\n     *\n     * @param string $saveas extension to save image as\n     *\n     * @return $this\n     */\n    public function setSaveAsExtension($saveAs = null)\n    {\n        if (isset($saveAs)) {\n            $saveAs = strtolower($saveAs);\n            $this->checkFileExtension($saveAs);\n            $this->saveAs = $saveAs;\n            $this->extension = $saveAs;\n        }\n\n        $this->log(\"Prepare to save image using as: \" . $this->extension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set JPEG quality to use when saving image\n     *\n     * @param int $quality as the quality to set.\n     *\n     * @return $this\n     */\n    public function setJpegQuality($quality = null)\n    {\n        if ($quality) {\n            $this->useQuality = true;\n        }\n\n        $this->quality = isset($quality)\n            ? $quality\n            : self::JPEG_QUALITY_DEFAULT;\n\n        (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting JPEG quality to {$this->quality}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set PNG compressen algorithm to use when saving image\n     *\n     * @param int $compress as the algorithm to use.\n     *\n     * @return $this\n     */\n    public function setPngCompression($compress = null)\n    {\n        if ($compress) {\n            $this->useCompress = true;\n        }\n\n        $this->compress = isset($compress)\n            ? $compress\n            : self::PNG_COMPRESSION_DEFAULT;\n\n        (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting PNG compression level to {$this->compress}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Use original image if possible, check options which affects image processing.\n     *\n     * @param boolean $useOrig default is to use original if possible, else set to false.\n     *\n     * @return $this\n     */\n    public function useOriginalIfPossible($useOrig = true)\n    {\n        if ($useOrig\n            && ($this->newWidth == $this->width)\n            && ($this->newHeight == $this->height)\n            && !$this->area\n            && !$this->crop\n            && !$this->cropToFit\n            && !$this->fillToFit\n            && !$this->filters\n            && !$this->sharpen\n            && !$this->emboss\n            && !$this->blur\n            && !$this->convolve\n            && !$this->palette\n            && !$this->useQuality\n            && !$this->useCompress\n            && !$this->saveAs\n            && !$this->rotateBefore\n            && !$this->rotateAfter\n            && !$this->autoRotate\n            && !$this->bgColor\n            && ($this->upscale === self::UPSCALE_DEFAULT)\n        ) {\n            $this->log(\"Using original image.\");\n            $this->output($this->pathToImage);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Generate filename to save file in cache.\n     *\n     * @param string $base as basepath for storing file.\n     *\n     * @return $this\n     */\n    public function generateFilename($base)\n    {\n        $parts        = pathinfo($this->pathToImage);\n        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;\n        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;\n        $crop_x       = $this->crop_x       ? \"_x{$this->crop_x}\"        : null;\n        $crop_y       = $this->crop_y       ? \"_y{$this->crop_y}\"        : null;\n        $scale        = $this->scale        ? \"_s{$this->scale}\"         : null;\n        $bgColor      = $this->bgColor      ? \"_bgc{$this->bgColor}\"     : null;\n        $quality      = $this->quality      ? \"_q{$this->quality}\"       : null;\n        $compress     = $this->compress     ? \"_co{$this->compress}\"     : null;\n        $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null;\n        $rotateAfter  = $this->rotateAfter  ? \"_ra{$this->rotateAfter}\"  : null;\n\n        $width  = $this->newWidth;\n        $height = $this->newHeight;\n\n        $offset = isset($this->offset)\n            ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left']\n            : null;\n\n        $crop = $this->crop\n            ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y']\n            : null;\n\n        $filters = null;\n        if (isset($this->filters)) {\n            foreach ($this->filters as $filter) {\n                if (is_array($filter)) {\n                    $filters .= \"_f{$filter['id']}\";\n                    for ($i=1; $i<=$filter['argc']; $i++) {\n                        $filters .= \":\".$filter[\"arg{$i}\"];\n                    }\n                }\n            }\n        }\n\n        $sharpen = $this->sharpen ? 's' : null;\n        $emboss  = $this->emboss  ? 'e' : null;\n        $blur    = $this->blur    ? 'b' : null;\n        $palette = $this->palette ? 'p' : null;\n\n        $autoRotate = $this->autoRotate ? 'ar' : null;\n\n        $this->extension = isset($this->extension)\n            ? $this->extension\n            : $parts['extension'];\n\n        $optimize = null;\n        if ($this->extension == 'jpeg' || $this->extension == 'jpg') {\n            $optimize = $this->jpegOptimize ? 'o' : null;\n        } elseif ($this->extension == 'png') {\n            $optimize .= $this->pngFilter  ? 'f' : null;\n            $optimize .= $this->pngDeflate ? 'd' : null;\n        }\n\n        $convolve = null;\n        if ($this->convolve) {\n            $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve);\n        }\n\n        $upscale = null;\n        if ($this->upscale !== self::UPSCALE_DEFAULT) {\n            $upscale = '_nu';\n        }\n\n        $subdir = str_replace('/', '-', dirname($this->imageSrc));\n        $subdir = ($subdir == '.') ? '_.' : $subdir;\n        $file = $subdir . '_' . $parts['filename'] . '_' . $width . '_'\n            . $height . $offset . $crop . $cropToFit . $fillToFit\n            . $crop_x . $crop_y . $upscale\n            . $quality . $filters . $sharpen . $emboss . $blur . $palette . $optimize\n            . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor . $convolve\n            . '.' . $this->extension;\n\n        return $this->setTarget($file, $base);\n    }\n\n\n\n    /**\n     * Use cached version of image, if possible.\n     *\n     * @param boolean $useCache is default true, set to false to avoid using cached object.\n     *\n     * @return $this\n     */\n    public function useCacheIfPossible($useCache = true)\n    {\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime   = filemtime($this->pathToImage);\n            $cacheTime  = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                if ($this->useCache) {\n                    if ($this->verbose) {\n                        $this->log(\"Use cached file.\");\n                        $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $this->output($this->cacheFileName, $this->outputFormat);\n                } else {\n                    $this->log(\"Cache is valid but ignoring it by intention.\");\n                }\n            } else {\n                $this->log(\"Original file is modified, ignoring cache.\");\n            }\n        } else {\n            $this->log(\"Cachefile does not exists or ignoring it.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Error message when failing to load somehow corrupt image.\n     *\n     * @return void\n     *\n     */\n    public function failedToLoad()\n    {\n        header(\"HTTP/1.0 404 Not Found\");\n        echo(\"CImage.php says 404: Fatal error when opening image.<br>\");\n\n        switch ($this->fileExtension) {\n            case 'jpg':\n            case 'jpeg':\n                $this->image = imagecreatefromjpeg($this->pathToImage);\n                break;\n\n            case 'gif':\n                $this->image = imagecreatefromgif($this->pathToImage);\n                break;\n\n            case 'png':\n                $this->image = imagecreatefrompng($this->pathToImage);\n                break;\n        }\n\n        exit();\n    }\n\n\n\n    /**\n     * Load image from disk.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     *\n     */\n    public function load($src = null, $dir = null)\n    {\n        if (isset($src)) {\n            $this->setSource($src, $dir);\n        }\n\n        $this->log(\"Opening file as {$this->fileExtension}.\");\n\n        switch ($this->fileExtension) {\n            case 'jpg':\n            case 'jpeg':\n                $this->image = @imagecreatefromjpeg($this->pathToImage);\n                $this->image or $this->failedToLoad();\n                break;\n\n            case 'gif':\n                $this->image = @imagecreatefromgif($this->pathToImage);\n                $this->image or $this->failedToLoad();\n                break;\n\n            case 'png':\n                $this->image = @imagecreatefrompng($this->pathToImage);\n                $this->image or $this->failedToLoad();\n\n                $type = $this->getPngType();\n                $hasFewColors = imagecolorstotal($this->image);\n\n                if ($type == self::PNG_RGB_PALETTE || ($hasFewColors > 0 && $hasFewColors <= 256)) {\n                    if ($this->verbose) {\n                        $this->log(\"Handle this image as a palette image.\");\n                    }\n                    $this->palette = true;\n                }\n                break;\n\n            default:\n                $this->image = false;\n                throw new Exception('No support for this file extension.');\n        }\n\n        if ($this->verbose) {\n            $this->log(\"imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\"imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\"Number of colors in image = \" . $this->colorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\"Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the type of PNG image.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    private function getPngType()\n    {\n        $pngType = ord(file_get_contents($this->pathToImage, false, null, 25, 1));\n\n        switch ($pngType) {\n\n            case self::PNG_GREYSCALE:\n                $this->log(\"PNG is type 0, Greyscale.\");\n                break;\n\n            case self::PNG_RGB:\n                $this->log(\"PNG is type 2, RGB\");\n                break;\n\n            case self::PNG_RGB_PALETTE:\n                $this->log(\"PNG is type 3, RGB with palette\");\n                break;\n\n            case self::PNG_GREYSCALE_ALPHA:\n                $this->Log(\"PNG is type 4, Greyscale with alpha channel\");\n                break;\n\n            case self::PNG_RGB_ALPHA:\n                $this->Log(\"PNG is type 6, RGB with alpha channel (PNG 32-bit)\");\n                break;\n\n            default:\n                $this->Log(\"PNG is UNKNOWN type, is it really a PNG image?\");\n        }\n\n        return $pngType;\n    }\n\n\n\n    /**\n     * Calculate number of colors in an image.\n     *\n     * @param resource $im the image.\n     *\n     * @return int\n     */\n    private function colorsTotal($im)\n    {\n        if (imageistruecolor($im)) {\n            $this->log(\"Colors as true color.\");\n            $h = imagesy($im);\n            $w = imagesx($im);\n            $c = array();\n            for ($x=0; $x < $w; $x++) {\n                for ($y=0; $y < $h; $y++) {\n                    @$c['c'.imagecolorat($im, $x, $y)]++;\n                }\n            }\n            return count($c);\n        } else {\n            $this->log(\"Colors as palette.\");\n            return imagecolorstotal($im);\n        }\n    }\n\n\n\n    /**\n     * Preprocess image before rezising it.\n     *\n     * @return $this\n     */\n    public function preResize()\n    {\n        $this->log(\"Pre-process before resizing\");\n\n        // Rotate image\n        if ($this->rotateBefore) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateBefore, $this->bgColor)\n                 ->reCalculateDimensions();\n        }\n\n        // Auto-rotate image\n        if ($this->autoRotate) {\n            $this->log(\"Auto rotating image.\");\n            $this->rotateExif()\n                 ->reCalculateDimensions();\n        }\n\n        // Scale the original image before starting\n        if (isset($this->scale)) {\n            $this->log(\"Scale by {$this->scale}%\");\n            $newWidth  = $this->width * $this->scale / 100;\n            $newHeight = $this->height * $this->scale / 100;\n            $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);\n            imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);\n            $this->image = $img;\n            $this->width = $newWidth;\n            $this->height = $newHeight;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return $this\n     */\n    public function resize()\n    {\n\n        $this->log(\"Starting to Resize()\");\n        $this->log(\"Upscale = '$this->upscale'\");\n\n        // Only use a specified area of the image, $this->offset is defining the area to use\n        if (isset($this->offset)) {\n\n            $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\");\n            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);\n            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);\n            $this->image = $img;\n            $this->width = $this->offset['width'];\n            $this->height = $this->offset['height'];\n        }\n\n        if ($this->crop) {\n\n            // Do as crop, take only part of image\n            $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\");\n            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);\n            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);\n            $this->image = $img;\n            $this->width = $this->crop['width'];\n            $this->height = $this->crop['height'];\n        }\n\n        if (!$this->upscale) {\n            // Consider rewriting the no-upscale code to fit within this if-statement,\n            // likely to be more readable code.\n            // The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch\n        }\n\n        if ($this->cropToFit) {\n\n            // Resize by crop to fit\n            $this->log(\"Resizing using strategy - Crop to fit\");\n\n            if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight)) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n\n                $posX = 0;\n                $posY = 0;\n\n                if ($this->newWidth > $this->width) {\n                    $posX = round(($this->newWidth - $this->width) / 2);\n                }\n\n                if ($this->newHeight > $this->height) {\n                    $posY = round(($this->newHeight - $this->height) / 2);\n                }\n\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            } else {\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n                $imgPreCrop   = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } else if ($this->fillToFit) {\n\n            // Resize by fill to fit\n            $this->log(\"Resizing using strategy - Fill to fit\");\n\n            $posX = 0;\n            $posY = 0;\n\n            $ratioOrig = $this->width / $this->height;\n            $ratioNew  = $this->newWidth / $this->newHeight;\n\n            // Check ratio for landscape or portrait\n            if ($ratioOrig < $ratioNew) {\n                $posX = round(($this->newWidth - $this->fillWidth) / 2);\n            } else {\n                $posY = round(($this->newHeight - $this->fillHeight) / 2);\n            }\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n                $posX = round(($this->fillWidth - $this->width) / 2);\n                $posY = round(($this->fillHeight - $this->height) / 2);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n\n            } else {\n                $imgPreFill   = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {\n\n            // Resize it\n            $this->log(\"Resizing, new height and/or width\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                if (!$this->keepRatio) {\n                    $this->log(\"Resizing - stretch to fit selected.\");\n\n                    $posX = 0;\n                    $posY = 0;\n                    $cropX = 0;\n                    $cropY = 0;\n\n                    if ($this->newWidth > $this->width && $this->newHeight > $this->height) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                    } else if ($this->newWidth > $this->width) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $cropY = round(($this->height - $this->newHeight) / 2);\n                    } else if ($this->newHeight > $this->height) {\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                        $cropX = round(($this->width - $this->newWidth) / 2);\n                    }\n\n                    //$this->log(\"posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY.\");\n                    $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                    imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n                    $this->image = $imageResized;\n                    $this->width = $this->newWidth;\n                    $this->height = $this->newHeight;\n                }\n            } else {\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);\n                $this->image = $imageResized;\n                $this->width = $this->newWidth;\n                $this->height = $this->newHeight;\n            }\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Postprocess image after rezising image.\n     *\n     * @return $this\n     */\n    public function postResize()\n    {\n        $this->log(\"Post-process after resizing\");\n\n        // Rotate image\n        if ($this->rotateAfter) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateAfter, $this->bgColor);\n        }\n\n        // Apply filters\n        if (isset($this->filters) && is_array($this->filters)) {\n\n            foreach ($this->filters as $filter) {\n                $this->log(\"Applying filter {$filter['type']}.\");\n\n                switch ($filter['argc']) {\n\n                    case 0:\n                        imagefilter($this->image, $filter['type']);\n                        break;\n\n                    case 1:\n                        imagefilter($this->image, $filter['type'], $filter['arg1']);\n                        break;\n\n                    case 2:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']);\n                        break;\n\n                    case 3:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']);\n                        break;\n\n                    case 4:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']);\n                        break;\n                }\n            }\n        }\n\n        // Convert to palette image\n        if ($this->palette) {\n            $this->log(\"Converting to palette image.\");\n            $this->trueColorToPalette();\n        }\n\n        // Blur the image\n        if ($this->blur) {\n            $this->log(\"Blur.\");\n            $this->blurImage();\n        }\n\n        // Emboss the image\n        if ($this->emboss) {\n            $this->log(\"Emboss.\");\n            $this->embossImage();\n        }\n\n        // Sharpen the image\n        if ($this->sharpen) {\n            $this->log(\"Sharpen.\");\n            $this->sharpenImage();\n        }\n\n        // Custom convolution\n        if ($this->convolve) {\n            //$this->log(\"Convolve: \" . $this->convolve);\n            $this->imageConvolution();\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using angle.\n     *\n     * @param float $angle        to rotate image.\n     * @param int   $anglebgColor to fill image with if needed.\n     *\n     * @return $this\n     */\n    public function rotate($angle, $bgColor)\n    {\n        $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\");\n\n        $color = $this->getBackgroundColor();\n        $this->image = imagerotate($this->image, $angle, $color);\n\n        $this->width  = imagesx($this->image);\n        $this->height = imagesy($this->image);\n\n        $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using information in EXIF.\n     *\n     * @return $this\n     */\n    public function rotateExif()\n    {\n        if (!in_array($this->fileExtension, array('jpg', 'jpeg'))) {\n            $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\");\n            return $this;\n        }\n\n        $exif = exif_read_data($this->pathToImage);\n\n        if (!empty($exif['Orientation'])) {\n            switch ($exif['Orientation']) {\n                case 3:\n                    $this->log(\"Autorotate 180.\");\n                    $this->rotate(180, $this->bgColor);\n                    break;\n\n                case 6:\n                    $this->log(\"Autorotate -90.\");\n                    $this->rotate(-90, $this->bgColor);\n                    break;\n\n                case 8:\n                    $this->log(\"Autorotate 90.\");\n                    $this->rotate(90, $this->bgColor);\n                    break;\n\n                default:\n                    $this->log(\"Autorotate ignored, unknown value as orientation.\");\n            }\n        } else {\n            $this->log(\"Autorotate ignored, no orientation in EXIF.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert true color image to palette image, keeping alpha.\n     * http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\n     *\n     * @return void\n     */\n    public function trueColorToPalette()\n    {\n        $img = imagecreatetruecolor($this->width, $this->height);\n        $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);\n        imagecolortransparent($img, $bga);\n        imagefill($img, 0, 0, $bga);\n        imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);\n        imagetruecolortopalette($img, false, 255);\n        imagesavealpha($img, true);\n\n        if (imageistruecolor($this->image)) {\n            $this->log(\"Matching colors with true color image.\");\n            imagecolormatch($this->image, $img);\n        }\n\n        $this->image = $img;\n    }\n\n\n\n    /**\n     * Sharpen image using image convolution.\n     *\n     * @return $this\n     */\n    public function sharpenImage()\n    {\n        $this->imageConvolution('sharpen');\n        return $this;\n    }\n\n\n\n    /**\n     * Emboss image using image convolution.\n     *\n     * @return $this\n     */\n    public function embossImage()\n    {\n        $this->imageConvolution('emboss');\n        return $this;\n    }\n\n\n\n    /**\n     * Blur image using image convolution.\n     *\n     * @return $this\n     */\n    public function blurImage()\n    {\n        $this->imageConvolution('blur');\n        return $this;\n    }\n\n\n\n    /**\n     * Create convolve expression and return arguments for image convolution.\n     *\n     * @param string $expression constant string which evaluates to a list of\n     *                           11 numbers separated by komma or such a list.\n     *\n     * @return array as $matrix (3x3), $divisor and $offset\n     */\n    public function createConvolveArguments($expression)\n    {\n        // Check of matching constant\n        if (isset($this->convolves[$expression])) {\n            $expression = $this->convolves[$expression];\n        }\n\n        $part = explode(',', $expression);\n        $this->log(\"Creating convolution expressen: $expression\");\n\n        // Expect list of 11 numbers, split by , and build up arguments\n        if (count($part) != 11) {\n            throw new Exception(\n                \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\"\n            );\n        }\n\n        array_walk($part, function ($item, $key) {\n            if (!is_numeric($item)) {\n                throw new Exception(\"Argument to convolve expression should be float but is not.\");\n            }\n        });\n\n        return array(\n            array(\n                array($part[0], $part[1], $part[2]),\n                array($part[3], $part[4], $part[5]),\n                array($part[6], $part[7], $part[8]),\n            ),\n            $part[9],\n            $part[10],\n        );\n    }\n\n\n\n    /**\n     * Add custom expressions (or overwrite existing) for image convolution.\n     *\n     * @param array $options Key value array with strings to be converted\n     *                       to convolution expressions.\n     *\n     * @return $this\n     */\n    public function addConvolveExpressions($options)\n    {\n        $this->convolves = array_merge($this->convolves, $options);\n        return $this;\n    }\n\n\n\n    /**\n     * Image convolution.\n     *\n     * @param string $options A string with 11 float separated by comma.\n     *\n     * @return $this\n     */\n    public function imageConvolution($options = null)\n    {\n        // Use incoming options or use $this.\n        $options = $options ? $options : $this->convolve;\n\n        // Treat incoming as string, split by +\n        $this->log(\"Convolution with '$options'\");\n        $options = explode(\":\", $options);\n\n        // Check each option if it matches constant value\n        foreach ($options as $option) {\n            list($matrix, $divisor, $offset) = $this->createConvolveArguments($option);\n            imageconvolution($this->image, $matrix, $divisor, $offset);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set default background color between 000000-FFFFFF or if using\n     * alpha 00000000-FFFFFF7F.\n     *\n     * @param string $color as hex value.\n     *\n     * @return $this\n    */\n    public function setDefaultBackgroundColor($color)\n    {\n        $this->log(\"Setting default background color to '$color'.\");\n\n        if (!(strlen($color) == 6 || strlen($color) == 8)) {\n            throw new Exception(\n                \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $red    = hexdec(substr($color, 0, 2));\n        $green  = hexdec(substr($color, 2, 2));\n        $blue   = hexdec(substr($color, 4, 2));\n\n        $alpha = (strlen($color) == 8)\n            ? hexdec(substr($color, 6, 2))\n            : null;\n\n        if (($red < 0 || $red > 255)\n            || ($green < 0 || $green > 255)\n            || ($blue < 0 || $blue > 255)\n            || ($alpha < 0 || $alpha > 127)\n        ) {\n            throw new Exception(\n                \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $this->bgColor = strtolower($color);\n        $this->bgColorDefault = array(\n            'red'   => $red,\n            'green' => $green,\n            'blue'  => $blue,\n            'alpha' => $alpha\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the background color.\n     *\n     * @param resource $img the image to work with or null if using $this->image.\n     *\n     * @return color value or null if no background color is set.\n    */\n    private function getBackgroundColor($img = null)\n    {\n        $img = isset($img) ? $img : $this->image;\n\n        if ($this->bgColorDefault) {\n\n            $red   = $this->bgColorDefault['red'];\n            $green = $this->bgColorDefault['green'];\n            $blue  = $this->bgColorDefault['blue'];\n            $alpha = $this->bgColorDefault['alpha'];\n\n            if ($alpha) {\n                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);\n            } else {\n                $color = imagecolorallocate($img, $red, $green, $blue);\n            }\n\n            return $color;\n\n        } else {\n            return 0;\n        }\n    }\n\n\n\n    /**\n     * Create a image and keep transparency for png and gifs.\n     *\n     * @param int $width of the new image.\n     * @param int $height of the new image.\n     *\n     * @return image resource.\n    */\n    private function createImageKeepTransparency($width, $height)\n    {\n        $this->log(\"Creating a new working image width={$width}px, height={$height}px.\");\n        $img = imagecreatetruecolor($width, $height);\n        imagealphablending($img, false);\n        imagesavealpha($img, true);\n\n        $index = imagecolortransparent($this->image);\n        if ($index != -1) {\n\n            imagealphablending($img, true);\n            $transparent = imagecolorsforindex($this->image, $index);\n            $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']);\n            imagefill($img, 0, 0, $color);\n            $index = imagecolortransparent($img, $color);\n            $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\");\n\n        } elseif ($this->bgColorDefault) {\n\n            $color = $this->getBackgroundColor($img);\n            imagefill($img, 0, 0, $color);\n            $this->Log(\"Filling image with background color.\");\n        }\n\n        return $img;\n    }\n\n\n\n    /**\n     * Set optimizing  and post-processing options.\n     *\n     * @param array $options with config for postprocessing with external tools.\n     *\n     * @return $this\n     */\n    public function setPostProcessingOptions($options)\n    {\n        if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) {\n            $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd'];\n        } else {\n            $this->jpegOptimizeCmd = null;\n        }\n\n        if (isset($options['png_filter']) && $options['png_filter']) {\n            $this->pngFilterCmd = $options['png_filter_cmd'];\n        } else {\n            $this->pngFilterCmd = null;\n        }\n\n        if (isset($options['png_deflate']) && $options['png_deflate']) {\n            $this->pngDeflateCmd = $options['png_deflate_cmd'];\n        } else {\n            $this->pngDeflateCmd = null;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Save image.\n     *\n     * @param string $src  as target filename.\n     * @param string $base as base directory where to store images.\n     *\n     * @return $this or false if no folder is set.\n     */\n    public function save($src = null, $base = null)\n    {\n        if (isset($src)) {\n            $this->setTarget($src, $base);\n        }\n\n        is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n\n        switch(strtolower($this->extension)) {\n\n            case 'jpeg':\n            case 'jpg':\n                $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\");\n                imagejpeg($this->image, $this->cacheFileName, $this->quality);\n\n                // Use JPEG optimize if defined\n                if ($this->jpegOptimizeCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->log($cmd);\n                    $this->log($res);\n                }\n                break;\n\n            case 'gif':\n                $this->Log(\"Saving image as GIF to cache.\");\n                imagegif($this->image, $this->cacheFileName);\n                break;\n\n            case 'png':\n                $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\");\n\n                // Turn off alpha blending and set alpha flag\n                imagealphablending($this->image, false);\n                imagesavealpha($this->image, true);\n                imagepng($this->image, $this->cacheFileName, $this->compress);\n\n                // Use external program to filter PNG, if defined\n                if ($this->pngFilterCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngFilterCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to deflate PNG, if defined\n                if ($this->pngDeflateCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n                break;\n\n            default:\n                $this->RaiseError('No support for this file extension.');\n                break;\n        }\n\n        if ($this->verbose) {\n            clearstatcache();\n            $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n            $this->log(\"imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\"imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\"Number of colors in image = \" . $this->ColorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\"Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Create a hard link, as an alias, to the cached file.\n     *\n     * @param string $alias where to store the link,\n     *                      filename without extension.\n     *\n     * @return $this\n     */\n    public function linkToCacheFile($alias)\n    {\n        if ($alias === null) {\n            $this->log(\"Ignore creating alias.\");\n            return $this;\n        }\n\n        $alias = $alias . \".\" . $this->extension;\n\n        if (is_readable($alias)) {\n            unlink($alias);\n        }\n\n        $res = link($this->cacheFileName, $alias);\n\n        if ($res) {\n            $this->log(\"Created an alias as: $alias\");\n        } else {\n            $this->log(\"Failed to create the alias: $alias\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Output image to browser using caching.\n     *\n     * @param string $file   to read and output, default is to use $this->cacheFileName\n     * @param string $format set to json to output file as json object with details\n     *\n     * @return void\n     */\n    public function output($file = null, $format = null)\n    {\n        if (is_null($file)) {\n            $file = $this->cacheFileName;\n        }\n\n        if (is_null($format)) {\n            $format = $this->outputFormat;\n        }\n\n        $this->log(\"Output format is: $format\");\n\n        if (!$this->verbose && $format == 'json') {\n            header('Content-type: application/json');\n            echo $this->json($file);\n            exit;\n        }\n\n        $this->log(\"Outputting image: $file\");\n\n        // Get image modification time\n        clearstatcache();\n        $lastModified = filemtime($file);\n        $gmdate = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        if (!$this->verbose) {\n            header('Last-Modified: ' . $gmdate . \" GMT\");\n        }\n\n        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {\n\n            if ($this->verbose) {\n                $this->log(\"304 not modified\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            header(\"HTTP/1.0 304 Not Modified\");\n\n        } else {\n\n            if ($this->verbose) {\n                $this->log(\"Last modified: \" . $gmdate . \" GMT\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            // Get details on image\n            $info = getimagesize($file);\n            !empty($info) or $this->raiseError(\"The file doesn't seem to be an image.\");\n            $mime = $info['mime'];\n\n            header('Content-type: ' . $mime);\n            readfile($file);\n        }\n\n        exit;\n    }\n\n\n\n    /**\n     * Create a JSON object from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string json-encoded representation of the image.\n     */\n    public function json($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $details = array();\n\n        clearstatcache();\n\n        $details['src']        = $this->imageSrc;\n        $lastModified          = filemtime($this->pathToImage);\n        $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $details['cache']        = basename($this->cacheFileName);\n        $lastModified            = filemtime($this->cacheFileName);\n        $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $this->loadImageDetails($file);\n\n        $details['filename'] = basename($file);\n        $details['width']  = $this->width;\n        $details['height'] = $this->height;\n        $details['aspectRatio'] = round($this->width / $this->height, 3);\n        $details['size'] = filesize($file);\n\n        $this->load($file);\n        $details['colors'] = $this->colorsTotal($this->image);\n\n        $options = null;\n        if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) {\n            $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;\n        }\n\n        return json_encode($details, $options);\n    }\n\n\n\n    /**\n     * Log an event if verbose mode.\n     *\n     * @param string $message to log.\n     *\n     * @return this\n     */\n    public function log($message)\n    {\n        if ($this->verbose) {\n            $this->log[] = $message;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Do verbose output and print out the log and the actual images.\n     *\n     * @return void\n     */\n    private function verboseOutput()\n    {\n        $log = null;\n        $this->log(\"As JSON: \\n\" . $this->json());\n        $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\");\n        $this->log(\"Memory limit: \" . ini_get('memory_limit'));\n\n        $included = get_included_files();\n        $this->log(\"Included files: \" . count($included));\n\n        foreach ($this->log as $val) {\n            if (is_array($val)) {\n                foreach ($val as $val1) {\n                    $log .= htmlentities($val1) . '<br/>';\n                }\n            } else {\n                $log .= htmlentities($val) . '<br/>';\n            }\n        }\n\n        echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n    }\n\n\n\n    /**\n     * Raise error, enables to implement a selection of error methods.\n     *\n     * @param string $message the error message to display.\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function raiseError($message)\n    {\n        throw new Exception($message);\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n$version = \"v0.7.0 (2015-02-10)\";\n\n\n\n/**\n * Default configuration options, can be overridden in own config-file.\n *\n * @param string $msg to display.\n *\n * @return void\n */\nfunction errorPage($msg)\n{\n    global $mode;\n\n    header(\"HTTP/1.0 500 Internal Server Error\");\n\n    if ($mode == 'development') {\n        die(\"[img.php] $msg\");\n    } else {\n        error_log(\"[img.php] $msg\");\n        die(\"HTTP/1.0 500 Internal Server Error\");\n    }\n}\n\n\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\"<p><b>img.php: Uncaught exception:</b> <p>\" . $exception->getMessage() . \"</p><pre>\" . $exception->getTraceAsString(), \"</pre>\");\n});\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null)\n{\n    global $verbose;\n    static $log = array();\n\n    if (!$verbose) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    $log[] = $msg;\n}\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} else if (!isset($config)) {\n    $config = array();\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\nverbose(\"img.php version = $version\");\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is nod loaded.\");\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\");\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} else if (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwdAlways) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n    if (!$passwordMatch) {\n        errorPage(\"Password required and does not match or exists.\");\n    }\n\n} elseif ($pwdConfig && $pwd) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer, PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n    } else if ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\");\n    } else if (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\");\n    } else if (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n    } else if (!empty($hotlinkingWhitelist)) {\n\n        $allowedByWhitelist = false;\n        foreach ($hotlinkingWhitelist as $val) {\n            if (preg_match($val, $refererHost)) {\n                $allowedByWhitelist = true;\n            }\n        }\n\n        if (!$allowedByWhitelist) {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist.\");\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\");\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Get the source files.\n */\n$autoloader  = getConfig('autoloader', false);\n$cimageClass = getConfig('cimage_class', false);\n\nif ($autoloader) {\n    require $autoloader;\n} else if ($cimageClass) {\n    require $cimageClass;\n}\n\n\n\n/**\n * Create the class for the image.\n */\n$img = new CImage();\n$img->setVerbose($verbose);\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $pattern);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = get('src')\n    or errorPage('Must set src-attribute.');\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\\.:]+$#');\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Filename contains invalid characters.');\n\nif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n\n} else if ($imagePathConstraint) {\n\n    // Check that the image is a file below the directory 'image_path'.\n    $pathToImage = realpath($imagePath . $srcImage);\n    $imageDir    = realpath($imagePath);\n\n    is_file($pathToImage)\n        or errorPage(\n            'Source image is not a valid file, check the filename and that a\n            matching file exists on the filesystem.'\n        );\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.'\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.');\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.');\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.');\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Hight out of range.');\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range');\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range');\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range');\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range');\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n * json - output the image as a JSON object with details on the image.\n */\n$outputFormat = getDefined('json', 'json', null);\n\nverbose(\"json = $outputFormat\");\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\");\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.');\n\n} else if ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.');\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio;\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Get the cachepath from config.\n */\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n\n\n\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Fimgs.php.txt",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * This version is a all-in-one version of img.php, it is not dependant an any other file\n * so you can simply copy it to any place you want it. \n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n\n/**\n * Change configuration details in the array below or create a separate file\n * where you store the configuration details. \n *\n * The configuration file should be named the same name as this file and then \n * add '_config.php'. If this file is named 'img.php' then name the\n * config file should be named 'img_config.php'.\n *\n * The settings below are only a few of the available ones. Check the file in\n * webroot/img_config.php for a complete list of configuration options.\n */\n$config = array(\n\n    'mode'         => 'development',               // 'production', 'development', 'strict'\n    //'image_path'   =>  __DIR__ . '/img/',\n    //'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n    //'remote_allow' => true,\n    //'password'     => false,                      // \"secret-password\",\n\n);\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CHttpGet\n{\n    private $request  = array();\n    private $response = array();\n\n\n\n    /**\n    * Constructor\n    *\n    */\n    public function __construct()\n    {\n        $this->request['header'] = array();\n    }\n\n\n\n    /**\n     * Set the url for the request.\n     *\n     * @param string $url\n     *\n     * @return $this\n     */\n    public function setUrl($url)\n    {\n        $this->request['url'] = $url;\n        return $this;\n    }\n\n\n\n    /**\n     * Set custom header field for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function setHeader($field, $value)\n    {\n        $this->request['header'][] = \"$field: $value\";\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function parseHeader()\n    {\n        $header = explode(\"\\r\\n\", rtrim($this->response['headerRaw'], \"\\r\\n\"));\n        $output = array();\n\n        if ('HTTP' === substr($header[0], 0, 4)) {\n            list($output['version'], $output['status']) = explode(' ', $header[0]);\n            unset($header[0]);\n        }\n\n        foreach ($header as $entry) {\n            $pos = strpos($entry, ':');\n            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));\n        }\n\n        $this->response['header'] = $output;\n        return $this;\n    }\n\n\n\n    /**\n     * Perform the request.\n     *\n     * @param boolean $debug set to true to dump headers.\n     *\n     * @return boolean\n     */\n    public function doGet($debug = false)\n    {\n        $options = array(\n            CURLOPT_URL             => $this->request['url'],\n            CURLOPT_HEADER          => 1,\n            CURLOPT_HTTPHEADER      => $this->request['header'],\n            CURLOPT_AUTOREFERER     => true,\n            CURLOPT_RETURNTRANSFER  => true,\n            CURLINFO_HEADER_OUT     => $debug,\n            CURLOPT_CONNECTTIMEOUT  => 5,\n            CURLOPT_TIMEOUT         => 5,\n        );\n\n        $ch = curl_init();\n        curl_setopt_array($ch, $options);\n        $response = curl_exec($ch);\n\n        if (!$response) {\n            return false;\n        }\n\n        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n        $this->response['headerRaw'] = substr($response, 0, $headerSize);\n        $this->response['body']      = substr($response, $headerSize);\n\n        $this->parseHeader();\n\n        if ($debug) {\n            $info = curl_getinfo($ch);\n            echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\";\n            echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\";\n            echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\";\n        }\n\n        curl_close($ch);\n        return true;\n    }\n\n\n\n    /**\n     * Get HTTP code of response.\n     *\n     * @return integer as HTTP status code or null if not available.\n     */\n    public function getStatus()\n    {\n        return isset($this->response['header']['status'])\n            ? (int) $this->response['header']['status']\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @return int as timestamp.\n     */\n    public function getLastModified()\n    {\n        return isset($this->response['header']['Last-Modified'])\n            ? strtotime($this->response['header']['Last-Modified'])\n            : null;\n    }\n\n\n\n    /**\n     * Get content type.\n     *\n     * @return string as the content type or null if not existing or invalid.\n     */\n    public function getContentType()\n    {\n        $type = isset($this->response['header']['Content-Type'])\n            ? $this->response['header']['Content-Type']\n            : null;\n\n        return preg_match('#[a-z]+/[a-z]+#', $type)\n            ? $type\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @param mixed $default as default value (int seconds) if date is\n     *                       missing in response header.\n     *\n     * @return int as timestamp or $default if Date is missing in\n     *             response header.\n     */\n    public function getDate($default = false)\n    {\n        return isset($this->response['header']['Date'])\n            ? strtotime($this->response['header']['Date'])\n            : $default;\n    }\n\n\n\n    /**\n     * Get max age of cachable item.\n     *\n     * @param mixed $default as default value if date is missing in response\n     *                       header.\n     *\n     * @return int as timestamp or false if not available.\n     */\n    public function getMaxAge($default = false)\n    {\n        $cacheControl = isset($this->response['header']['Cache-Control'])\n            ? $this->response['header']['Cache-Control']\n            : null;\n\n        $maxAge = null;\n        if ($cacheControl) {\n            // max-age=2592000\n            $part = explode('=', $cacheControl);\n            $maxAge = ($part[0] == \"max-age\")\n                ? (int) $part[1]\n                : null;\n        }\n\n        if ($maxAge) {\n            return $maxAge;\n        }\n\n        $expire = isset($this->response['header']['Expires'])\n            ? strtotime($this->response['header']['Expires'])\n            : null;\n\n        return $expire ? $expire : $default;\n    }\n\n\n\n    /**\n     * Get body of response.\n     *\n     * @return string as body.\n     */\n    public function getBody()\n    {\n        return $this->response['body'];\n    }\n}\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CRemoteImage\n{\n    /**\n     * Path to cache files.\n     */\n    private $saveFolder = null;\n\n\n\n    /**\n     * Use cache or not.\n     */\n    private $useCache = true;\n\n\n\n    /**\n     * HTTP object to aid in download file.\n     */\n    private $http;\n\n\n\n    /**\n     * Status of the HTTP request.\n     */\n    private $status;\n\n\n\n    /**\n     * Defalt age for cached items 60*60*24*7.\n     */\n    private $defaultMaxAge = 604800;\n\n\n\n    /**\n     * Url of downloaded item.\n     */\n    private $url;\n\n\n\n    /**\n     * Base name of cache file for downloaded item.\n     */\n    private $fileName;\n\n\n\n    /**\n     * Filename for json-file with details of cached item.\n     */\n    private $fileJson;\n\n\n\n    /**\n     * Filename for image-file.\n     */\n    private $fileImage;\n\n\n\n    /**\n     * Cache details loaded from file.\n     */\n    private $cache;\n\n\n\n    /**\n     * Constructor\n     *\n     */\n    public function __construct()\n    {\n        ;\n    }\n\n\n    /**\n     * Get status of last HTTP request.\n     *\n     * @return int as status\n     */\n    public function getStatus()\n    {\n        return $this->status;\n    }\n\n\n\n    /**\n     * Get JSON details for cache item.\n     *\n     * @return array with json details on cache.\n     */\n    public function getDetails()\n    {\n        return $this->cache;\n    }\n\n\n\n    /**\n     * Set the path to the cache directory.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function setCache($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if cache is writable or throw exception.\n     *\n     * @return $this\n     *\n     * @throws Exception if cahce folder is not writable.\n     */\n    public function isCacheWritable()\n    {\n        if (!is_writable($this->saveFolder)) {\n            throw new Exception(\"Cache folder is not writable for downloaded files.\");\n        }\n        return $this;\n    }\n\n\n\n    /**\n     * Decide if the cache should be used or not before trying to download\n     * a remote file.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Translate a content type to a file extension.\n     *\n     * @param string $type a valid content type.\n     *\n     * @return string as file extension or false if no match.\n     */\n    function contentTypeToFileExtension($type) {\n        $extension = array(\n            'image/jpeg' => 'jpg',\n            'image/png'  => 'png',\n            'image/gif'  => 'gif',\n        );\n\n        return isset($extension[$type])\n        ? $extension[$type]\n        : false;\n    }\n\n\n\n    /**\n     * Set header fields.\n     *\n     * @return $this\n     */\n    function setHeaderFields() {\n        $this->http->setHeader(\"User-Agent\", \"CImage/0.6 (PHP/\". phpversion() . \" cURL)\");\n        $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\");\n\n        if ($this->useCache) {\n            $this->http->setHeader(\"Cache-Control\", \"max-age=0\");\n        } else {\n            $this->http->setHeader(\"Cache-Control\", \"no-cache\");\n            $this->http->setHeader(\"Pragma\", \"no-cache\");\n        }\n    }\n\n\n\n    /**\n     * Save downloaded resource to cache.\n     *\n     * @return string as path to saved file or false if not saved.\n     */\n    function save() {\n\n        $this->cache = array();\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n        $type         = $this->http->getContentType();\n        $extension    = $this->contentTypeToFileExtension($type);\n\n        $this->cache['Date']           = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']        = $maxAge;\n        $this->cache['Content-Type']   = $type;\n        $this->cache['File-Extension'] = $extension;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        if ($extension) {\n\n            $this->fileImage = $this->fileName . \".\" . $extension;\n\n            // Save only if body is a valid image\n            $body = $this->http->getBody();\n            $img = imagecreatefromstring($body);\n\n            if ($img !== false) {\n                file_put_contents($this->fileImage, $body);\n                file_put_contents($this->fileJson, json_encode($this->cache));\n                return $this->fileImage;\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Got a 304 and updates cache with new age.\n     *\n     * @return string as path to cached file.\n     */\n    function updateCacheDetails() {\n\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n\n        $this->cache['Date']     = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']  = $maxAge;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        file_put_contents($this->fileJson, json_encode($this->cache));\n        return $this->fileImage;\n    }\n\n\n\n    /**\n     * Download a remote file and keep a cache of downloaded files.\n     *\n     * @param string $url a remote url.\n     *\n     * @return string as path to downloaded file or false if failed.\n     */\n    function download($url) {\n\n        $this->http = new CHttpGet();\n        $this->url = $url;\n\n        // First check if the cache is valid and can be used\n        $this->loadCacheDetails();\n\n        if ($this->useCache) {\n            $src = $this->getCachedSource();\n            if ($src) {\n                $this->status = 1;\n                return $src;\n            }\n        }\n\n        // Do a HTTP request to download item\n        $this->setHeaderFields();\n        $this->http->setUrl($this->url);\n        $this->http->doGet();\n\n        $this->status = $this->http->getStatus();\n        if ($this->status === 200) {\n            $this->isCacheWritable();\n            return $this->save();\n        } else if ($this->status === 304) {\n            $this->isCacheWritable();\n            return $this->updateCacheDetails();\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return $this\n     */\n    public function loadCacheDetails()\n    {\n        $cacheFile = str_replace(array(\"/\", \":\", \"#\", \".\", \"?\"), \"-\", $this->url);\n        $this->fileName = $this->saveFolder . $cacheFile;\n        $this->fileJson = $this->fileName . \".json\";\n        if (is_readable($this->fileJson)) {\n            $this->cache = json_decode(file_get_contents($this->fileJson), true);\n        }\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return string as the path ot the image file or false if no cache.\n     */\n    public function getCachedSource()\n    {\n        $this->fileImage = $this->fileName . \".\" . $this->cache['File-Extension'];\n        $imageExists = is_readable($this->fileImage);\n\n        // Is cache valid?\n        $date   = strtotime($this->cache['Date']);\n        $maxAge = $this->cache['Max-Age'];\n        $now = time();\n        if ($imageExists && $date + $maxAge > $now) {\n            return $this->fileImage;\n        }\n\n        // Prepare for a 304 if available\n        if ($imageExists && isset($this->cache['Last-Modified'])) {\n            $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']);\n        }\n\n        return false;\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n */\nclass CImage\n{\n\n    /**\n     * Constants type of PNG image\n     */\n    const PNG_GREYSCALE         = 0;\n    const PNG_RGB               = 2;\n    const PNG_RGB_PALETTE       = 3;\n    const PNG_GREYSCALE_ALPHA   = 4;\n    const PNG_RGB_ALPHA         = 6;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const JPEG_QUALITY_DEFAULT = 60;\n\n\n\n    /**\n     * Quality level for JPEG images.\n     */\n    private $quality;\n\n\n\n    /**\n     * Is the quality level set from external use (true) or is it default (false)?\n     */\n    private $useQuality = false;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const PNG_COMPRESSION_DEFAULT = -1;\n\n\n\n    /**\n     * Compression level for PNG images.\n     */\n    private $compress;\n\n\n\n    /**\n     * Is the compress level set from external use (true) or is it default (false)?\n     */\n    private $useCompress = false;\n\n\n\n\n    /**\n     * Default background color, red, green, blue, alpha.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    /*\n    const BACKGROUND_COLOR = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );*/\n\n\n\n    /**\n     * Default background color to use.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    //private $bgColorDefault = self::BACKGROUND_COLOR;\n    private $bgColorDefault = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );\n\n\n    /**\n     * Background color to use, specified as part of options.\n     */\n    private $bgColor;\n\n\n\n    /**\n     * Where to save the target file.\n     */\n    private $saveFolder;\n\n\n\n    /**\n     * The working image object.\n     */\n    private $image;\n\n\n\n    /**\n     * The root folder of images (only used in constructor to create $pathToImage?).\n     */\n    private $imageFolder;\n\n\n\n    /**\n     * Image filename, may include subdirectory, relative from $imageFolder\n     */\n    private $imageSrc;\n\n\n\n    /**\n     * Actual path to the image, $imageFolder . '/' . $imageSrc\n     */\n    private $pathToImage;\n\n\n\n    /**\n     * Original file extension\n     */\n    private $fileExtension;\n\n\n\n    /**\n     * File extension to use when saving image.\n     */\n    private $extension;\n\n\n\n    /**\n     * Output format, supports null (image) or json.\n     */\n    private $outputFormat = null;\n\n\n\n    /**\n     * Verbose mode to print out a trace and display the created image\n     */\n    private $verbose = false;\n\n\n\n    /**\n     * Keep a log/trace on what happens\n     */\n    private $log = array();\n\n\n\n    /**\n     * Handle image as palette image\n     */\n    private $palette;\n\n\n\n    /**\n     * Target filename, with path, to save resulting image in.\n     */\n    private $cacheFileName;\n\n\n\n    /**\n     * Set a format to save image as, or null to use original format.\n     */\n    private $saveAs;\n\n\n    /**\n     * Path to command for filter optimize, for example optipng or null.\n     */\n    private $pngFilter;\n\n\n\n    /**\n     * Path to command for deflate optimize, for example pngout or null.\n     */\n    private $pngDeflate;\n\n\n\n    /**\n     * Path to command to optimize jpeg images, for example jpegtran or null.\n     */\n    private $jpegOptimize;\n\n\n    /**\n     * Image dimensions, calculated from loaded image.\n     */\n    private $width;  // Calculated from source image\n    private $height; // Calculated from source image\n\n\n    /**\n     * New image dimensions, incoming as argument or calculated.\n     */\n    private $newWidth;\n    private $newWidthOrig;  // Save original value\n    private $newHeight;\n    private $newHeightOrig; // Save original value\n\n\n    /**\n     * Change target height & width when different dpr, dpr 2 means double image dimensions.\n     */\n    private $dpr = 1;\n\n\n    /**\n     * Always upscale images, even if they are smaller than target image.\n     */\n    const UPSCALE_DEFAULT = true;\n    private $upscale = self::UPSCALE_DEFAULT;\n\n\n\n    /**\n     * Array with details on how to crop, incoming as argument and calculated.\n     */\n    public $crop;\n    public $cropOrig; // Save original value\n\n\n    /**\n     * String with details on how to do image convolution. String\n     * should map a key in the $convolvs array or be a string of\n     * 11 float values separated by comma. The first nine builds\n     * up the matrix, then divisor and last offset.\n     */\n    private $convolve;\n\n\n    /**\n     * Custom convolution expressions, matrix 3x3, divisor and offset.\n     */\n    private $convolves = array(\n        'lighten'       => '0,0,0, 0,12,0, 0,0,0, 9, 0',\n        'darken'        => '0,0,0, 0,6,0, 0,0,0, 9, 0',\n        'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n        'emboss'        => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0',\n        'emboss-alt'    => '-2,-1,0, -1,1,1, 0,1,2, 1, 0',\n        'blur'          => '1,1,1, 1,15,1, 1,1,1, 23, 0',\n        'gblur'         => '1,2,1, 2,4,2, 1,2,1, 16, 0',\n        'edge'          => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0',\n        'edge-alt'      => '0,1,0, 1,-4,1, 0,1,0, 1, 0',\n        'draw'          => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0',\n        'mean'          => '1,1,1, 1,1,1, 1,1,1, 9, 0',\n        'motion'        => '1,0,0, 0,1,0, 0,0,1, 3, 0',\n    );\n\n\n    /**\n     * Resize strategy to fill extra area with background color.\n     * True or false.\n     */\n    private $fillToFit;\n\n\n    /**\n     * Used with option area to set which parts of the image to use.\n     */\n    private $offset;\n\n\n\n    /**\n    * Calculate target dimension for image when using fill-to-fit resize strategy.\n    */\n    private $fillWidth;\n    private $fillHeight;\n\n\n\n    /**\n    * Allow remote file download, default is to disallow remote file download.\n    */\n    private $allowRemote = false;\n\n\n\n    /**\n     * Pattern to recognize a remote file.\n     */\n    //private $remotePattern = '#^[http|https]://#';\n    private $remotePattern = '#^https?://#';\n\n\n\n    /**\n     * Use the cache if true, set to false to ignore the cached file.\n     */\n    private $useCache = true;\n\n\n    /**\n     * Properties, the class is mutable and the method setOptions()\n     * decides (partly) what properties are created.\n     *\n     * @todo Clean up these and check if and how they are used\n     */\n\n    public $keepRatio;\n    public $cropToFit;\n    private $cropWidth;\n    private $cropHeight;\n    public $crop_x;\n    public $crop_y;\n    public $filters;\n    private $type; // Calculated from source image\n    private $attr; // Calculated from source image\n    private $useOriginal; // Use original image if possible\n\n\n\n\n    /**\n     * Constructor, can take arguments to init the object.\n     *\n     * @param string $imageSrc    filename which may contain subdirectory.\n     * @param string $imageFolder path to root folder for images.\n     * @param string $saveFolder  path to folder where to save the new file or null to skip saving.\n     * @param string $saveName    name of target file when saveing.\n     */\n    public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null)\n    {\n        $this->setSource($imageSrc, $imageFolder);\n        $this->setTarget($saveFolder, $saveName);\n    }\n\n\n\n    /**\n     * Set verbose mode.\n     *\n     * @param boolean $mode true or false to enable and disable verbose mode,\n     *                      default is true.\n     *\n     * @return $this\n     */\n    public function setVerbose($mode = true)\n    {\n        $this->verbose = $mode;\n        return $this;\n    }\n\n\n\n    /**\n     * Set save folder, base folder for saving cache files.\n     *\n     * @todo clean up how $this->saveFolder is used in other methods.\n     *\n     * @param string $path where to store cached files.\n     *\n     * @return $this\n     */\n    public function setSaveFolder($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Use cache or not.\n     *\n     * @todo clean up how $this->noCache is used in other methods.\n     *\n     * @param string $use true or false to use cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Allow or disallow remote image download.\n     *\n     * @param boolean $allow   true or false to enable and disable.\n     * @param string  $pattern to use to detect if its a remote file.\n     *\n     * @return $this\n     */\n    public function setRemoteDownload($allow, $pattern = null)\n    {\n        $this->allowRemote = $allow;\n        $this->remotePattern = $pattern ? $pattern : $this->remotePattern;\n\n        $this->log(\"Set remote download to: \"\n            . ($this->allowRemote ? \"true\" : \"false\")\n            . \" using pattern \"\n            . $this->remotePattern);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the image resource is a remote file or not.\n     *\n     * @param string $src check if src is remote.\n     *\n     * @return boolean true if $src is a remote file, else false.\n     */\n    public function isRemoteSource($src)\n    {\n        $remote = preg_match($this->remotePattern, $src);\n        $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\"));\n        return $remote;\n    }\n\n\n\n    /**\n     * Check if file extension is valid as a file extension.\n     *\n     * @param string $extension of image file.\n     *\n     * @return $this\n     */\n    private function checkFileExtension($extension)\n    {\n        $valid = array('jpg', 'jpeg', 'png', 'gif');\n\n        in_array(strtolower($extension), $valid)\n            or $this->raiseError('Not a valid file extension.');\n\n        return $this;\n    }\n\n\n\n    /**\n     * Download a remote image and return path to its local copy.\n     *\n     * @param string $src remote path to image.\n     *\n     * @return string as path to downloaded remote source.\n     */\n    public function downloadRemoteSource($src)\n    {\n        $remote = new CRemoteImage();\n        $cache  = $this->saveFolder . \"/remote/\";\n\n        if (!is_dir($cache)) {\n            if (!is_writable($this->saveFolder)) {\n                throw new Exception(\"Can not create remote cache, cachefolder not writable.\");\n            }\n            mkdir($cache);\n            $this->log(\"The remote cache does not exists, creating it.\");\n        }\n\n        if (!is_writable($cache)) {\n            $this->log(\"The remote cache is not writable.\");\n        }\n\n        $remote->setCache($cache);\n        $remote->useCache($this->useCache);\n        $src = $remote->download($src);\n\n        $this->log(\"Remote HTTP status: \" . $remote->getStatus());\n        $this->log(\"Remote item has local cached file: $src\");\n        $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true));\n\n        return $src;\n    }\n\n\n\n    /**\n     * Set src file.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     */\n    public function setSource($src, $dir = null)\n    {\n        if (!isset($src)) {\n            return $this;\n        }\n\n        if ($this->allowRemote && $this->isRemoteSource($src)) {\n            $src = $this->downloadRemoteSource($src);\n            $dir = null;\n        }\n\n        if (!isset($dir)) {\n            $dir = dirname($src);\n            $src = basename($src);\n        }\n\n        $this->imageSrc       = ltrim($src, '/');\n        $this->imageFolder    = rtrim($dir, '/');\n        $this->pathToImage    = $this->imageFolder . '/' . $this->imageSrc;\n        $this->fileExtension  = strtolower(pathinfo($this->pathToImage, PATHINFO_EXTENSION));\n        //$this->extension      = $this->fileExtension;\n\n        $this->checkFileExtension($this->fileExtension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set target file.\n     *\n     * @param string $src of target image.\n     * @param string $dir as base directory where images are stored.\n     *\n     * @return $this\n     */\n    public function setTarget($src = null, $dir = null)\n    {\n        if (!(isset($src) && isset($dir))) {\n            return $this;\n        }\n\n        $this->saveFolder     = $dir;\n        $this->cacheFileName  = $dir . '/' . $src;\n\n        /* Allow readonly cache\n        is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n        */\n\n        // Sanitize filename\n        $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName);\n        $this->log(\"The cache file name is: \" . $this->cacheFileName);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set options to use when processing image.\n     *\n     * @param array $args used when processing image.\n     *\n     * @return $this\n     */\n    public function setOptions($args)\n    {\n        $this->log(\"Set new options for processing image.\");\n\n        $defaults = array(\n            // Options for calculate dimensions\n            'newWidth'    => null,\n            'newHeight'   => null,\n            'aspectRatio' => null,\n            'keepRatio'   => true,\n            'cropToFit'   => false,\n            'fillToFit'   => null,\n            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),\n            'area'        => null, //'0,0,0,0',\n            'upscale'     => self::UPSCALE_DEFAULT,\n\n            // Options for caching or using original\n            'useCache'    => true,\n            'useOriginal' => true,\n\n            // Pre-processing, before resizing is done\n            'scale'        => null,\n            'rotateBefore' => null,\n            'autoRotate'  => false,\n\n            // General options\n            'bgColor'     => null,\n\n            // Post-processing, after resizing is done\n            'palette'     => null,\n            'filters'     => null,\n            'sharpen'     => null,\n            'emboss'      => null,\n            'blur'        => null,\n            'convolve'       => null,\n            'rotateAfter' => null,\n\n            // Output format\n            'outputFormat' => null,\n            'dpr'          => 1,\n\n            // Options for saving\n            //'quality'     => null,\n            //'compress'    => null,\n            //'saveAs'      => null,\n        );\n\n        // Convert crop settings from string to array\n        if (isset($args['crop']) && !is_array($args['crop'])) {\n            $pices = explode(',', $args['crop']);\n            $args['crop'] = array(\n                'width'   => $pices[0],\n                'height'  => $pices[1],\n                'start_x' => $pices[2],\n                'start_y' => $pices[3],\n            );\n        }\n\n        // Convert area settings from string to array\n        if (isset($args['area']) && !is_array($args['area'])) {\n                $pices = explode(',', $args['area']);\n                $args['area'] = array(\n                    'top'    => $pices[0],\n                    'right'  => $pices[1],\n                    'bottom' => $pices[2],\n                    'left'   => $pices[3],\n                );\n        }\n\n        // Convert filter settings from array of string to array of array\n        if (isset($args['filters']) && is_array($args['filters'])) {\n            foreach ($args['filters'] as $key => $filterStr) {\n                $parts = explode(',', $filterStr);\n                $filter = $this->mapFilter($parts[0]);\n                $filter['str'] = $filterStr;\n                for ($i=1; $i<=$filter['argc']; $i++) {\n                    if (isset($parts[$i])) {\n                        $filter[\"arg{$i}\"] = $parts[$i];\n                    } else {\n                        throw new Exception(\n                            'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php'\n                        );\n                    }\n                }\n                $args['filters'][$key] = $filter;\n            }\n        }\n\n        // Merge default arguments with incoming and set properties.\n        //$args = array_merge_recursive($defaults, $args);\n        $args = array_merge($defaults, $args);\n        foreach ($defaults as $key => $val) {\n            $this->{$key} = $args[$key];\n        }\n\n        if ($this->bgColor) {\n            $this->setDefaultBackgroundColor($this->bgColor);\n        }\n\n        // Save original values to enable re-calculating\n        $this->newWidthOrig  = $this->newWidth;\n        $this->newHeightOrig = $this->newHeight;\n        $this->cropOrig      = $this->crop;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Map filter name to PHP filter and id.\n     *\n     * @param string $name the name of the filter.\n     *\n     * @return array with filter settings\n     * @throws Exception\n     */\n    private function mapFilter($name)\n    {\n        $map = array(\n            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),\n            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),\n            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),\n            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),\n            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),\n            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),\n            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),\n            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),\n            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),\n            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),\n            'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),\n            'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),\n        );\n\n        if (isset($map[$name])) {\n            return $map[$name];\n        } else {\n            throw new Exception('No such filter.');\n        }\n    }\n\n\n\n    /**\n     * Load image details from original image file.\n     *\n     * @param string $file the file to load or null to use $this->pathToImage.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function loadImageDetails($file = null)\n    {\n        $file = $file ? $file : $this->pathToImage;\n\n        is_readable($file)\n            or $this->raiseError('Image file does not exist.');\n\n        // Get details on image\n        $info = list($this->width, $this->height, $this->type, $this->attr) = getimagesize($file);\n        !empty($info) or $this->raiseError(\"The file doesn't seem to be an image.\");\n\n        if ($this->verbose) {\n            $this->log(\"Image file: {$file}\");\n            $this->log(\"Image width x height (type): {$this->width} x {$this->height} ({$this->type}).\");\n            $this->log(\"Image filesize: \" . filesize($file) . \" bytes.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Init new width and height and do some sanity checks on constraints, before any\n     * processing can be done.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function initDimensions()\n    {\n        $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // width as %\n        if ($this->newWidth[strlen($this->newWidth)-1] == '%') {\n            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;\n            $this->log(\"Setting new width based on % to {$this->newWidth}\");\n        }\n\n        // height as %\n        if ($this->newHeight[strlen($this->newHeight)-1] == '%') {\n            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;\n            $this->log(\"Setting new height based on % to {$this->newHeight}\");\n        }\n\n        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');\n\n        // width & height from aspect ratio\n        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {\n            if ($this->aspectRatio >= 1) {\n                $this->newWidth   = $this->width;\n                $this->newHeight  = $this->width / $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n\n            } else {\n                $this->newHeight  = $this->height;\n                $this->newWidth   = $this->height * $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n            }\n\n        } elseif ($this->aspectRatio && is_null($this->newWidth)) {\n            $this->newWidth   = $this->newHeight * $this->aspectRatio;\n            $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\");\n\n        } elseif ($this->aspectRatio && is_null($this->newHeight)) {\n            $this->newHeight  = $this->newWidth / $this->aspectRatio;\n            $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\");\n        }\n\n        // Change width & height based on dpr\n        if ($this->dpr != 1) {\n            if (!is_null($this->newWidth)) {\n                $this->newWidth  = round($this->newWidth * $this->dpr);\n                $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\");\n            }\n            if (!is_null($this->newHeight)) {\n                $this->newHeight = round($this->newHeight * $this->dpr);\n                $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\");\n            }\n        }\n\n        // Check values to be within domain\n        is_null($this->newWidth)\n            or is_numeric($this->newWidth)\n            or $this->raiseError('Width not numeric');\n\n        is_null($this->newHeight)\n            or is_numeric($this->newHeight)\n            or $this->raiseError('Height not numeric');\n\n        $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Calculate new width and height of image, based on settings.\n     *\n     * @return $this\n     */\n    public function calculateNewWidthAndHeight()\n    {\n        // Crop, use cropped width and height as base for calulations\n        $this->log(\"Calculate new width and height.\");\n        $this->log(\"Original width x height is {$this->width} x {$this->height}.\");\n        $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // Check if there is an area to crop off\n        if (isset($this->area)) {\n            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);\n            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);\n            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);\n            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);\n            $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];\n            $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];\n            $this->width  = $this->offset['width'];\n            $this->height = $this->offset['height'];\n            $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\");\n            $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\");\n        }\n\n        $width  = $this->width;\n        $height = $this->height;\n\n        // Check if crop is set\n        if ($this->crop) {\n            $width  = $this->crop['width']  = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];\n            $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];\n\n            if ($this->crop['start_x'] == 'left') {\n                $this->crop['start_x'] = 0;\n            } elseif ($this->crop['start_x'] == 'right') {\n                $this->crop['start_x'] = $this->width - $width;\n            } elseif ($this->crop['start_x'] == 'center') {\n                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);\n            }\n\n            if ($this->crop['start_y'] == 'top') {\n                $this->crop['start_y'] = 0;\n            } elseif ($this->crop['start_y'] == 'bottom') {\n                $this->crop['start_y'] = $this->height - $height;\n            } elseif ($this->crop['start_y'] == 'center') {\n                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);\n            }\n\n            $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\");\n        }\n\n        // Calculate new width and height if keeping aspect-ratio.\n        if ($this->keepRatio) {\n\n            $this->log(\"Keep aspect ratio.\");\n\n            // Crop-to-fit and both new width and height are set.\n            if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Use newWidth and newHeigh as width/height, image should fit in box.\n                $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\");\n\n            } elseif (isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Both new width and height are set.\n                // Use newWidth and newHeigh as max width/height, image should not be larger.\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n                $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;\n                $this->newWidth  = round($width  / $ratio);\n                $this->newHeight = round($height / $ratio);\n                $this->log(\"New width and height was set.\");\n\n            } elseif (isset($this->newWidth)) {\n\n                // Use new width as max-width\n                $factor = (float)$this->newWidth / (float)$width;\n                $this->newHeight = round($factor * $height);\n                $this->log(\"New width was set.\");\n\n            } elseif (isset($this->newHeight)) {\n\n                // Use new height as max-hight\n                $factor = (float)$this->newHeight / (float)$height;\n                $this->newWidth = round($factor * $width);\n                $this->log(\"New height was set.\");\n\n            }\n\n            // Get image dimensions for pre-resize image.\n            if ($this->cropToFit || $this->fillToFit) {\n\n                // Get relations of original & target image\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n\n                if ($this->cropToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Crop to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;\n                    $this->cropWidth  = round($width  / $ratio);\n                    $this->cropHeight = round($height / $ratio);\n                    $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\");\n\n                } else if ($this->fillToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Fill to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;\n                    $this->fillWidth  = round($width  / $ratio);\n                    $this->fillHeight = round($height / $ratio);\n                    $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\");\n                }\n            }\n        }\n\n        // Crop, ensure to set new width and height\n        if ($this->crop) {\n            $this->log(\"Crop.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }\n\n        // Fill to fit, ensure to set new width and height\n        /*if ($this->fillToFit) {\n            $this->log(\"FillToFit.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }*/\n\n        // No new height or width is set, use existing measures.\n        $this->newWidth  = round(isset($this->newWidth) ? $this->newWidth : $this->width);\n        $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height);\n        $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Re-calculate image dimensions when original image dimension has changed.\n     *\n     * @return $this\n     */\n    public function reCalculateDimensions()\n    {\n        $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight);\n\n        $this->newWidth  = $this->newWidthOrig;\n        $this->newHeight = $this->newHeightOrig;\n        $this->crop      = $this->cropOrig;\n\n        $this->initDimensions()\n             ->calculateNewWidthAndHeight();\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set extension for filename to save as.\n     *\n     * @param string $saveas extension to save image as\n     *\n     * @return $this\n     */\n    public function setSaveAsExtension($saveAs = null)\n    {\n        if (isset($saveAs)) {\n            $saveAs = strtolower($saveAs);\n            $this->checkFileExtension($saveAs);\n            $this->saveAs = $saveAs;\n            $this->extension = $saveAs;\n        }\n\n        $this->log(\"Prepare to save image using as: \" . $this->extension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set JPEG quality to use when saving image\n     *\n     * @param int $quality as the quality to set.\n     *\n     * @return $this\n     */\n    public function setJpegQuality($quality = null)\n    {\n        if ($quality) {\n            $this->useQuality = true;\n        }\n\n        $this->quality = isset($quality)\n            ? $quality\n            : self::JPEG_QUALITY_DEFAULT;\n\n        (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting JPEG quality to {$this->quality}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set PNG compressen algorithm to use when saving image\n     *\n     * @param int $compress as the algorithm to use.\n     *\n     * @return $this\n     */\n    public function setPngCompression($compress = null)\n    {\n        if ($compress) {\n            $this->useCompress = true;\n        }\n\n        $this->compress = isset($compress)\n            ? $compress\n            : self::PNG_COMPRESSION_DEFAULT;\n\n        (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting PNG compression level to {$this->compress}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Use original image if possible, check options which affects image processing.\n     *\n     * @param boolean $useOrig default is to use original if possible, else set to false.\n     *\n     * @return $this\n     */\n    public function useOriginalIfPossible($useOrig = true)\n    {\n        if ($useOrig\n            && ($this->newWidth == $this->width)\n            && ($this->newHeight == $this->height)\n            && !$this->area\n            && !$this->crop\n            && !$this->cropToFit\n            && !$this->fillToFit\n            && !$this->filters\n            && !$this->sharpen\n            && !$this->emboss\n            && !$this->blur\n            && !$this->convolve\n            && !$this->palette\n            && !$this->useQuality\n            && !$this->useCompress\n            && !$this->saveAs\n            && !$this->rotateBefore\n            && !$this->rotateAfter\n            && !$this->autoRotate\n            && !$this->bgColor\n            && ($this->upscale === self::UPSCALE_DEFAULT)\n        ) {\n            $this->log(\"Using original image.\");\n            $this->output($this->pathToImage);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Generate filename to save file in cache.\n     *\n     * @param string $base as basepath for storing file.\n     *\n     * @return $this\n     */\n    public function generateFilename($base)\n    {\n        $parts        = pathinfo($this->pathToImage);\n        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;\n        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;\n        $crop_x       = $this->crop_x       ? \"_x{$this->crop_x}\"        : null;\n        $crop_y       = $this->crop_y       ? \"_y{$this->crop_y}\"        : null;\n        $scale        = $this->scale        ? \"_s{$this->scale}\"         : null;\n        $bgColor      = $this->bgColor      ? \"_bgc{$this->bgColor}\"     : null;\n        $quality      = $this->quality      ? \"_q{$this->quality}\"       : null;\n        $compress     = $this->compress     ? \"_co{$this->compress}\"     : null;\n        $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null;\n        $rotateAfter  = $this->rotateAfter  ? \"_ra{$this->rotateAfter}\"  : null;\n\n        $width  = $this->newWidth;\n        $height = $this->newHeight;\n\n        $offset = isset($this->offset)\n            ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left']\n            : null;\n\n        $crop = $this->crop\n            ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y']\n            : null;\n\n        $filters = null;\n        if (isset($this->filters)) {\n            foreach ($this->filters as $filter) {\n                if (is_array($filter)) {\n                    $filters .= \"_f{$filter['id']}\";\n                    for ($i=1; $i<=$filter['argc']; $i++) {\n                        $filters .= \":\".$filter[\"arg{$i}\"];\n                    }\n                }\n            }\n        }\n\n        $sharpen = $this->sharpen ? 's' : null;\n        $emboss  = $this->emboss  ? 'e' : null;\n        $blur    = $this->blur    ? 'b' : null;\n        $palette = $this->palette ? 'p' : null;\n\n        $autoRotate = $this->autoRotate ? 'ar' : null;\n\n        $this->extension = isset($this->extension)\n            ? $this->extension\n            : $parts['extension'];\n\n        $optimize = null;\n        if ($this->extension == 'jpeg' || $this->extension == 'jpg') {\n            $optimize = $this->jpegOptimize ? 'o' : null;\n        } elseif ($this->extension == 'png') {\n            $optimize .= $this->pngFilter  ? 'f' : null;\n            $optimize .= $this->pngDeflate ? 'd' : null;\n        }\n\n        $convolve = null;\n        if ($this->convolve) {\n            $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve);\n        }\n\n        $upscale = null;\n        if ($this->upscale !== self::UPSCALE_DEFAULT) {\n            $upscale = '_nu';\n        }\n\n        $subdir = str_replace('/', '-', dirname($this->imageSrc));\n        $subdir = ($subdir == '.') ? '_.' : $subdir;\n        $file = $subdir . '_' . $parts['filename'] . '_' . $width . '_'\n            . $height . $offset . $crop . $cropToFit . $fillToFit\n            . $crop_x . $crop_y . $upscale\n            . $quality . $filters . $sharpen . $emboss . $blur . $palette . $optimize\n            . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor . $convolve\n            . '.' . $this->extension;\n\n        return $this->setTarget($file, $base);\n    }\n\n\n\n    /**\n     * Use cached version of image, if possible.\n     *\n     * @param boolean $useCache is default true, set to false to avoid using cached object.\n     *\n     * @return $this\n     */\n    public function useCacheIfPossible($useCache = true)\n    {\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime   = filemtime($this->pathToImage);\n            $cacheTime  = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                if ($this->useCache) {\n                    if ($this->verbose) {\n                        $this->log(\"Use cached file.\");\n                        $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $this->output($this->cacheFileName, $this->outputFormat);\n                } else {\n                    $this->log(\"Cache is valid but ignoring it by intention.\");\n                }\n            } else {\n                $this->log(\"Original file is modified, ignoring cache.\");\n            }\n        } else {\n            $this->log(\"Cachefile does not exists or ignoring it.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Error message when failing to load somehow corrupt image.\n     *\n     * @return void\n     *\n     */\n    public function failedToLoad()\n    {\n        header(\"HTTP/1.0 404 Not Found\");\n        echo(\"CImage.php says 404: Fatal error when opening image.<br>\");\n\n        switch ($this->fileExtension) {\n            case 'jpg':\n            case 'jpeg':\n                $this->image = imagecreatefromjpeg($this->pathToImage);\n                break;\n\n            case 'gif':\n                $this->image = imagecreatefromgif($this->pathToImage);\n                break;\n\n            case 'png':\n                $this->image = imagecreatefrompng($this->pathToImage);\n                break;\n        }\n\n        exit();\n    }\n\n\n\n    /**\n     * Load image from disk.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     *\n     */\n    public function load($src = null, $dir = null)\n    {\n        if (isset($src)) {\n            $this->setSource($src, $dir);\n        }\n\n        $this->log(\"Opening file as {$this->fileExtension}.\");\n\n        switch ($this->fileExtension) {\n            case 'jpg':\n            case 'jpeg':\n                $this->image = @imagecreatefromjpeg($this->pathToImage);\n                $this->image or $this->failedToLoad();\n                break;\n\n            case 'gif':\n                $this->image = @imagecreatefromgif($this->pathToImage);\n                $this->image or $this->failedToLoad();\n                break;\n\n            case 'png':\n                $this->image = @imagecreatefrompng($this->pathToImage);\n                $this->image or $this->failedToLoad();\n\n                $type = $this->getPngType();\n                $hasFewColors = imagecolorstotal($this->image);\n\n                if ($type == self::PNG_RGB_PALETTE || ($hasFewColors > 0 && $hasFewColors <= 256)) {\n                    if ($this->verbose) {\n                        $this->log(\"Handle this image as a palette image.\");\n                    }\n                    $this->palette = true;\n                }\n                break;\n\n            default:\n                $this->image = false;\n                throw new Exception('No support for this file extension.');\n        }\n\n        if ($this->verbose) {\n            $this->log(\"imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\"imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\"Number of colors in image = \" . $this->colorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\"Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the type of PNG image.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    private function getPngType()\n    {\n        $pngType = ord(file_get_contents($this->pathToImage, false, null, 25, 1));\n\n        switch ($pngType) {\n\n            case self::PNG_GREYSCALE:\n                $this->log(\"PNG is type 0, Greyscale.\");\n                break;\n\n            case self::PNG_RGB:\n                $this->log(\"PNG is type 2, RGB\");\n                break;\n\n            case self::PNG_RGB_PALETTE:\n                $this->log(\"PNG is type 3, RGB with palette\");\n                break;\n\n            case self::PNG_GREYSCALE_ALPHA:\n                $this->Log(\"PNG is type 4, Greyscale with alpha channel\");\n                break;\n\n            case self::PNG_RGB_ALPHA:\n                $this->Log(\"PNG is type 6, RGB with alpha channel (PNG 32-bit)\");\n                break;\n\n            default:\n                $this->Log(\"PNG is UNKNOWN type, is it really a PNG image?\");\n        }\n\n        return $pngType;\n    }\n\n\n\n    /**\n     * Calculate number of colors in an image.\n     *\n     * @param resource $im the image.\n     *\n     * @return int\n     */\n    private function colorsTotal($im)\n    {\n        if (imageistruecolor($im)) {\n            $this->log(\"Colors as true color.\");\n            $h = imagesy($im);\n            $w = imagesx($im);\n            $c = array();\n            for ($x=0; $x < $w; $x++) {\n                for ($y=0; $y < $h; $y++) {\n                    @$c['c'.imagecolorat($im, $x, $y)]++;\n                }\n            }\n            return count($c);\n        } else {\n            $this->log(\"Colors as palette.\");\n            return imagecolorstotal($im);\n        }\n    }\n\n\n\n    /**\n     * Preprocess image before rezising it.\n     *\n     * @return $this\n     */\n    public function preResize()\n    {\n        $this->log(\"Pre-process before resizing\");\n\n        // Rotate image\n        if ($this->rotateBefore) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateBefore, $this->bgColor)\n                 ->reCalculateDimensions();\n        }\n\n        // Auto-rotate image\n        if ($this->autoRotate) {\n            $this->log(\"Auto rotating image.\");\n            $this->rotateExif()\n                 ->reCalculateDimensions();\n        }\n\n        // Scale the original image before starting\n        if (isset($this->scale)) {\n            $this->log(\"Scale by {$this->scale}%\");\n            $newWidth  = $this->width * $this->scale / 100;\n            $newHeight = $this->height * $this->scale / 100;\n            $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);\n            imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);\n            $this->image = $img;\n            $this->width = $newWidth;\n            $this->height = $newHeight;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return $this\n     */\n    public function resize()\n    {\n\n        $this->log(\"Starting to Resize()\");\n        $this->log(\"Upscale = '$this->upscale'\");\n\n        // Only use a specified area of the image, $this->offset is defining the area to use\n        if (isset($this->offset)) {\n\n            $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\");\n            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);\n            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);\n            $this->image = $img;\n            $this->width = $this->offset['width'];\n            $this->height = $this->offset['height'];\n        }\n\n        if ($this->crop) {\n\n            // Do as crop, take only part of image\n            $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\");\n            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);\n            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);\n            $this->image = $img;\n            $this->width = $this->crop['width'];\n            $this->height = $this->crop['height'];\n        }\n\n        if (!$this->upscale) {\n            // Consider rewriting the no-upscale code to fit within this if-statement,\n            // likely to be more readable code.\n            // The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch\n        }\n\n        if ($this->cropToFit) {\n\n            // Resize by crop to fit\n            $this->log(\"Resizing using strategy - Crop to fit\");\n\n            if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight)) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n\n                $posX = 0;\n                $posY = 0;\n\n                if ($this->newWidth > $this->width) {\n                    $posX = round(($this->newWidth - $this->width) / 2);\n                }\n\n                if ($this->newHeight > $this->height) {\n                    $posY = round(($this->newHeight - $this->height) / 2);\n                }\n\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            } else {\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n                $imgPreCrop   = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } else if ($this->fillToFit) {\n\n            // Resize by fill to fit\n            $this->log(\"Resizing using strategy - Fill to fit\");\n\n            $posX = 0;\n            $posY = 0;\n\n            $ratioOrig = $this->width / $this->height;\n            $ratioNew  = $this->newWidth / $this->newHeight;\n\n            // Check ratio for landscape or portrait\n            if ($ratioOrig < $ratioNew) {\n                $posX = round(($this->newWidth - $this->fillWidth) / 2);\n            } else {\n                $posY = round(($this->newHeight - $this->fillHeight) / 2);\n            }\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n                $posX = round(($this->fillWidth - $this->width) / 2);\n                $posY = round(($this->fillHeight - $this->height) / 2);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n\n            } else {\n                $imgPreFill   = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {\n\n            // Resize it\n            $this->log(\"Resizing, new height and/or width\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                if (!$this->keepRatio) {\n                    $this->log(\"Resizing - stretch to fit selected.\");\n\n                    $posX = 0;\n                    $posY = 0;\n                    $cropX = 0;\n                    $cropY = 0;\n\n                    if ($this->newWidth > $this->width && $this->newHeight > $this->height) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                    } else if ($this->newWidth > $this->width) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $cropY = round(($this->height - $this->newHeight) / 2);\n                    } else if ($this->newHeight > $this->height) {\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                        $cropX = round(($this->width - $this->newWidth) / 2);\n                    }\n\n                    //$this->log(\"posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY.\");\n                    $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                    imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight);\n                    $this->image = $imageResized;\n                    $this->width = $this->newWidth;\n                    $this->height = $this->newHeight;\n                }\n            } else {\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopyresampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);\n                $this->image = $imageResized;\n                $this->width = $this->newWidth;\n                $this->height = $this->newHeight;\n            }\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Postprocess image after rezising image.\n     *\n     * @return $this\n     */\n    public function postResize()\n    {\n        $this->log(\"Post-process after resizing\");\n\n        // Rotate image\n        if ($this->rotateAfter) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateAfter, $this->bgColor);\n        }\n\n        // Apply filters\n        if (isset($this->filters) && is_array($this->filters)) {\n\n            foreach ($this->filters as $filter) {\n                $this->log(\"Applying filter {$filter['type']}.\");\n\n                switch ($filter['argc']) {\n\n                    case 0:\n                        imagefilter($this->image, $filter['type']);\n                        break;\n\n                    case 1:\n                        imagefilter($this->image, $filter['type'], $filter['arg1']);\n                        break;\n\n                    case 2:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']);\n                        break;\n\n                    case 3:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']);\n                        break;\n\n                    case 4:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']);\n                        break;\n                }\n            }\n        }\n\n        // Convert to palette image\n        if ($this->palette) {\n            $this->log(\"Converting to palette image.\");\n            $this->trueColorToPalette();\n        }\n\n        // Blur the image\n        if ($this->blur) {\n            $this->log(\"Blur.\");\n            $this->blurImage();\n        }\n\n        // Emboss the image\n        if ($this->emboss) {\n            $this->log(\"Emboss.\");\n            $this->embossImage();\n        }\n\n        // Sharpen the image\n        if ($this->sharpen) {\n            $this->log(\"Sharpen.\");\n            $this->sharpenImage();\n        }\n\n        // Custom convolution\n        if ($this->convolve) {\n            //$this->log(\"Convolve: \" . $this->convolve);\n            $this->imageConvolution();\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using angle.\n     *\n     * @param float $angle        to rotate image.\n     * @param int   $anglebgColor to fill image with if needed.\n     *\n     * @return $this\n     */\n    public function rotate($angle, $bgColor)\n    {\n        $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\");\n\n        $color = $this->getBackgroundColor();\n        $this->image = imagerotate($this->image, $angle, $color);\n\n        $this->width  = imagesx($this->image);\n        $this->height = imagesy($this->image);\n\n        $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using information in EXIF.\n     *\n     * @return $this\n     */\n    public function rotateExif()\n    {\n        if (!in_array($this->fileExtension, array('jpg', 'jpeg'))) {\n            $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\");\n            return $this;\n        }\n\n        $exif = exif_read_data($this->pathToImage);\n\n        if (!empty($exif['Orientation'])) {\n            switch ($exif['Orientation']) {\n                case 3:\n                    $this->log(\"Autorotate 180.\");\n                    $this->rotate(180, $this->bgColor);\n                    break;\n\n                case 6:\n                    $this->log(\"Autorotate -90.\");\n                    $this->rotate(-90, $this->bgColor);\n                    break;\n\n                case 8:\n                    $this->log(\"Autorotate 90.\");\n                    $this->rotate(90, $this->bgColor);\n                    break;\n\n                default:\n                    $this->log(\"Autorotate ignored, unknown value as orientation.\");\n            }\n        } else {\n            $this->log(\"Autorotate ignored, no orientation in EXIF.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert true color image to palette image, keeping alpha.\n     * http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\n     *\n     * @return void\n     */\n    public function trueColorToPalette()\n    {\n        $img = imagecreatetruecolor($this->width, $this->height);\n        $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);\n        imagecolortransparent($img, $bga);\n        imagefill($img, 0, 0, $bga);\n        imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);\n        imagetruecolortopalette($img, false, 255);\n        imagesavealpha($img, true);\n\n        if (imageistruecolor($this->image)) {\n            $this->log(\"Matching colors with true color image.\");\n            imagecolormatch($this->image, $img);\n        }\n\n        $this->image = $img;\n    }\n\n\n\n    /**\n     * Sharpen image using image convolution.\n     *\n     * @return $this\n     */\n    public function sharpenImage()\n    {\n        $this->imageConvolution('sharpen');\n        return $this;\n    }\n\n\n\n    /**\n     * Emboss image using image convolution.\n     *\n     * @return $this\n     */\n    public function embossImage()\n    {\n        $this->imageConvolution('emboss');\n        return $this;\n    }\n\n\n\n    /**\n     * Blur image using image convolution.\n     *\n     * @return $this\n     */\n    public function blurImage()\n    {\n        $this->imageConvolution('blur');\n        return $this;\n    }\n\n\n\n    /**\n     * Create convolve expression and return arguments for image convolution.\n     *\n     * @param string $expression constant string which evaluates to a list of\n     *                           11 numbers separated by komma or such a list.\n     *\n     * @return array as $matrix (3x3), $divisor and $offset\n     */\n    public function createConvolveArguments($expression)\n    {\n        // Check of matching constant\n        if (isset($this->convolves[$expression])) {\n            $expression = $this->convolves[$expression];\n        }\n\n        $part = explode(',', $expression);\n        $this->log(\"Creating convolution expressen: $expression\");\n\n        // Expect list of 11 numbers, split by , and build up arguments\n        if (count($part) != 11) {\n            throw new Exception(\n                \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\"\n            );\n        }\n\n        array_walk($part, function ($item, $key) {\n            if (!is_numeric($item)) {\n                throw new Exception(\"Argument to convolve expression should be float but is not.\");\n            }\n        });\n\n        return array(\n            array(\n                array($part[0], $part[1], $part[2]),\n                array($part[3], $part[4], $part[5]),\n                array($part[6], $part[7], $part[8]),\n            ),\n            $part[9],\n            $part[10],\n        );\n    }\n\n\n\n    /**\n     * Add custom expressions (or overwrite existing) for image convolution.\n     *\n     * @param array $options Key value array with strings to be converted\n     *                       to convolution expressions.\n     *\n     * @return $this\n     */\n    public function addConvolveExpressions($options)\n    {\n        $this->convolves = array_merge($this->convolves, $options);\n        return $this;\n    }\n\n\n\n    /**\n     * Image convolution.\n     *\n     * @param string $options A string with 11 float separated by comma.\n     *\n     * @return $this\n     */\n    public function imageConvolution($options = null)\n    {\n        // Use incoming options or use $this.\n        $options = $options ? $options : $this->convolve;\n\n        // Treat incoming as string, split by +\n        $this->log(\"Convolution with '$options'\");\n        $options = explode(\":\", $options);\n\n        // Check each option if it matches constant value\n        foreach ($options as $option) {\n            list($matrix, $divisor, $offset) = $this->createConvolveArguments($option);\n            imageconvolution($this->image, $matrix, $divisor, $offset);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set default background color between 000000-FFFFFF or if using\n     * alpha 00000000-FFFFFF7F.\n     *\n     * @param string $color as hex value.\n     *\n     * @return $this\n    */\n    public function setDefaultBackgroundColor($color)\n    {\n        $this->log(\"Setting default background color to '$color'.\");\n\n        if (!(strlen($color) == 6 || strlen($color) == 8)) {\n            throw new Exception(\n                \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $red    = hexdec(substr($color, 0, 2));\n        $green  = hexdec(substr($color, 2, 2));\n        $blue   = hexdec(substr($color, 4, 2));\n\n        $alpha = (strlen($color) == 8)\n            ? hexdec(substr($color, 6, 2))\n            : null;\n\n        if (($red < 0 || $red > 255)\n            || ($green < 0 || $green > 255)\n            || ($blue < 0 || $blue > 255)\n            || ($alpha < 0 || $alpha > 127)\n        ) {\n            throw new Exception(\n                \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $this->bgColor = strtolower($color);\n        $this->bgColorDefault = array(\n            'red'   => $red,\n            'green' => $green,\n            'blue'  => $blue,\n            'alpha' => $alpha\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the background color.\n     *\n     * @param resource $img the image to work with or null if using $this->image.\n     *\n     * @return color value or null if no background color is set.\n    */\n    private function getBackgroundColor($img = null)\n    {\n        $img = isset($img) ? $img : $this->image;\n\n        if ($this->bgColorDefault) {\n\n            $red   = $this->bgColorDefault['red'];\n            $green = $this->bgColorDefault['green'];\n            $blue  = $this->bgColorDefault['blue'];\n            $alpha = $this->bgColorDefault['alpha'];\n\n            if ($alpha) {\n                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);\n            } else {\n                $color = imagecolorallocate($img, $red, $green, $blue);\n            }\n\n            return $color;\n\n        } else {\n            return 0;\n        }\n    }\n\n\n\n    /**\n     * Create a image and keep transparency for png and gifs.\n     *\n     * @param int $width of the new image.\n     * @param int $height of the new image.\n     *\n     * @return image resource.\n    */\n    private function createImageKeepTransparency($width, $height)\n    {\n        $this->log(\"Creating a new working image width={$width}px, height={$height}px.\");\n        $img = imagecreatetruecolor($width, $height);\n        imagealphablending($img, false);\n        imagesavealpha($img, true);\n\n        $index = imagecolortransparent($this->image);\n        if ($index != -1) {\n\n            imagealphablending($img, true);\n            $transparent = imagecolorsforindex($this->image, $index);\n            $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']);\n            imagefill($img, 0, 0, $color);\n            $index = imagecolortransparent($img, $color);\n            $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\");\n\n        } elseif ($this->bgColorDefault) {\n\n            $color = $this->getBackgroundColor($img);\n            imagefill($img, 0, 0, $color);\n            $this->Log(\"Filling image with background color.\");\n        }\n\n        return $img;\n    }\n\n\n\n    /**\n     * Set optimizing  and post-processing options.\n     *\n     * @param array $options with config for postprocessing with external tools.\n     *\n     * @return $this\n     */\n    public function setPostProcessingOptions($options)\n    {\n        if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) {\n            $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd'];\n        } else {\n            $this->jpegOptimizeCmd = null;\n        }\n\n        if (isset($options['png_filter']) && $options['png_filter']) {\n            $this->pngFilterCmd = $options['png_filter_cmd'];\n        } else {\n            $this->pngFilterCmd = null;\n        }\n\n        if (isset($options['png_deflate']) && $options['png_deflate']) {\n            $this->pngDeflateCmd = $options['png_deflate_cmd'];\n        } else {\n            $this->pngDeflateCmd = null;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Save image.\n     *\n     * @param string $src  as target filename.\n     * @param string $base as base directory where to store images.\n     *\n     * @return $this or false if no folder is set.\n     */\n    public function save($src = null, $base = null)\n    {\n        if (isset($src)) {\n            $this->setTarget($src, $base);\n        }\n\n        is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n\n        switch(strtolower($this->extension)) {\n\n            case 'jpeg':\n            case 'jpg':\n                $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\");\n                imagejpeg($this->image, $this->cacheFileName, $this->quality);\n\n                // Use JPEG optimize if defined\n                if ($this->jpegOptimizeCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->log($cmd);\n                    $this->log($res);\n                }\n                break;\n\n            case 'gif':\n                $this->Log(\"Saving image as GIF to cache.\");\n                imagegif($this->image, $this->cacheFileName);\n                break;\n\n            case 'png':\n                $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\");\n\n                // Turn off alpha blending and set alpha flag\n                imagealphablending($this->image, false);\n                imagesavealpha($this->image, true);\n                imagepng($this->image, $this->cacheFileName, $this->compress);\n\n                // Use external program to filter PNG, if defined\n                if ($this->pngFilterCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngFilterCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to deflate PNG, if defined\n                if ($this->pngDeflateCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n                break;\n\n            default:\n                $this->RaiseError('No support for this file extension.');\n                break;\n        }\n\n        if ($this->verbose) {\n            clearstatcache();\n            $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n            $this->log(\"imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\"imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\"Number of colors in image = \" . $this->ColorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\"Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Create a hard link, as an alias, to the cached file.\n     *\n     * @param string $alias where to store the link,\n     *                      filename without extension.\n     *\n     * @return $this\n     */\n    public function linkToCacheFile($alias)\n    {\n        if ($alias === null) {\n            $this->log(\"Ignore creating alias.\");\n            return $this;\n        }\n\n        $alias = $alias . \".\" . $this->extension;\n\n        if (is_readable($alias)) {\n            unlink($alias);\n        }\n\n        $res = link($this->cacheFileName, $alias);\n\n        if ($res) {\n            $this->log(\"Created an alias as: $alias\");\n        } else {\n            $this->log(\"Failed to create the alias: $alias\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Output image to browser using caching.\n     *\n     * @param string $file   to read and output, default is to use $this->cacheFileName\n     * @param string $format set to json to output file as json object with details\n     *\n     * @return void\n     */\n    public function output($file = null, $format = null)\n    {\n        if (is_null($file)) {\n            $file = $this->cacheFileName;\n        }\n\n        if (is_null($format)) {\n            $format = $this->outputFormat;\n        }\n\n        $this->log(\"Output format is: $format\");\n\n        if (!$this->verbose && $format == 'json') {\n            header('Content-type: application/json');\n            echo $this->json($file);\n            exit;\n        }\n\n        $this->log(\"Outputting image: $file\");\n\n        // Get image modification time\n        clearstatcache();\n        $lastModified = filemtime($file);\n        $gmdate = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        if (!$this->verbose) {\n            header('Last-Modified: ' . $gmdate . \" GMT\");\n        }\n\n        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {\n\n            if ($this->verbose) {\n                $this->log(\"304 not modified\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            header(\"HTTP/1.0 304 Not Modified\");\n\n        } else {\n\n            if ($this->verbose) {\n                $this->log(\"Last modified: \" . $gmdate . \" GMT\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            // Get details on image\n            $info = getimagesize($file);\n            !empty($info) or $this->raiseError(\"The file doesn't seem to be an image.\");\n            $mime = $info['mime'];\n\n            header('Content-type: ' . $mime);\n            readfile($file);\n        }\n\n        exit;\n    }\n\n\n\n    /**\n     * Create a JSON object from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string json-encoded representation of the image.\n     */\n    public function json($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $details = array();\n\n        clearstatcache();\n\n        $details['src']        = $this->imageSrc;\n        $lastModified          = filemtime($this->pathToImage);\n        $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $details['cache']        = basename($this->cacheFileName);\n        $lastModified            = filemtime($this->cacheFileName);\n        $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $this->loadImageDetails($file);\n\n        $details['filename'] = basename($file);\n        $details['width']  = $this->width;\n        $details['height'] = $this->height;\n        $details['aspectRatio'] = round($this->width / $this->height, 3);\n        $details['size'] = filesize($file);\n\n        $this->load($file);\n        $details['colors'] = $this->colorsTotal($this->image);\n\n        $options = null;\n        if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) {\n            $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;\n        }\n\n        return json_encode($details, $options);\n    }\n\n\n\n    /**\n     * Log an event if verbose mode.\n     *\n     * @param string $message to log.\n     *\n     * @return this\n     */\n    public function log($message)\n    {\n        if ($this->verbose) {\n            $this->log[] = $message;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Do verbose output and print out the log and the actual images.\n     *\n     * @return void\n     */\n    private function verboseOutput()\n    {\n        $log = null;\n        $this->log(\"As JSON: \\n\" . $this->json());\n        $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\");\n        $this->log(\"Memory limit: \" . ini_get('memory_limit'));\n\n        $included = get_included_files();\n        $this->log(\"Included files: \" . count($included));\n\n        foreach ($this->log as $val) {\n            if (is_array($val)) {\n                foreach ($val as $val1) {\n                    $log .= htmlentities($val1) . '<br/>';\n                }\n            } else {\n                $log .= htmlentities($val) . '<br/>';\n            }\n        }\n\n        echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n    }\n\n\n\n    /**\n     * Raise error, enables to implement a selection of error methods.\n     *\n     * @param string $message the error message to display.\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function raiseError($message)\n    {\n        throw new Exception($message);\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n$version = \"v0.7.0 (2015-02-10)\";\n\n\n\n/**\n * Default configuration options, can be overridden in own config-file.\n *\n * @param string $msg to display.\n *\n * @return void\n */\nfunction errorPage($msg)\n{\n    global $mode;\n\n    header(\"HTTP/1.0 500 Internal Server Error\");\n\n    if ($mode == 'development') {\n        die(\"[img.php] $msg\");\n    } else {\n        error_log(\"[img.php] $msg\");\n        die(\"HTTP/1.0 500 Internal Server Error\");\n    }\n}\n\n\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\"<p><b>img.php: Uncaught exception:</b> <p>\" . $exception->getMessage() . \"</p><pre>\" . $exception->getTraceAsString(), \"</pre>\");\n});\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null)\n{\n    global $verbose;\n    static $log = array();\n\n    if (!$verbose) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    $log[] = $msg;\n}\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} else if (!isset($config)) {\n    $config = array();\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\nverbose(\"img.php version = $version\");\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is nod loaded.\");\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n\n} else if ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\");\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} else if (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwdAlways) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n    if (!$passwordMatch) {\n        errorPage(\"Password required and does not match or exists.\");\n    }\n\n} elseif ($pwdConfig && $pwd) {\n\n    $passwordMatch = ($pwdConfig === $pwd);\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer, PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n    } else if ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\");\n    } else if (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\");\n    } else if (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n    } else if (!empty($hotlinkingWhitelist)) {\n\n        $allowedByWhitelist = false;\n        foreach ($hotlinkingWhitelist as $val) {\n            if (preg_match($val, $refererHost)) {\n                $allowedByWhitelist = true;\n            }\n        }\n\n        if (!$allowedByWhitelist) {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist.\");\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\");\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Get the source files.\n */\n$autoloader  = getConfig('autoloader', false);\n$cimageClass = getConfig('cimage_class', false);\n\nif ($autoloader) {\n    require $autoloader;\n} else if ($cimageClass) {\n    require $cimageClass;\n}\n\n\n\n/**\n * Create the class for the image.\n */\n$img = new CImage();\n$img->setVerbose($verbose);\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $pattern);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = get('src')\n    or errorPage('Must set src-attribute.');\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\\.:]+$#');\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Filename contains invalid characters.');\n\nif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n\n} else if ($imagePathConstraint) {\n\n    // Check that the image is a file below the directory 'image_path'.\n    $pathToImage = realpath($imagePath . $srcImage);\n    $imageDir    = realpath($imagePath);\n\n    is_file($pathToImage)\n        or errorPage(\n            'Source image is not a valid file, check the filename and that a\n            matching file exists on the filesystem.'\n        );\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.'\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.');\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.');\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.');\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Hight out of range.');\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range');\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range');\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range');\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range');\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range');\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n * json - output the image as a JSON object with details on the image.\n */\n$outputFormat = getDefined('json', 'json', null);\n\nverbose(\"json = $outputFormat\");\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\");\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.');\n\n} else if ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.');\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio;\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Get the cachepath from config.\n */\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n\n\n\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Fconfig.php.txt",
    "content": "<?php\n// Use error reporting\nerror_reporting(-1);\nini_set('display_errors', 1);\n\n\n// The link to img.php\n$imgphp = \"../img.php?src=\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftemplate.php.txt",
    "content": "<!doctype html>\n<head>\n  <meta charset='utf-8'/>\n  <title><?=$title?></title>\n  <style>\n  body {background-color: #ccc;}\n  </style>\n  <script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\ncolors: \" + data.colors + \"\\nsize: \" + data.size + \"\\nwidth: \" + data.width + \"\\nheigh: \" + data.height + \"\\naspect-ratio: \" + data.aspectRatio;\n  });  \n}\n</script>\n\n</head>\n<body>\n<h1><?=$title?></h1>\n\n<?php if (isset($description)) : ?>\n<p><?=$description?></p>\n<?php endif; ?>\n\n<h2>Images used in test</h2>\n\n<p>The following images are used for this test.</p>\n\n<?php foreach($images as $image) : ?>\n  <p>\n    <code>\n      <a href=\"img/<?=$image?>\"><?=$image?></a> \n      <a href=\"<?=$imgphp . $image . '&json'?>\">(json)</a>\n      <a href=\"<?=$imgphp . $image . '&verbose'?>\">(verbose)</a>\n    </code>\n    <br>\n  <img src=\"<?=$imgphp . $image?>\"></p>\n  <p></p>\n\n<pre id=\"<?=$image?>\"></pre>\n<script type=\"text/javascript\">window.getDetails(\"<?=$imgphp . $image . '&json'?>\", \"<?=$image?>\")</script>\n\n<?php endforeach; ?>\n\n\n\n<h2>Testcases used for each image</h2>\n\n<p>The following testcases are used for each image.</p>\n\n<?php foreach($testcase as $tc) : ?>\n  <code><?=$tc?></code><br>\n<?php endforeach; ?>\n\n\n\n<h2>For each image, apply all testcases</h2>\n\n<?php \n$ch1 = 1;\nforeach($images as $image) :\n?>\n<h3><?=$ch1?>. Using source image <?=$image?></h3>\n\n<p>\n  <code>\n    <a href=\"img/<?=$image?>\"><?=$image?></a> \n    <a href=\"<?=$imgphp . $image . '&json'?>\">(json)</a>\n    <a href=\"<?=$imgphp . $image . '&verbose'?>\">(verbose)</a>\n  </code>\n  <br>\n  <img src=\"<?=$imgphp . $image?>\">\n</p>\n\n<pre id=\"<?=$ch1?>\"></pre>\n<script type=\"text/javascript\">window.getDetails(\"<?=$imgphp . $image . '&json'?>\", \"<?=$ch1?>\")</script>\n\n<?php \n$ch2 = 1;\nforeach($testcase as $tc) : \n$tcId = \"$ch1.$ch2\";\n?>\n<h4>Testcase <?=$tcId?>: <?=$tc?></h4>\n\n<p>\n  <code>\n    <a href=\"<?=$imgphp . $image . $tc?>\"><?=$image . $tc?></a> \n    <a href=\"<?=$imgphp . $image . $tc . '&json'?>\">(json)</a>\n    <a href=\"<?=$imgphp . $image . $tc . '&verbose'?>\">(verbose)</a>\n  </code>\n  <br>\n  <img src=\"<?=$imgphp . $image . $tc?>\">\n</p>\n\n<pre id=\"<?=$tcId?>\"></pre>\n<script type=\"text/javascript\">window.getDetails(\"<?=$imgphp . $image . $tc . '&json'?>\", \"<?=$tcId?>\")</script>\n\n<?php $ch2++; endforeach; ?>\n<?php $ch1++; endforeach; ?>\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest.php.txt",
    "content": "<!doctype html>\n<head>\n  <meta charset='utf-8'/>\n  <title>Testing img resizing using CImage.php</title>\n</head>\n<body>\n<h1>Testing <code>CImage.php</code> through <code>img.php</code></h1>\n\n<h2>Testcases</h2>\n\n<?php\n$testcase = array(\n  array('text'=>'Original image', 'query'=>''),\n  array('text'=>'Crop out a rectangle of 100x100, start by position 200x200.', 'query'=>'&crop=100,100,200,200'),\n  array('text'=>'Crop out a full width rectangle with height of 200, start by position 0x100.', 'query'=>'&crop=0,200,0,100'),\n  array('text'=>'Max width 200.', 'query'=>'&w=200'),\n  array('text'=>'Max height 200.', 'query'=>'&h=200'),\n  array('text'=>'Max width 200 and max height 200.', 'query'=>'&w=200&h=200'),\n  array('text'=>'No-ratio makes image fit in area of width 200 and height 200.', 'query'=>'&w=200&h=200&no-ratio'),\n  array('text'=>'Crop to fit in width 200 and height 200.', 'query'=>'&w=200&h=200&crop-to-fit'),\n  array('text'=>'Crop to fit in width 200 and height 100.', 'query'=>'&w=200&h=100&crop-to-fit'),\n  array('text'=>'Crop to fit in width 100 and height 200.', 'query'=>'&w=100&h=200&crop-to-fit'),\n  array('text'=>'Quality 70', 'query'=>'&w=200&h=200&quality=70'),\n  array('text'=>'Quality 40', 'query'=>'&w=200&h=200&quality=40'),\n  array('text'=>'Quality 10', 'query'=>'&w=200&h=200&quality=10'),\n  array('text'=>'Filter: Negate', 'query'=>'&w=200&h=200&f=negate'),\n  array('text'=>'Filter: Grayscale', 'query'=>'&w=200&h=200&f=grayscale'),\n  array('text'=>'Filter: Brightness 90', 'query'=>'&w=200&h=200&f=brightness,90'),\n  array('text'=>'Filter: Contrast 50', 'query'=>'&w=200&h=200&f=contrast,50'),\n  array('text'=>'Filter: Colorize 0,255,0,0', 'query'=>'&w=200&h=200&f=colorize,0,255,0,0'),\n  array('text'=>'Filter: Edge detect', 'query'=>'&w=200&h=200&f=edgedetect'),\n  array('text'=>'Filter: Emboss', 'query'=>'&w=200&h=200&f=emboss'),\n  array('text'=>'Filter: Gaussian blur', 'query'=>'&w=200&h=200&f=gaussian_blur'),\n  array('text'=>'Filter: Selective blur', 'query'=>'&w=200&h=200&f=selective_blur'),\n  array('text'=>'Filter: Mean removal', 'query'=>'&w=200&h=200&f=mean_removal'),\n  array('text'=>'Filter: Smooth 2', 'query'=>'&w=200&h=200&f=smooth,2'),\n  array('text'=>'Filter: Pixelate 10,10', 'query'=>'&w=200&h=200&f=pixelate,10,10'),\n  array('text'=>'Multiple filter: Negate, Grayscale and Pixelate 10,10', 'query'=>'&w=200&h=200&&f=negate&f0=grayscale&f1=pixelate,10,10'),\n  array('text'=>'Crop with width & height and crop-to-fit with quality and filter', 'query'=>'&crop=100,100,100,100&w=200&h=200&crop-to-fit&q=70&f0=grayscale'),\n);\n?>\n\n<h3>Test case with image <code>wider.jpg</code></h3>\n<table>\n<caption>Test case with image <code>wider.jpg</code></caption>\n<thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>\n<tbody>\n<?php\nforeach($testcase as $key => $val) {\n  $url = \"../img.php?src=wider.jpg{$val['query']}\";\n  echo \"<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>\".htmlentities($url).\"</a></code></td><td><img src='$url' /></td></tr>\";\n}\n?>\n</tbody>\n</table>\n\n<h3>Test case with image <code>higher.jpg</code></h3>\n<table>\n<caption>Test case with image <code>higher.jpg</code></caption>\n<thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>\n<tbody>\n<?php\nforeach($testcase as $key => $val) {\n  $url = \"../img.php?src=higher.jpg{$val['query']}\";\n  echo \"<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>\".htmlentities($url).\"</a></code></td><td><img src='$url' /></td></tr>\";\n}\n?>\n</tbody>\n</table>\n\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue29.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing img for issue 29\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'issue29/400x265.jpg',\n    'issue29/400x268.jpg',\n    'issue29/400x300.jpg',\n    'issue29/465x304.jpg',\n    'issue29/640x273.jpg',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&w=300&cf&q=80&nc',\n    '&w=75&h=75&cf&q=80&nc',\n    '&w=75&h=75&q=80',\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue36_aro.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 36 - autoRotate\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'issue36/me-0.jpg',\n    'issue36/me-90.jpg',\n    'issue36/me-180.jpg',\n    'issue36/me-270.jpg',\n    'issue36/flower-0.jpg',\n    'issue36/flower-90.jpg',\n    'issue36/flower-180.jpg',\n    'issue36/flower-270.jpg',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&aro&nc',\n    '&aro&nc&w=200',\n    '&aro&nc&h=200',\n    '&aro&nc&w=200&h=200&cf',\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue36_rb-ra-180.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 180;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue36_rb-ra-270.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 270;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue36_rb-ra-45.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 45;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue36_rb-ra-90.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 90;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue38.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 38 - fill to fit, together with background colors\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"The issue was to implement fill-to-fit, but it needs some flexibility in how to choose the background color and it also affects rotation of the image (the background color does). So this testcase is both for fill-to-fit and for background color (thereby including a test using rotate).\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim04.png',\n    'apple_trans.gif',\n    'circle_trans.png',\n);\n\n\n\n// For each image, apply these testcases\n$cache =  \"&nc\"; // \"\"; // \"&nc\"\n$testcase = array(\n    \"$cache&w=300&h=300&fill-to-fit\",\n    \"$cache&w=200&h=400&fill-to-fit\",\n    \"$cache&w=300&h=300&fill-to-fit=ff0000\",\n    \"$cache&w=200&h=400&fill-to-fit=ff0000\",\n    \"$cache&w=300&h=300&fill-to-fit=ff00003f\",\n    \"$cache&w=200&h=400&fill-to-fit=ff00003f\",\n    \"$cache&w=200&h=400&fill-to-fit&bgc=ff0000\",\n    \"$cache&w=300&h=300&fill-to-fit&bgc=ff00003f\",\n    \"$cache&w=300&h=300&ra=45\",\n    \"$cache&w=300&h=300&ra=45&bgc=ff0000\",\n    \"$cache&w=300&h=300&ra=45&bgc=ff00003f\",\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue40.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 40 - no ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Showing off how to resize image with and without ratio.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'issue40/source.jpg',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&nc&width=652&height=466',\n    '&nc&width=652&height=466&no-ratio',\n    '&nc&width=652&height=466&crop-to-fit',\n    '&nc&width=652&aspect-ratio=1.4',\n    '&nc&width=652&aspect-ratio=1.4&no-ratio',\n    '&nc&width=652&aspect-ratio=1.4&crop-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue49.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 49 - flexible convolution\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Creating shortcuts to custom convolutions by using configurable list of constant convolutions.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&nc&width=400&convolve=lighten',\n    '&nc&width=400&convolve=darken',\n    '&nc&width=400&convolve=sharpen',\n    '&nc&width=400&convolve=emboss',\n    '&nc&width=400&convolve=blur',\n    '&nc&width=400&convolve=blur:blur',\n    '&nc&width=400&convolve=blur:blur:blur:blur',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue52-cf.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 52 - Fill to fit fails with aspect ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that Fill To Fit resize strategy works with all variants of sizes.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = '&nc'; \n$testcase = array(\n    $nc . '&w=300&h=300&crop-to-fit',\n    $nc . '&w=300&ar=1&crop-to-fit',\n    $nc . '&w=300&ar=3&crop-to-fit',\n    $nc . '&h=300&ar=1&crop-to-fit',\n    $nc . '&h=300&ar=3&crop-to-fit',\n    $nc . '&w=50%&ar=1&crop-to-fit',\n    $nc . '&w=50%&ar=3&crop-to-fit',\n    $nc . '&h=50%&ar=1&crop-to-fit',\n    $nc . '&h=50%&ar=3&crop-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue52-stretch.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 52 - Fill to fit fails with aspect ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that Fill To Fit resize strategy works with all variants of sizes.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = '&nc'; \n$testcase = array(\n    $nc . '&w=300&h=300&stretch',\n    $nc . '&w=300&ar=1&stretch',\n    $nc . '&w=300&ar=3&stretch',\n    $nc . '&h=300&ar=1&stretch',\n    $nc . '&h=300&ar=3&stretch',\n    $nc . '&w=50%&ar=1&stretch',\n    $nc . '&w=50%&ar=3&stretch',\n    $nc . '&h=50%&ar=1&stretch',\n    $nc . '&h=50%&ar=3&stretch',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue52.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 52 - Fill to fit fails with aspect ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that Fill To Fit resize strategy works with all variants of sizes.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = null; //&nc'; \n$testcase = array(\n    $nc . '&w=300&h=300&fill-to-fit',\n    $nc . '&w=300&ar=1&fill-to-fit',\n    $nc . '&w=300&ar=2&fill-to-fit',\n    $nc . '&h=300&ar=1&fill-to-fit',\n    $nc . '&h=300&ar=2&fill-to-fit',\n    $nc . '&w=50%&ar=1&fill-to-fit',\n    $nc . '&w=50%&ar=2&fill-to-fit',\n    $nc . '&h=50%&ar=1&fill-to-fit',\n    $nc . '&h=50%&ar=2&fill-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue58.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 58 - JSON reporting filesize\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that JSON returns filesize of actual image.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&w=300',\n    '&w=300&h=300',\n    '&w=300&h=300&stretch',\n    '&w=300&h=300&crop-to-fit',\n    '&w=300&h=300&fill-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_issue60.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 60  - skip original\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Always use the original if suitable, use skip-original to force using the cached version.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '',\n    '&so',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_option-crop.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing option crop\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Cropping parts of image\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = \"&nc\"; //null; //&nc'; \n$testcase = array(\n    $nc . '&w=300',\n    $nc . '&w=300&crop=0,0,0,0',\n    $nc . '&crop=300,200,0,0',\n    $nc . '&crop=300,200,left,top',\n    $nc . '&crop=300,200,right,top',\n    $nc . '&crop=300,200,right,bottom',\n    $nc . '&crop=300,200,left,bottom',\n    $nc . '&crop=300,200,center,center',\n    $nc . '&crop=200,220,190,300',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_option-no-upscale.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing option no-upscale\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Do not upscale image when original image (slice) is smaller than target image.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = null; //\"&nc\"; //null; //&nc'; \n$testcase = array(\n    $nc . '&w=600',\n    $nc . '&w=600&no-upscale',\n    $nc . '&h=400',\n    $nc . '&h=400&no-upscale',\n    $nc . '&w=600&h=400',\n    $nc . '&w=600&h=400&no-upscale',\n    $nc . '&w=700&h=400&stretch',\n    $nc . '&w=700&h=400&no-upscale&stretch',\n    $nc . '&w=700&h=200&stretch',\n    $nc . '&w=700&h=200&no-upscale&stretch',\n    $nc . '&w=300&h=400&stretch',\n    $nc . '&w=300&h=400&no-upscale&stretch',\n    $nc . '&w=600&h=400&crop-to-fit',\n    $nc . '&w=600&h=400&no-upscale&crop-to-fit',\n    $nc . '&w=600&h=200&crop-to-fit',\n    $nc . '&w=600&h=200&no-upscale&crop-to-fit',\n    $nc . '&w=300&h=400&crop-to-fit',\n    $nc . '&w=300&h=400&no-upscale&crop-to-fit',\n    $nc . '&w=600&h=400&fill-to-fit',\n    $nc . '&w=600&h=400&no-upscale&fill-to-fit',\n/*\n    $nc . '&w=600&ar=1.6',\n    $nc . '&w=600&ar=1.6&no-upscale',\n    $nc . '&h=400&ar=1.6',\n    $nc . '&h=400&ar=1.6&no-upscale',\n*/\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot%2Ftest%2Ftest_option-save-as.php.txt",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing option save-as - save image to another format\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n    'car.gif',\n    'car.jpg',\n    'ball24.png',\n    'wider.jpg',\n);\n\n\n\n// For each image, apply these testcases\n$nc = \"&nc\"; //null; //&nc'; \n$testcase = array(\n    $nc . '&w=300',\n    $nc . '&w=300&sa=jpg',\n    $nc . '&w=300&sa=png',\n    $nc . '&w=300&sa=gif',\n    $nc . '&w=300&palette',\n    $nc . '&w=300&sa=png&palette',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n\n"
  },
  {
    "path": "docs/api/files/webroot.check_system.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-757827638\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-757827638\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot</small>check_system.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/check_system.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.compare.compare-test.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1907041064\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1907041064\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/compare</small>compare-test.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/compare/compare-test.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.compare.compare.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1603660564\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1603660564\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/compare</small>compare.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/compare/compare.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.img.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-543265601\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-543265601\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot</small>img.php</h1>\n                    <p><em>Resize and crop images on the fly, store generated images in a cache.</em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                                                                                    <dt>See also</dt>\n                                                                                        <dd><a href=\"https://github.com/mosbth/cimage\"><div class=\"namespace-wrapper\">https://github.com/mosbth/cimage</div></a></dd>\n                                                    \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr>\n                                <th>\n                                    author\n                                </th>\n                                <td>\n                                                                            <p>Mikael Roos mos@dbwebb.se</p>\n                                                                    </td>\n                            </tr>\n                                                    <tr>\n                                <th>\n                                    example\n                                </th>\n                                <td>\n                                                                            \n                                                                    </td>\n                            </tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n                        <div class=\"row-fluid\">\n                <section class=\"span8 content file\">\n                    <h2>Functions</h2>\n                </section>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_errorPage\" name=\"method_errorPage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">errorPage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">errorPage(string  <span class=\"argument\">$msg</span>) : void</pre>\n                <p><em>Display error message.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to display.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/img.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_get\" name=\"method_get\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">get()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">get(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default = null</span>) : mixed</pre>\n                <p><em>Get input from query string or return default value if not set.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value from $_GET or default value.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/img.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDefined\" name=\"method_getDefined\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getDefined()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDefined(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$defined</span>, mixed  <span class=\"argument\">$undefined</span>) : mixed</pre>\n                <p><em>Get input from query string and set to $defined if defined or else $undefined.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$defined </td>\n                                <td><p>value to return when $key is set in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$undefined </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $defined or $undefined.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/img.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getConfig\" name=\"method_getConfig\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getConfig()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getConfig(string  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default</span>) : mixed</pre>\n                <p><em>Get value from config array or default if key is not set in config array.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$key </td>\n                                <td><p>the key in the config array.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to be default if $key is not set in config.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $config[$key] or $default.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/img.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_verbose\" name=\"method_verbose\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">verbose()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">verbose(string  <span class=\"argument\">$msg = null</span>) : void</pre>\n                <p><em>Log when verbose mode, when used without argument it returns the result.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to log.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/img.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/img.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.img_config.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-112631378\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-112631378\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot</small>img_config.php</h1>\n                    <p><em>Configuration for img.php, name the config file the same as your img.php and\nappend _config. If you are testing out some in imgtest.php then label that\nconfig-file imgtest_config.php.</em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/img_config.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.img_header.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-7868195\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-7868195\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot</small>img_header.php</h1>\n                    <p><em>Resize and crop images on the fly, store generated images in a cache.</em></p>\n                    <p>This version is a all-in-one version of img.php, it is not dependant an any other file\nso you can simply copy it to any place you want it.</p>\n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                                                                                    <dt>See also</dt>\n                                                                                        <dd><a href=\"https://github.com/mosbth/cimage\"><div class=\"namespace-wrapper\">https://github.com/mosbth/cimage</div></a></dd>\n                                                    \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr>\n                                <th>\n                                    author\n                                </th>\n                                <td>\n                                                                            <p>Mikael Roos mos@dbwebb.se</p>\n                                                                    </td>\n                            </tr>\n                                                    <tr>\n                                <th>\n                                    example\n                                </th>\n                                <td>\n                                                                            \n                                                                    </td>\n                            </tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/img_header.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.imgd.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-91016725\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-91016725\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot</small>imgd.php</h1>\n                    <p><em>Resize and crop images on the fly, store generated images in a cache.</em></p>\n                    <p>This version is a all-in-one version of img.php, it is not dependant an any other file\nso you can simply copy it to any place you want it.</p>\n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CHttpGet.html\">CHttpGet</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CImage.html\">CImage</a></td>\n                            <td><em>Resize and crop images on the fly, store generated images in a cache.</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                                                                                    <dt>See also</dt>\n                                                                                        <dd><a href=\"https://github.com/mosbth/cimage\"><div class=\"namespace-wrapper\">https://github.com/mosbth/cimage</div></a></dd>\n                                                    \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr>\n                                <th>\n                                    author\n                                </th>\n                                <td>\n                                                                            <p>Mikael Roos mos@dbwebb.se</p>\n                                                                    </td>\n                            </tr>\n                                                    <tr>\n                                <th>\n                                    example\n                                </th>\n                                <td>\n                                                                            \n                                                                    </td>\n                            </tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n                        <div class=\"row-fluid\">\n                <section class=\"span8 content file\">\n                    <h2>Functions</h2>\n                </section>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_errorPage\" name=\"method_errorPage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">errorPage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">errorPage(string  <span class=\"argument\">$msg</span>) : void</pre>\n                <p><em>Default configuration options, can be overridden in own config-file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to display.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgd.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_get\" name=\"method_get\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">get()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">get(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default = null</span>) : mixed</pre>\n                <p><em>Get input from query string or return default value if not set.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value from $_GET or default value.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgd.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDefined\" name=\"method_getDefined\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getDefined()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDefined(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$defined</span>, mixed  <span class=\"argument\">$undefined</span>) : mixed</pre>\n                <p><em>Get input from query string and set to $defined if defined or else $undefined.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$defined </td>\n                                <td><p>value to return when $key is set in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$undefined </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $defined or $undefined.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgd.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getConfig\" name=\"method_getConfig\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getConfig()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getConfig(string  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default</span>) : mixed</pre>\n                <p><em>Get value from config array or default if key is not set in config array.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$key </td>\n                                <td><p>the key in the config array.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to be default if $key is not set in config.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $config[$key] or $default.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgd.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_verbose\" name=\"method_verbose\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">verbose()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">verbose(string  <span class=\"argument\">$msg = null</span>) : void</pre>\n                <p><em>Log when verbose mode, when used without argument it returns the result.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to log.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgd.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/imgd.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.imgp.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-466042370\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-466042370\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot</small>imgp.php</h1>\n                    <p><em>Resize and crop images on the fly, store generated images in a cache.</em></p>\n                    <p>This version is a all-in-one version of img.php, it is not dependant an any other file\nso you can simply copy it to any place you want it.</p>\n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CHttpGet.html\">CHttpGet</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CImage.html\">CImage</a></td>\n                            <td><em>Resize and crop images on the fly, store generated images in a cache.</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                                                                                    <dt>See also</dt>\n                                                                                        <dd><a href=\"https://github.com/mosbth/cimage\"><div class=\"namespace-wrapper\">https://github.com/mosbth/cimage</div></a></dd>\n                                                    \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr>\n                                <th>\n                                    author\n                                </th>\n                                <td>\n                                                                            <p>Mikael Roos mos@dbwebb.se</p>\n                                                                    </td>\n                            </tr>\n                                                    <tr>\n                                <th>\n                                    example\n                                </th>\n                                <td>\n                                                                            \n                                                                    </td>\n                            </tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n                        <div class=\"row-fluid\">\n                <section class=\"span8 content file\">\n                    <h2>Functions</h2>\n                </section>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_errorPage\" name=\"method_errorPage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">errorPage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">errorPage(string  <span class=\"argument\">$msg</span>) : void</pre>\n                <p><em>Default configuration options, can be overridden in own config-file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to display.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgp.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_get\" name=\"method_get\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">get()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">get(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default = null</span>) : mixed</pre>\n                <p><em>Get input from query string or return default value if not set.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value from $_GET or default value.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgp.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDefined\" name=\"method_getDefined\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getDefined()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDefined(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$defined</span>, mixed  <span class=\"argument\">$undefined</span>) : mixed</pre>\n                <p><em>Get input from query string and set to $defined if defined or else $undefined.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$defined </td>\n                                <td><p>value to return when $key is set in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$undefined </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $defined or $undefined.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgp.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getConfig\" name=\"method_getConfig\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getConfig()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getConfig(string  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default</span>) : mixed</pre>\n                <p><em>Get value from config array or default if key is not set in config array.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$key </td>\n                                <td><p>the key in the config array.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to be default if $key is not set in config.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $config[$key] or $default.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgp.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_verbose\" name=\"method_verbose\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">verbose()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">verbose(string  <span class=\"argument\">$msg = null</span>) : void</pre>\n                <p><em>Log when verbose mode, when used without argument it returns the result.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to log.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgp.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/imgp.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.imgs.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-331213822\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-331213822\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot</small>imgs.php</h1>\n                    <p><em>Resize and crop images on the fly, store generated images in a cache.</em></p>\n                    <p>This version is a all-in-one version of img.php, it is not dependant an any other file\nso you can simply copy it to any place you want it.</p>\n\n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CHttpGet.html\">CHttpGet</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CImage.html\">CImage</a></td>\n                            <td><em>Resize and crop images on the fly, store generated images in a cache.</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                                                                                    <dt>See also</dt>\n                                                                                        <dd><a href=\"https://github.com/mosbth/cimage\"><div class=\"namespace-wrapper\">https://github.com/mosbth/cimage</div></a></dd>\n                                                    \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr>\n                                <th>\n                                    author\n                                </th>\n                                <td>\n                                                                            <p>Mikael Roos mos@dbwebb.se</p>\n                                                                    </td>\n                            </tr>\n                                                    <tr>\n                                <th>\n                                    example\n                                </th>\n                                <td>\n                                                                            \n                                                                    </td>\n                            </tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n                        <div class=\"row-fluid\">\n                <section class=\"span8 content file\">\n                    <h2>Functions</h2>\n                </section>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_errorPage\" name=\"method_errorPage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">errorPage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">errorPage(string  <span class=\"argument\">$msg</span>) : void</pre>\n                <p><em>Default configuration options, can be overridden in own config-file.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to display.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgs.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_get\" name=\"method_get\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">get()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">get(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default = null</span>) : mixed</pre>\n                <p><em>Get input from query string or return default value if not set.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value from $_GET or default value.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgs.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDefined\" name=\"method_getDefined\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getDefined()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDefined(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$defined</span>, mixed  <span class=\"argument\">$undefined</span>) : mixed</pre>\n                <p><em>Get input from query string and set to $defined if defined or else $undefined.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$defined </td>\n                                <td><p>value to return when $key is set in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$undefined </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $defined or $undefined.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgs.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getConfig\" name=\"method_getConfig\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getConfig()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getConfig(string  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default</span>) : mixed</pre>\n                <p><em>Get value from config array or default if key is not set in config array.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$key </td>\n                                <td><p>the key in the config array.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to be default if $key is not set in config.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $config[$key] or $default.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgs.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_verbose\" name=\"method_verbose\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">verbose()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">verbose(string  <span class=\"argument\">$msg = null</span>) : void</pre>\n                <p><em>Log when verbose mode, when used without argument it returns the result.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to log.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\">webroot/imgs.php</div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/imgs.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.config.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-250109129\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-250109129\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>config.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/config.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.template.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1196601751\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1196601751\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>template.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/template.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-875354507\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-875354507\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue29.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-2116914885\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-2116914885\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue29.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue29.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue36_aro.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-2142830909\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-2142830909\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue36_aro.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue36_aro.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue36_rb-ra-180.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1012143278\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1012143278\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue36_rb-ra-180.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue36_rb-ra-180.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue36_rb-ra-270.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-742104745\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-742104745\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue36_rb-ra-270.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue36_rb-ra-270.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue36_rb-ra-45.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1207902275\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1207902275\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue36_rb-ra-45.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue36_rb-ra-45.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue36_rb-ra-90.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-768819546\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-768819546\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue36_rb-ra-90.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue36_rb-ra-90.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue38.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1222660257\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1222660257\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue38.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue38.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue40.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1228093180\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1228093180\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue40.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue40.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue49.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1877350969\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1877350969\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue49.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue49.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue52-cf.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1137104037\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1137104037\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue52-cf.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue52-cf.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue52-stretch.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1431109639\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1431109639\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue52-stretch.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue52-stretch.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue52.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-333419331\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-333419331\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue52.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue52.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue58.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1296658234\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1296658234\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue58.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue58.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_issue60.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-908160725\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-908160725\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_issue60.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_issue60.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_option-crop.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-641842435\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-641842435\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_option-crop.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_option-crop.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_option-no-upscale.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-308733617\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-308733617\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_option-no-upscale.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_option-no-upscale.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/files/webroot.test.test_option-save-as.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script type=\"text/javascript\">\n        function loadExternalCodeSnippets() {\n            Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {\n                var src = pre.getAttribute('data-src');\n                var extension = (src.match(/\\.(\\w+)$/) || [, ''])[1];\n                var language = 'php';\n\n                var code = document.createElement('code');\n                code.className = 'language-' + language;\n\n                pre.textContent = '';\n\n                code.textContent = 'Loading…';\n\n                pre.appendChild(code);\n\n                var xhr = new XMLHttpRequest();\n\n                xhr.open('GET', src, true);\n\n                xhr.onreadystatechange = function () {\n                    if (xhr.readyState == 4) {\n\n                        if (xhr.status < 400 && xhr.responseText) {\n                            code.textContent = xhr.responseText;\n\n                            Prism.highlightElement(code);\n                        }\n                        else if (xhr.status >= 400) {\n                            code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;\n                        }\n                        else {\n                            code.textContent = '✖ Error: File does not exist or is empty';\n                        }\n                    }\n                };\n\n                xhr.send(null);\n            });\n        }\n\n        $(document).ready(function(){\n            loadExternalCodeSnippets();\n        });\n        $('#source-view').on('shown', function () {\n            loadExternalCodeSnippets();\n        })\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">126</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">683</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-130193242\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-130193242\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage_RemoteDownloadTest.html\">CImage_RemoteDownloadTest</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelistTest.html\">CWhitelistTest</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content file\">\n                    <nav>\n                                                                    </nav>\n\n                    <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\"><i class=\"icon-code\"></i></a>\n                    <h1><small>webroot/test</small>test_option-save-as.php</h1>\n                    <p><em></em></p>\n                    \n\n                    \n                    \n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                                                    <dt>Package</dt>\n                            <dd><div class=\"namespace-wrapper\">\\Default</div></dd>\n                        \n                        \n                    </dl>\n                    <h2>Tags</h2>\n                    <table class=\"table table-condensed\">\n                                                    <tr><td colspan=\"2\"><em>None found</em></td></tr>\n                                            </table>\n\n                </aside>\n            </div>\n\n            \n            \n        </div>\n    </section>\n\n    <div id=\"source-view\" class=\"modal hide fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"source-view-label\" aria-hidden=\"true\">\n        <div class=\"modal-header\">\n            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n            <h3 id=\"source-view-label\"></h3>\n        </div>\n        <div class=\"modal-body\">\n            <pre data-src=\"../files/webroot/test/test_option-save-as.php.txt\" class=\"language-php line-numbers\"></pre>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on March 4th, 2015 at 10:43.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/graphs/class.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n        <link href=\"../css/jquery.iviewer.css\" rel=\"stylesheet\" media=\"all\"/>\n    <style>\n        #viewer {\n            position: relative;\n            width: 100%;\n        }\n        .wrapper {\n            overflow: hidden;\n        }\n    </style>\n\n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n        <script src=\"../js/jquery.mousewheel.js\" type=\"text/javascript\"></script>\n    <script src=\"../js/jquery.iviewer.js\" type=\"text/javascript\"></script>\n    <script type=\"text/javascript\">\n        $(window).resize(function(){\n            $(\"#viewer\").height($(window).height() - 100);\n        });\n\n        $(document).ready(function() {\n            $(\"#viewer\").iviewer({src: '../graphs/classes.svg', zoom_animation: false});\n            $('#viewer img').bind('dragstart', function(event){\n                event.preventDefault();\n            });\n            $(window).resize();\n        });\n    </script>\n\n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <div class=\"row-fluid\">\n        <div class=\"span12\">\n            <div class=\"wrapper\">\n                <div id=\"viewer\" class=\"viewer\"></div>\n            </div>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"js/jquery-1.11.0.min.js\"></script>\n    <script src=\"js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"js/bootstrap.min.js\"></script>\n    <script src=\"js/jquery.smooth-scroll.js\"></script>\n    <script src=\"js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    \n    <link rel=\"shortcut icon\" href=\"images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-774114870\"></a>\n                                <a href=\"namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-774114870\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content namespace\">\n                    <nav>\n                                                \n                                            </nav>\n                    <h1><small></small>\\</h1>\n\n                    \n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"classes/CAsciiArt.html\">CAsciiArt</a></td>\n                            <td><em>Create an ASCII version of an image.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"classes/CHttpGet.html\">CHttpGet</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"classes/CImage.html\">CImage</a></td>\n                            <td><em>Resize and crop images on the fly, store generated images in a cache.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"classes/CRemoteImage.html\">CRemoteImage</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"classes/CWhitelist.html\">CWhitelist</a></td>\n                            <td><em>Act as whitelist (or blacklist).</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                        <dt>Namespace hierarchy</dt>\n                        <dd class=\"hierarchy\">\n                                                                                                                                                <div class=\"namespace-wrapper\">\\</div>\n                        </dd>\n                    </dl>\n                </aside>\n            </div>\n\n            \n                        <div class=\"row-fluid\">\n                <section class=\"span8 content namespace\">\n                    <h2>Functions</h2>\n                </section>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_errorPage\" name=\"method_errorPage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">errorPage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">errorPage(string  <span class=\"argument\">$msg</span>) : void</pre>\n                <p><em>Display error message.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to display.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_get\" name=\"method_get\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">get()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">get(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default = null</span>) : mixed</pre>\n                <p><em>Get input from query string or return default value if not set.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value from $_GET or default value.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getConfig\" name=\"method_getConfig\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getConfig()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getConfig(string  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default</span>) : mixed</pre>\n                <p><em>Get value from config array or default if key is not set in config array.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$key </td>\n                                <td><p>the key in the config array.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to be default if $key is not set in config.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $config[$key] or $default.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDefined\" name=\"method_getDefined\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getDefined()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDefined(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$defined</span>, mixed  <span class=\"argument\">$undefined</span>) : mixed</pre>\n                <p><em>Get input from query string and set to $defined if defined or else $undefined.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$defined </td>\n                                <td><p>value to return when $key is set in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$undefined </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $defined or $undefined.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_verbose\" name=\"method_verbose\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">verbose()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">verbose(string  <span class=\"argument\">$msg = null</span>) : void</pre>\n                <p><em>Log when verbose mode, when used without argument it returns the result.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to log.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n        </div>\n    </section>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/js/html5.js",
    "content": "/*\n HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed\n*/\n(function(l,f){function m(){var a=e.elements;return\"string\"==typeof a?a.split(\" \"):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();\na.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function(\"h,f\",\"return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&(\"+m().join().replace(/[\\w\\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c(\"'+a+'\")'})+\");return n}\")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement(\"p\");d=d.getElementsByTagName(\"head\")[0]||d.documentElement;c.innerHTML=\"x<style>article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}</style>\";\nc=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o=\"_html5shiv\",h=0,n={},g;(function(){try{var a=f.createElement(\"a\");a.innerHTML=\"<xyz></xyz>\";j=\"hidden\"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement(\"a\");var c=f.createDocumentFragment();b=\"undefined\"==typeof c.cloneNode||\n\"undefined\"==typeof c.createDocumentFragment||\"undefined\"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||\"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video\",version:\"3.7.0\",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:\"default\",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);\nif(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);\n"
  },
  {
    "path": "docs/api/js/jquery.dotdotdot-1.5.9.js",
    "content": "/*\t\n *\tjQuery dotdotdot 1.5.9\n *\t\n *\tCopyright (c) 2013 Fred Heusschen\n *\twww.frebsite.nl\n *\n *\tPlugin website:\n *\tdotdotdot.frebsite.nl\n *\n *\tDual licensed under the MIT and GPL licenses.\n *\thttp://en.wikipedia.org/wiki/MIT_License\n *\thttp://en.wikipedia.org/wiki/GNU_General_Public_License\n */\n\n(function( $ )\n{\n\tif ( $.fn.dotdotdot )\n\t{\n\t\treturn;\n\t}\n\n\t$.fn.dotdotdot = function( o )\n\t{\n\t\tif ( this.length == 0 )\n\t\t{\n\t\t\tif ( !o || o.debug !== false )\n\t\t\t{\n\t\t\t\tdebug( true, 'No element found for \"' + this.selector + '\".' );\t\t\t\t\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\tif ( this.length > 1 )\n\t\t{\n\t\t\treturn this.each(\n\t\t\t\tfunction()\n\t\t\t\t{\n\t\t\t\t\t$(this).dotdotdot( o );\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\n\t\tvar $dot = this;\n\n\t\tif ( $dot.data( 'dotdotdot' ) )\n\t\t{\n\t\t\t$dot.trigger( 'destroy.dot' );\n\t\t}\n\n\t\t$dot.data( 'dotdotdot-style', $dot.attr( 'style' ) );\n\t\t$dot.css( 'word-wrap', 'break-word' );\n\n\t\t$dot.bind_events = function()\n\t\t{\n\t\t\t$dot.bind(\n\t\t\t\t'update.dot',\n\t\t\t\tfunction( e, c )\n\t\t\t\t{\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\n\t\t\t\t\topts.maxHeight = ( typeof opts.height == 'number' ) \n\t\t\t\t\t\t? opts.height \n\t\t\t\t\t\t: getTrueInnerHeight( $dot );\n\n\t\t\t\t\topts.maxHeight += opts.tolerance;\n\n\t\t\t\t\tif ( typeof c != 'undefined' )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( typeof c == 'string' || c instanceof HTMLElement )\n\t\t\t\t\t\t{\n\t\t\t\t\t \t\tc = $('<div />').append( c ).contents();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( c instanceof $ )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\torgContent = c;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t$inr = $dot.wrapInner( '<div class=\"dotdotdot\" />' ).children();\n\t\t\t\t\t$inr.empty()\n\t\t\t\t\t\t.append( orgContent.clone( true ) )\n\t\t\t\t\t\t.css({\n\t\t\t\t\t\t\t'height'\t: 'auto',\n\t\t\t\t\t\t\t'width'\t\t: 'auto',\n\t\t\t\t\t\t\t'border'\t: 'none',\n\t\t\t\t\t\t\t'padding'\t: 0,\n\t\t\t\t\t\t\t'margin'\t: 0\n\t\t\t\t\t\t});\n\n\t\t\t\t\tvar after = false,\n\t\t\t\t\t\ttrunc = false;\n\n\t\t\t\t\tif ( conf.afterElement )\n\t\t\t\t\t{\n\t\t\t\t\t\tafter = conf.afterElement.clone( true );\n\t\t\t\t\t\tconf.afterElement.remove();\n\t\t\t\t\t}\n\t\t\t\t\tif ( test( $inr, opts ) )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( opts.wrap == 'children' )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttrunc = children( $inr, opts, after );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttrunc = ellipsis( $inr, $dot, $inr, opts, after );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t$inr.replaceWith( $inr.contents() );\n\t\t\t\t\t$inr = null;\n\t\t\t\t\t\n\t\t\t\t\tif ( $.isFunction( opts.callback ) )\n\t\t\t\t\t{\n\t\t\t\t\t\topts.callback.call( $dot[ 0 ], trunc, orgContent );\n\t\t\t\t\t}\n\n\t\t\t\t\tconf.isTruncated = trunc;\n\t\t\t\t\treturn trunc;\n\t\t\t\t}\n\n\t\t\t).bind(\n\t\t\t\t'isTruncated.dot',\n\t\t\t\tfunction( e, fn )\n\t\t\t\t{\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\n\t\t\t\t\tif ( typeof fn == 'function' )\n\t\t\t\t\t{\n\t\t\t\t\t\tfn.call( $dot[ 0 ], conf.isTruncated );\n\t\t\t\t\t}\n\t\t\t\t\treturn conf.isTruncated;\n\t\t\t\t}\n\n\t\t\t).bind(\n\t\t\t\t'originalContent.dot',\n\t\t\t\tfunction( e, fn )\n\t\t\t\t{\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\n\t\t\t\t\tif ( typeof fn == 'function' )\n\t\t\t\t\t{\n\t\t\t\t\t\tfn.call( $dot[ 0 ], orgContent );\n\t\t\t\t\t}\n\t\t\t\t\treturn orgContent;\n\t\t\t\t}\n\n\t\t\t).bind(\n\t\t\t\t'destroy.dot',\n\t\t\t\tfunction( e )\n\t\t\t\t{\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\n\t\t\t\t\t$dot.unwatch()\n\t\t\t\t\t\t.unbind_events()\n\t\t\t\t\t\t.empty()\n\t\t\t\t\t\t.append( orgContent )\n\t\t\t\t\t\t.attr( 'style', $dot.data( 'dotdotdot-style' ) )\n\t\t\t\t\t\t.data( 'dotdotdot', false );\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn $dot;\n\t\t};\t//\t/bind_events\n\n\t\t$dot.unbind_events = function()\n\t\t{\n\t\t\t$dot.unbind('.dot');\n\t\t\treturn $dot;\n\t\t};\t//\t/unbind_events\n\n\t\t$dot.watch = function()\n\t\t{\n\t\t\t$dot.unwatch();\n\t\t\tif ( opts.watch == 'window' )\n\t\t\t{\n\t\t\t\tvar $window = $(window),\n\t\t\t\t\t_wWidth = $window.width(),\n\t\t\t\t\t_wHeight = $window.height(); \n\n\t\t\t\t$window.bind(\n\t\t\t\t\t'resize.dot' + conf.dotId,\n\t\t\t\t\tfunction()\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( _wWidth != $window.width() || _wHeight != $window.height() || !opts.windowResizeFix )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_wWidth = $window.width();\n\t\t\t\t\t\t\t_wHeight = $window.height();\n\t\n\t\t\t\t\t\t\tif ( watchInt )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tclearInterval( watchInt );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twatchInt = setTimeout(\n\t\t\t\t\t\t\t\tfunction()\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t$dot.trigger( 'update.dot' );\n\t\t\t\t\t\t\t\t}, 10\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twatchOrg = getSizes( $dot );\n\t\t\t\twatchInt = setInterval(\n\t\t\t\t\tfunction()\n\t\t\t\t\t{\n\t\t\t\t\t\tvar watchNew = getSizes( $dot );\n\t\t\t\t\t\tif ( watchOrg.width  != watchNew.width ||\n\t\t\t\t\t\t\t watchOrg.height != watchNew.height )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$dot.trigger( 'update.dot' );\n\t\t\t\t\t\t\twatchOrg = getSizes( $dot );\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 100\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn $dot;\n\t\t};\n\t\t$dot.unwatch = function()\n\t\t{\n\t\t\t$(window).unbind( 'resize.dot' + conf.dotId );\n\t\t\tif ( watchInt )\n\t\t\t{\n\t\t\t\tclearInterval( watchInt );\n\t\t\t}\n\t\t\treturn $dot;\n\t\t};\n\n\t\tvar\torgContent\t= $dot.contents(),\n\t\t\topts \t\t= $.extend( true, {}, $.fn.dotdotdot.defaults, o ),\n\t\t\tconf\t\t= {},\n\t\t\twatchOrg\t= {},\n\t\t\twatchInt\t= null,\n\t\t\t$inr\t\t= null;\n\n\t\tconf.afterElement\t= getElement( opts.after, $dot );\n\t\tconf.isTruncated\t= false;\n\t\tconf.dotId\t\t\t= dotId++;\n\n\n\t\t$dot.data( 'dotdotdot', true )\n\t\t\t.bind_events()\n\t\t\t.trigger( 'update.dot' );\n\n\t\tif ( opts.watch )\n\t\t{\n\t\t\t$dot.watch();\n\t\t}\n\n\t\treturn $dot;\n\t};\n\n\n\t//\tpublic\n\t$.fn.dotdotdot.defaults = {\n\t\t'ellipsis'\t: '... ',\n\t\t'wrap'\t\t: 'word',\n\t\t'lastCharacter': {\n\t\t\t'remove'\t\t: [ ' ', ',', ';', '.', '!', '?' ],\n\t\t\t'noEllipsis'\t: []\n\t\t},\n\t\t'tolerance'\t: 0,\n\t\t'callback'\t: null,\n\t\t'after'\t\t: null,\n\t\t'height'\t: null,\n\t\t'watch'\t\t: false,\n\t\t'windowResizeFix': true,\n\t\t'debug'\t\t: false\n\t};\n\t\n\n\t//\tprivate\n\tvar dotId = 1;\n\n\tfunction children( $elem, o, after )\n\t{\n\t\tvar $elements \t= $elem.children(),\n\t\t\tisTruncated\t= false;\n\n\t\t$elem.empty();\n\n\t\tfor ( var a = 0, l = $elements.length; a < l; a++ )\n\t\t{\n\t\t\tvar $e = $elements.eq( a );\n\t\t\t$elem.append( $e );\n\t\t\tif ( after )\n\t\t\t{\n\t\t\t\t$elem.append( after );\n\t\t\t}\n\t\t\tif ( test( $elem, o ) )\n\t\t\t{\n\t\t\t\t$e.remove();\n\t\t\t\tisTruncated = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif ( after )\n\t\t\t\t{\n\t\t\t\t\tafter.remove();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn isTruncated;\n\t}\n\tfunction ellipsis( $elem, $d, $i, o, after )\n\t{\n\t\tvar $elements \t= $elem.contents(),\n\t\t\tisTruncated\t= false;\n\n\t\t$elem.empty();\n\n\t\tvar notx = 'table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, select, optgroup, option, textarea, script, style';\n\t\tfor ( var a = 0, l = $elements.length; a < l; a++ )\n\t\t{\n\n\t\t\tif ( isTruncated )\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tvar e\t= $elements[ a ],\n\t\t\t\t$e\t= $(e);\n\n\t\t\tif ( typeof e == 'undefined' )\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t$elem.append( $e );\n\t\t\tif ( after )\n\t\t\t{\n\t\t\t\t$elem[ ( $elem.is( notx ) ) ? 'after' : 'append' ]( after );\n\t\t\t}\n\t\t\tif ( e.nodeType == 3 )\n\t\t\t{\n\t\t\t\tif ( test( $i, o ) )\n\t\t\t\t{\n\t\t\t\t\tisTruncated = ellipsisElement( $e, $d, $i, o, after );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tisTruncated = ellipsis( $e, $d, $i, o, after );\n\t\t\t}\n\n\t\t\tif ( !isTruncated )\n\t\t\t{\n\t\t\t\tif ( after )\n\t\t\t\t{\n\t\t\t\t\tafter.remove();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn isTruncated;\n\t}\n\tfunction ellipsisElement( $e, $d, $i, o, after )\n\t{\n\t\tvar isTruncated\t= false,\n\t\t\te = $e[ 0 ];\n\n\t\tif ( typeof e == 'undefined' )\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tvar seporator\t= ( o.wrap == 'letter' ) ? '' : ' ',\n\t\t\ttextArr\t\t= getTextContent( e ).split( seporator ),\n\t\t\tposition \t= -1,\n\t\t\tmidPos\t\t= -1,\n\t\t\tstartPos\t= 0,\n\t\t\tendPos\t\t= textArr.length - 1;\n\n\t\twhile ( startPos <= endPos )\n\t\t{\n\t\t\tvar m = Math.floor( ( startPos + endPos ) / 2 );\n\t\t\tif ( m == midPos ) \n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmidPos = m;\n\n\t\t\tsetTextContent( e, textArr.slice( 0, midPos + 1 ).join( seporator ) + o.ellipsis );\n\n\t\t\tif ( !test( $i, o ) )\n\t\t\t{\n\t\t\t\tposition = midPos;\n\t\t\t\tstartPos = midPos; \n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tendPos = midPos;\n\t\t\t}\t\t\t\t\n\t\t}\t\n\t\n\t\tif ( position != -1 && !( textArr.length == 1 && textArr[ 0 ].length == 0 ) )\n\t\t{\n\t\t\tvar txt = addEllipsis( textArr.slice( 0, position + 1 ).join( seporator ), o );\n\t\t\tisTruncated = true;\n\t\t\tsetTextContent( e, txt );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar $w = $e.parent();\n\t\t\t$e.remove();\n\n\t\t\tvar afterLength = ( after ) ? after.length : 0 ;\n\n\t\t\tif ( $w.contents().size() > afterLength )\n\t\t\t{\n\t\t\t\tvar $n = $w.contents().eq( -1 - afterLength );\n\t\t\t\tisTruncated = ellipsisElement( $n, $d, $i, o, after );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar $p = $w.prev()\n\t\t\t\tvar e = $p.contents().eq( -1 )[ 0 ];\n\n\t\t\t\tif ( typeof e != 'undefined' )\n\t\t\t\t{\n\t\t\t\t\tvar txt = addEllipsis( getTextContent( e ), o );\n\t\t\t\t\tsetTextContent( e, txt );\n\t\t\t\t\tif ( after )\n\t\t\t\t\t{\n\t\t\t\t\t\t$p.append( after );\n\t\t\t\t\t}\n\t\t\t\t\t$w.remove();\n\t\t\t\t\tisTruncated = true;\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\n\t\treturn isTruncated;\n\t}\n\tfunction test( $i, o )\n\t{\n\t\treturn $i.innerHeight() > o.maxHeight;\n\t}\n\tfunction addEllipsis( txt, o )\n\t{\n\t\twhile( $.inArray( txt.slice( -1 ), o.lastCharacter.remove ) > -1 )\n\t\t{\n\t\t\ttxt = txt.slice( 0, -1 );\n\t\t}\n\t\tif ( $.inArray( txt.slice( -1 ), o.lastCharacter.noEllipsis ) < 0 )\n\t\t{\n\t\t\ttxt += o.ellipsis;\n\t\t}\n\t\treturn txt;\n\t}\n\tfunction getSizes( $d )\n\t{\n\t\treturn {\n\t\t\t'width'\t: $d.innerWidth(),\n\t\t\t'height': $d.innerHeight()\n\t\t};\n\t}\n\tfunction setTextContent( e, content )\n\t{\n\t\tif ( e.innerText )\n\t\t{\n\t\t\te.innerText = content;\n\t\t}\n\t\telse if ( e.nodeValue )\n\t\t{\n\t\t\te.nodeValue = content;\n\t\t}\n\t\telse if (e.textContent)\n\t\t{\n\t\t\te.textContent = content;\n\t\t}\n\n\t}\n\tfunction getTextContent( e )\n\t{\n\t\tif ( e.innerText )\n\t\t{\n\t\t\treturn e.innerText;\n\t\t}\n\t\telse if ( e.nodeValue )\n\t\t{\n\t\t\treturn e.nodeValue;\n\t\t}\n\t\telse if ( e.textContent )\n\t\t{\n\t\t\treturn e.textContent;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn \"\";\n\t\t}\n\t}\n\tfunction getElement( e, $i )\n\t{\n\t\tif ( typeof e == 'undefined' )\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif ( !e )\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif ( typeof e == 'string' )\n\t\t{\n\t\t\te = $(e, $i);\n\t\t\treturn ( e.length )\n\t\t\t\t? e \n\t\t\t\t: false;\n\t\t}\n\t\tif ( typeof e == 'object' )\n\t\t{\n\t\t\treturn ( typeof e.jquery == 'undefined' )\n\t\t\t\t? false\n\t\t\t\t: e;\n\t\t}\n\t\treturn false;\n\t}\n\tfunction getTrueInnerHeight( $el )\n\t{\n\t\tvar h = $el.innerHeight(),\n\t\t\ta = [ 'paddingTop', 'paddingBottom' ];\n\n\t\tfor ( var z = 0, l = a.length; z < l; z++ ) {\n\t\t\tvar m = parseInt( $el.css( a[ z ] ), 10 );\n\t\t\tif ( isNaN( m ) )\n\t\t\t{\n\t\t\t\tm = 0;\n\t\t\t}\n\t\t\th -= m;\n\t\t}\n\t\treturn h;\n\t}\n\tfunction debug( d, m )\n\t{\n\t\tif ( !d )\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif ( typeof m == 'string' )\n\t\t{\n\t\t\tm = 'dotdotdot: ' + m;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tm = [ 'dotdotdot:', m ];\n\t\t}\n\n\t\tif ( typeof window.console != 'undefined' )\n\t\t{\n\t\t\tif ( typeof window.console.log != 'undefined' )\n\t\t\t{\n\t\t\t\twindow.console.log( m );\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n\n\t//\toverride jQuery.html\n\tvar _orgHtml = $.fn.html;\n    $.fn.html = function( str ) {\n\t\tif ( typeof str != 'undefined' )\n\t\t{\n\t\t\tif ( this.data( 'dotdotdot' ) )\n\t\t\t{\n\t\t\t\tif ( typeof str != 'function' )\n\t\t\t\t{\n\t\t\t\t\treturn this.trigger( 'update', [ str ] );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn _orgHtml.call( this, str );\n\t\t}\n\t\treturn _orgHtml.call( this );\n    };\n\n\n\t//\toverride jQuery.text\n\tvar _orgText = $.fn.text;\n    $.fn.text = function( str ) {\n\t\tif ( typeof str != 'undefined' )\n\t\t{\n\t\t\tif ( this.data( 'dotdotdot' ) )\n\t\t\t{\n\t\t\t\tvar temp = $( '<div />' );\n\t\t\t\ttemp.text( str );\n\t\t\t\tstr = temp.html();\n\t\t\t\ttemp.remove();\n\t\t\t\treturn this.trigger( 'update', [ str ] );\n\t\t\t}\n\t\t\treturn _orgText.call( this, str );\n\t\t}\n        return _orgText.call( this );\n    };\n\n\n})( jQuery );\n"
  },
  {
    "path": "docs/api/js/jquery.iviewer.js",
    "content": "/*\n * iviewer Widget for jQuery UI\n * https://github.com/can3p/iviewer\n *\n * Copyright (c) 2009 - 2012 Dmitry Petrov\n * Dual licensed under the MIT and GPL licenses.\n *  - http://www.opensource.org/licenses/mit-license.php\n *  - http://www.gnu.org/copyleft/gpl.html\n *\n * Author: Dmitry Petrov\n * Version: 0.7.7\n */\n\n( function( $, undefined ) {\n\n//this code was taken from the https://github.com/furf/jquery-ui-touch-punch\nvar mouseEvents = {\n        touchstart: 'mousedown',\n        touchmove: 'mousemove',\n        touchend: 'mouseup'\n    },\n    gesturesSupport = 'ongesturestart' in document.createElement('div');\n\n\n/**\n * Convert a touch event to a mouse-like\n */\nfunction makeMouseEvent (event) {\n    var touch = event.originalEvent.changedTouches[0];\n\n    return $.extend(event, {\n        type:    mouseEvents[event.type],\n        which:   1,\n        pageX:   touch.pageX,\n        pageY:   touch.pageY,\n        screenX: touch.screenX,\n        screenY: touch.screenY,\n        clientX: touch.clientX,\n        clientY: touch.clientY,\n        isTouchEvent: true\n    });\n}\n\nvar mouseProto = $.ui.mouse.prototype,\n    _mouseInit = $.ui.mouse.prototype._mouseInit;\n\nmouseProto._mouseInit = function() {\n    var self = this;\n    self._touchActive = false;\n\n    this.element.bind( 'touchstart.' + this.widgetName, function(event) {\n        if (gesturesSupport && event.originalEvent.touches.length > 1) { return; }\n        self._touchActive = true;\n        return self._mouseDown(makeMouseEvent(event));\n    })\n\n    var self = this;\n    // these delegates are required to keep context\n    this._mouseMoveDelegate = function(event) {\n        if (gesturesSupport && event.originalEvent.touches && event.originalEvent.touches.length > 1) { return; }\n        if (self._touchActive) {\n            return self._mouseMove(makeMouseEvent(event));\n        }\n    };\n    this._mouseUpDelegate = function(event) {\n        if (self._touchActive) {\n            self._touchActive = false;\n            return self._mouseUp(makeMouseEvent(event));\n        }\n    };\n\n    $(document)\n        .bind('touchmove.'+ this.widgetName, this._mouseMoveDelegate)\n        .bind('touchend.' + this.widgetName, this._mouseUpDelegate);\n\n    _mouseInit.apply(this);\n}\n\n/**\n * Simple implementation of jQuery like getters/setters\n * var val = something();\n * something(val);\n */\nvar setter = function(setter, getter) {\n    return function(val) {\n        if (arguments.length === 0) {\n            return getter.apply(this);\n        } else {\n            setter.apply(this, arguments);\n        }\n    }\n};\n\n/**\n * Internet explorer rotates image relative left top corner, so we should\n * shift image when it's rotated.\n */\nvar ieTransforms = {\n        '0': {\n            marginLeft: 0,\n            marginTop: 0,\n            filter: 'progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, SizingMethod=\"auto expand\")'\n        },\n\n        '90': {\n            marginLeft: -1,\n            marginTop: 1,\n            filter: 'progid:DXImageTransform.Microsoft.Matrix(M11=0, M12=-1, M21=1, M22=0, SizingMethod=\"auto expand\")'\n        },\n\n        '180': {\n            marginLeft: 0,\n            marginTop: 0,\n            filter: 'progid:DXImageTransform.Microsoft.Matrix(M11=-1, M12=0, M21=0, M22=-1, SizingMethod=\"auto expand\")'\n        },\n\n        '270': {\n            marginLeft: -1,\n            marginTop: 1,\n            filter: 'progid:DXImageTransform.Microsoft.Matrix(M11=0, M12=1, M21=-1, M22=0, SizingMethod=\"auto expand\")'\n        }\n    },\n    // this test is the inversion of the css filters test from the modernizr project\n    useIeTransforms = function() {\n        var modElem = document.createElement('modernizr'),\n\t\tmStyle = modElem.style,\n\t\tomPrefixes = 'Webkit Moz O ms',\n\t\tdomPrefixes = omPrefixes.toLowerCase().split(' '),\n        \tprops = (\"transform\" + ' ' + domPrefixes.join(\"Transform \") + \"Transform\").split(' ');\n        for ( var i in props ) {\n            var prop = props[i];\n            if ( !$.contains(prop, \"-\") && mStyle[prop] !== undefined ) {\n                return false;\n            }\n        }\n        return true;\n    }();\n\n$.widget( \"ui.iviewer\", $.ui.mouse, {\n    widgetEventPrefix: \"iviewer\",\n    options : {\n        /**\n        * start zoom value for image, not used now\n        * may be equal to \"fit\" to fit image into container or scale in %\n        **/\n        zoom: \"fit\",\n        /**\n        * base value to scale image\n        **/\n        zoom_base: 100,\n        /**\n        * maximum zoom\n        **/\n        zoom_max: 800,\n        /**\n        * minimum zoom\n        **/\n        zoom_min: 25,\n        /**\n        * base of rate multiplier.\n        * zoom is calculated by formula: zoom_base * zoom_delta^rate\n        **/\n        zoom_delta: 1.4,\n        /**\n        * whether the zoom should be animated.\n        */\n        zoom_animation: true,\n        /**\n        * if true plugin doesn't add its own controls\n        **/\n        ui_disabled: false,\n        /**\n         * If false mousewheel will be disabled\n         */\n        mousewheel: true,\n        /**\n        * if false, plugin doesn't bind resize event on window and this must\n        * be handled manually\n        **/\n        update_on_resize: true,\n        /**\n        * event is triggered when zoom value is changed\n        * @param int new zoom value\n        * @return boolean if false zoom action is aborted\n        **/\n        onZoom: jQuery.noop,\n        /**\n        * event is triggered when zoom value is changed after image is set to the new dimensions\n        * @param int new zoom value\n        * @return boolean if false zoom action is aborted\n        **/\n        onAfterZoom: jQuery.noop,\n        /**\n        * event is fired on drag begin\n        * @param object coords mouse coordinates on the image\n        * @return boolean if false is returned, drag action is aborted\n        **/\n        onStartDrag: jQuery.noop,\n        /**\n        * event is fired on drag action\n        * @param object coords mouse coordinates on the image\n        **/\n        onDrag: jQuery.noop,\n        /**\n        * event is fired on drag stop\n        * @param object coords mouse coordinates on the image\n        **/\n        onStopDrag: jQuery.noop,\n        /**\n        * event is fired when mouse moves over image\n        * @param object coords mouse coordinates on the image\n        **/\n        onMouseMove: jQuery.noop,\n        /**\n        * mouse click event\n        * @param object coords mouse coordinates on the image\n        **/\n        onClick: jQuery.noop,\n        /**\n        * event is fired when image starts to load\n        */\n        onStartLoad: null,\n        /**\n        * event is fired, when image is loaded and initially positioned\n        */\n        onFinishLoad: null,\n        /**\n        * event is fired when image load error occurs\n        */\n        onErrorLoad: null\n    },\n\n    _create: function() {\n        var me = this;\n\n        //drag variables\n        this.dx = 0;\n        this.dy = 0;\n\n        /* object containing actual information about image\n        *   @img_object.object - jquery img object\n        *   @img_object.orig_{width|height} - original dimensions\n        *   @img_object.display_{width|height} - actual dimensions\n        */\n        this.img_object = {};\n\n        this.zoom_object = {}; //object to show zoom status\n\n        this._angle = 0;\n\n        this.current_zoom = this.options.zoom;\n\n        if(this.options.src === null){\n            return;\n        }\n\n        this.container = this.element;\n\n        this._updateContainerInfo();\n\n        //init container\n        this.container.css(\"overflow\",\"hidden\");\n\n        if (this.options.update_on_resize == true) {\n            $(window).resize(function() {\n                me.update();\n            });\n        }\n\n        this.img_object = new $.ui.iviewer.ImageObject(this.options.zoom_animation);\n\n        if (this.options.mousewheel) {\n            this.container.bind('mousewheel.iviewer', function(ev, delta)\n                {\n                    //this event is there instead of containing div, because\n                    //at opera it triggers many times on div\n                    var zoom = (delta > 0)?1:-1,\n                        container_offset = me.container.offset(),\n                        mouse_pos = {\n                            //jquery.mousewheel 3.1.0 uses strange MozMousePixelScroll event\n                            //which is not being fixed by jQuery.Event\n                            x: (ev.pageX || ev.originalEvent.pageX) - container_offset.left,\n                            y: (ev.pageY || ev.originalEvent.pageX) - container_offset.top\n                        };\n\n                    me.zoom_by(zoom, mouse_pos);\n                    return false;\n                });\n\n            if (gesturesSupport) {\n                var gestureThrottle = +new Date();\n                var originalScale, originalCenter;\n                this.img_object.object()\n                    // .bind('gesturestart', function(ev) {\n                    .bind('touchstart', function(ev) {\n                        originalScale = me.current_zoom;\n                        var touches = ev.originalEvent.touches,\n                            container_offset;\n                        if (touches.length == 2) {\n                            container_offset = me.container.offset();\n                            originalCenter = {\n                                x: (touches[0].pageX + touches[1].pageX) / 2  - container_offset.left,\n                                y: (touches[0].pageY + touches[1].pageY) / 2 - container_offset.top\n                            };\n                        } else {\n                            originalCenter = null;\n                        }\n                    }).bind('gesturechange', function(ev) {\n                        //do not want to import throttle function from underscore\n                        var d = +new Date();\n                        if ((d - gestureThrottle) < 50) { return; }\n                        gestureThrottle = d;\n                        var zoom = originalScale * ev.originalEvent.scale;\n                        me.set_zoom(zoom, originalCenter);\n                        ev.preventDefault();\n                    }).bind('gestureend', function(ev) {\n                        originalCenter = null;\n                    });\n            }\n        }\n\n        //init object\n        this.img_object.object()\n            //bind mouse events\n            .click(function(e){return me._click(e)})\n                .prependTo(this.container);\n\n        this.container.bind('mousemove', function(ev) { me._handleMouseMove(ev); });\n\n        this.loadImage(this.options.src);\n\n        if(!this.options.ui_disabled)\n        {\n            this.createui();\n        }\n\n        this._mouseInit();\n    },\n\n    destroy: function() {\n        $.Widget.prototype.destroy.call( this );\n        this._mouseDestroy();\n        this.img_object.object().remove();\n        this.container.off('.iviewer');\n        this.container.css('overflow', ''); //cleanup styles on destroy\n    },\n\n    _updateContainerInfo: function()\n    {\n        this.options.height = this.container.height();\n        this.options.width = this.container.width();\n    },\n\n    update: function()\n    {\n        this._updateContainerInfo()\n        this.setCoords(this.img_object.x(), this.img_object.y());\n    },\n\n    loadImage: function( src )\n    {\n        this.current_zoom = this.options.zoom;\n        var me = this;\n\n        this._trigger('onStartLoad', 0, src);\n\n        this.container.addClass(\"iviewer_loading\");\n        this.img_object.load(src, function() {\n            me._imageLoaded(src);\n        }, function() {\n            me._trigger(\"onErrorLoad\", 0, src);\n        });\n    },\n\n    _imageLoaded: function(src) {\n        this.container.removeClass(\"iviewer_loading\");\n        this.container.addClass(\"iviewer_cursor\");\n\n        if(this.options.zoom == \"fit\"){\n            this.fit(true);\n        }\n        else {\n            this.set_zoom(this.options.zoom, true);\n        }\n\n        this._trigger('onFinishLoad', 0, src);\n    },\n\n    /**\n    * fits image in the container\n    *\n    * @param {boolean} skip_animation\n    **/\n    fit: function(skip_animation)\n    {\n        var aspect_ratio = this.img_object.orig_width() / this.img_object.orig_height();\n        var window_ratio = this.options.width /  this.options.height;\n        var choose_left = (aspect_ratio > window_ratio);\n        var new_zoom = 0;\n\n        if(choose_left){\n            new_zoom = this.options.width / this.img_object.orig_width() * 100;\n        }\n        else {\n            new_zoom = this.options.height / this.img_object.orig_height() * 100;\n        }\n\n      this.set_zoom(new_zoom, skip_animation);\n    },\n\n    /**\n    * center image in container\n    **/\n    center: function()\n    {\n        this.setCoords(-Math.round((this.img_object.display_width() - this.options.width)/2),\n                -Math.round((this.img_object.display_height() - this.options.height)/2));\n    },\n\n    /**\n    *   move a point in container to the center of display area\n    *   @param x a point in container\n    *   @param y a point in container\n    **/\n    moveTo: function(x, y)\n    {\n        var dx = x-Math.round(this.options.width/2);\n        var dy = y-Math.round(this.options.height/2);\n\n        var new_x = this.img_object.x() - dx;\n        var new_y = this.img_object.y() - dy;\n\n        this.setCoords(new_x, new_y);\n    },\n\n    /**\n     * Get container offset object.\n     */\n    getContainerOffset: function() {\n        return jQuery.extend({}, this.container.offset());\n    },\n\n    /**\n    * set coordinates of upper left corner of image object\n    **/\n    setCoords: function(x,y)\n    {\n        //do nothing while image is being loaded\n        if(!this.img_object.loaded()) { return; }\n\n        var coords = this._correctCoords(x,y);\n        this.img_object.x(coords.x);\n        this.img_object.y(coords.y);\n    },\n\n    _correctCoords: function( x, y )\n    {\n        x = parseInt(x, 10);\n        y = parseInt(y, 10);\n\n        //check new coordinates to be correct (to be in rect)\n        if(y > 0){\n            y = 0;\n        }\n        if(x > 0){\n            x = 0;\n        }\n        if(y + this.img_object.display_height() < this.options.height){\n            y = this.options.height - this.img_object.display_height();\n        }\n        if(x + this.img_object.display_width() < this.options.width){\n            x = this.options.width - this.img_object.display_width();\n        }\n        if(this.img_object.display_width() <= this.options.width){\n            x = -(this.img_object.display_width() - this.options.width)/2;\n        }\n        if(this.img_object.display_height() <= this.options.height){\n            y = -(this.img_object.display_height() - this.options.height)/2;\n        }\n\n        return { x: x, y:y };\n    },\n\n\n    /**\n    * convert coordinates on the container to the coordinates on the image (in original size)\n    *\n    * @return object with fields x,y according to coordinates or false\n    * if initial coords are not inside image\n    **/\n    containerToImage : function (x,y)\n    {\n        var coords = { x : x - this.img_object.x(),\n                 y :  y - this.img_object.y()\n        };\n\n        coords = this.img_object.toOriginalCoords(coords);\n\n        return { x :  util.descaleValue(coords.x, this.current_zoom),\n                 y :  util.descaleValue(coords.y, this.current_zoom)\n        };\n    },\n\n    /**\n    * convert coordinates on the image (in original size, and zero angle) to the coordinates on the container\n    *\n    * @return object with fields x,y according to coordinates\n    **/\n    imageToContainer : function (x,y)\n    {\n        var coords = {\n                x : util.scaleValue(x, this.current_zoom),\n                y : util.scaleValue(y, this.current_zoom)\n            };\n\n        return this.img_object.toRealCoords(coords);\n    },\n\n    /**\n    * get mouse coordinates on the image\n    * @param e - object containing pageX and pageY fields, e.g. mouse event object\n    *\n    * @return object with fields x,y according to coordinates or false\n    * if initial coords are not inside image\n    **/\n    _getMouseCoords : function(e)\n    {\n        var containerOffset = this.container.offset();\n            coords = this.containerToImage(e.pageX - containerOffset.left, e.pageY - containerOffset.top);\n\n        return coords;\n    },\n\n    /**\n    * set image scale to the new_zoom\n    *\n    * @param {number} new_zoom image scale in %\n    * @param {boolean} skip_animation\n    * @param {x: number, y: number} Coordinates of point the should not be moved on zoom. The default is the center of image.\n    **/\n    set_zoom: function(new_zoom, skip_animation, zoom_center)\n    {\n        if (this._trigger('onZoom', 0, new_zoom) == false) {\n            return;\n        }\n\n        //do nothing while image is being loaded\n        if(!this.img_object.loaded()) { return; }\n\n        zoom_center = zoom_center || {\n            x: Math.round(this.options.width/2),\n            y: Math.round(this.options.height/2)\n        }\n\n        if(new_zoom <  this.options.zoom_min)\n        {\n            new_zoom = this.options.zoom_min;\n        }\n        else if(new_zoom > this.options.zoom_max)\n        {\n            new_zoom = this.options.zoom_max;\n        }\n\n        /* we fake these values to make fit zoom properly work */\n        if(this.current_zoom == \"fit\")\n        {\n            var old_x = zoom_center.x + Math.round(this.img_object.orig_width()/2);\n            var old_y = zoom_center.y + Math.round(this.img_object.orig_height()/2);\n            this.current_zoom = 100;\n        }\n        else {\n            var old_x = -this.img_object.x() + zoom_center.x;\n            var old_y = -this.img_object.y() + zoom_center.y\n        }\n\n        var new_width = util.scaleValue(this.img_object.orig_width(), new_zoom);\n        var new_height = util.scaleValue(this.img_object.orig_height(), new_zoom);\n        var new_x = util.scaleValue( util.descaleValue(old_x, this.current_zoom), new_zoom);\n        var new_y = util.scaleValue( util.descaleValue(old_y, this.current_zoom), new_zoom);\n\n        new_x = zoom_center.x - new_x;\n        new_y = zoom_center.y - new_y;\n\n        new_width = Math.floor(new_width);\n        new_height = Math.floor(new_height);\n        new_x = Math.floor(new_x);\n        new_y = Math.floor(new_y);\n\n        this.img_object.display_width(new_width);\n        this.img_object.display_height(new_height);\n\n        var coords = this._correctCoords( new_x, new_y ),\n            self = this;\n\n        this.img_object.setImageProps(new_width, new_height, coords.x, coords.y,\n                                        skip_animation, function() {\n            self._trigger('onAfterZoom', 0, new_zoom );\n        });\n        this.current_zoom = new_zoom;\n\n        this.update_status();\n    },\n\n    /**\n    * changes zoom scale by delta\n    * zoom is calculated by formula: zoom_base * zoom_delta^rate\n    * @param Integer delta number to add to the current multiplier rate number\n    * @param {x: number, y: number=} Coordinates of point the should not be moved on zoom.\n    **/\n    zoom_by: function(delta, zoom_center)\n    {\n        var closest_rate = this.find_closest_zoom_rate(this.current_zoom);\n\n        var next_rate = closest_rate + delta;\n        var next_zoom = this.options.zoom_base * Math.pow(this.options.zoom_delta, next_rate)\n        if(delta > 0 && next_zoom < this.current_zoom)\n        {\n            next_zoom *= this.options.zoom_delta;\n        }\n\n        if(delta < 0 && next_zoom > this.current_zoom)\n        {\n            next_zoom /= this.options.zoom_delta;\n        }\n\n        this.set_zoom(next_zoom, undefined, zoom_center);\n    },\n\n    /**\n    * Rotate image\n    * @param {num} deg Degrees amount to rotate. Positive values rotate image clockwise.\n    *     Currently 0, 90, 180, 270 and -90, -180, -270 values are supported\n    *\n    * @param {boolean} abs If the flag is true if, the deg parameter will be considered as\n    *     a absolute value and relative otherwise.\n    * @return {num|null} Method will return current image angle if called without any arguments.\n    **/\n    angle: function(deg, abs) {\n        if (arguments.length === 0) { return this.img_object.angle(); }\n\n        if (deg < -270 || deg > 270 || deg % 90 !== 0) { return; }\n        if (!abs) { deg += this.img_object.angle(); }\n        if (deg < 0) { deg += 360; }\n        if (deg >= 360) { deg -= 360; }\n\n        if (deg === this.img_object.angle()) { return; }\n\n        this.img_object.angle(deg);\n        //the rotate behavior is different in all editors. For now we  just center the\n        //image. However, it will be better to try to keep the position.\n        this.center();\n        this._trigger('angle', 0, { angle: this.img_object.angle() });\n    },\n\n    /**\n    * finds closest multiplier rate for value\n    * basing on zoom_base and zoom_delta values from settings\n    * @param Number value zoom value to examine\n    **/\n    find_closest_zoom_rate: function(value)\n    {\n        if(value == this.options.zoom_base)\n        {\n            return 0;\n        }\n\n        function div(val1,val2) { return val1 / val2 };\n        function mul(val1,val2) { return val1 * val2 };\n\n        var func = (value > this.options.zoom_base)?mul:div;\n        var sgn = (value > this.options.zoom_base)?1:-1;\n\n        var mltplr = this.options.zoom_delta;\n        var rate = 1;\n\n        while(Math.abs(func(this.options.zoom_base, Math.pow(mltplr,rate)) - value) >\n              Math.abs(func(this.options.zoom_base, Math.pow(mltplr,rate+1)) - value))\n        {\n            rate++;\n        }\n\n        return sgn * rate;\n    },\n\n    /* update scale info in the container */\n    update_status: function()\n    {\n        if(!this.options.ui_disabled)\n        {\n            var percent = Math.round(100*this.img_object.display_height()/this.img_object.orig_height());\n            if(percent)\n            {\n                this.zoom_object.html(percent + \"%\");\n            }\n        }\n    },\n\n    /**\n     * Get some information about the image.\n     *     Currently orig_(width|height), display_(width|height), angle, zoom and src params are supported.\n     *\n     *  @param {string} parameter to check\n     *  @param {boolean} withoutRotation if param is orig_width or orig_height and this flag is set to true,\n     *      method will return original image width without considering rotation.\n     *\n     */\n    info: function(param, withoutRotation) {\n        if (!param) { return; }\n\n        switch (param) {\n            case 'orig_width':\n            case 'orig_height':\n                if (withoutRotation) {\n                    return (this.img_object.angle() % 180 === 0 ? this.img_object[param]() :\n                            param === 'orig_width' ? this.img_object.orig_height() :\n                                                        this.img_object.orig_width());\n                } else {\n                    return this.img_object[param]();\n                }\n            case 'display_width':\n            case 'display_height':\n            case 'angle':\n                return this.img_object[param]();\n            case 'zoom':\n                return this.current_zoom;\n            case 'src':\n                return this.img_object.object().attr('src');\n            case 'coords':\n                return {\n                    x: this.img_object.x(),\n                    y: this.img_object.y()\n                };\n        }\n    },\n\n    /**\n    *   callback for handling mousdown event to start dragging image\n    **/\n    _mouseStart: function( e )\n    {\n        $.ui.mouse.prototype._mouseStart.call(this, e);\n        if (this._trigger('onStartDrag', 0, this._getMouseCoords(e)) === false) {\n            return false;\n        }\n\n        /* start drag event*/\n        this.container.addClass(\"iviewer_drag_cursor\");\n\n        //#10: fix movement quirks for ipad\n        this._dragInitialized = !(e.originalEvent.changedTouches && e.originalEvent.changedTouches.length==1);\n\n        this.dx = e.pageX - this.img_object.x();\n        this.dy = e.pageY - this.img_object.y();\n        return true;\n    },\n\n    _mouseCapture: function( e ) {\n        return true;\n    },\n\n    /**\n     * Handle mouse move if needed. User can avoid using this callback, because\n     *    he can get the same information through public methods.\n     *  @param {jQuery.Event} e\n     */\n    _handleMouseMove: function(e) {\n        this._trigger('onMouseMove', e, this._getMouseCoords(e));\n    },\n\n    /**\n    *   callback for handling mousemove event to drag image\n    **/\n    _mouseDrag: function(e)\n    {\n        $.ui.mouse.prototype._mouseDrag.call(this, e);\n\n        //#10: imitate mouseStart, because we can get here without it on iPad for some reason\n        if (!this._dragInitialized) {\n            this.dx = e.pageX - this.img_object.x();\n            this.dy = e.pageY - this.img_object.y();\n            this._dragInitialized = true;\n        }\n\n        var ltop =  e.pageY - this.dy;\n        var lleft = e.pageX - this.dx;\n\n        this.setCoords(lleft, ltop);\n        this._trigger('onDrag', e, this._getMouseCoords(e));\n        return false;\n    },\n\n    /**\n    *   callback for handling stop drag\n    **/\n    _mouseStop: function(e)\n    {\n        $.ui.mouse.prototype._mouseStop.call(this, e);\n        this.container.removeClass(\"iviewer_drag_cursor\");\n        this._trigger('onStopDrag', 0, this._getMouseCoords(e));\n    },\n\n    _click: function(e)\n    {\n        this._trigger('onClick', 0, this._getMouseCoords(e));\n    },\n\n    /**\n    *   create zoom buttons info box\n    **/\n    createui: function()\n    {\n        var me=this;\n\n        $(\"<div>\", { 'class': \"iviewer_zoom_in iviewer_common iviewer_button\"})\n                    .bind('mousedown touchstart',function(){me.zoom_by(1); return false;})\n                    .appendTo(this.container);\n\n        $(\"<div>\", { 'class': \"iviewer_zoom_out iviewer_common iviewer_button\"})\n                    .bind('mousedown touchstart',function(){me.zoom_by(- 1); return false;})\n                    .appendTo(this.container);\n\n        $(\"<div>\", { 'class': \"iviewer_zoom_zero iviewer_common iviewer_button\"})\n                    .bind('mousedown touchstart',function(){me.set_zoom(100); return false;})\n                    .appendTo(this.container);\n\n        $(\"<div>\", { 'class': \"iviewer_zoom_fit iviewer_common iviewer_button\"})\n                    .bind('mousedown touchstart',function(){me.fit(this); return false;})\n                    .appendTo(this.container);\n\n        this.zoom_object = $(\"<div>\").addClass(\"iviewer_zoom_status iviewer_common\")\n                                    .appendTo(this.container);\n\n        $(\"<div>\", { 'class': \"iviewer_rotate_left iviewer_common iviewer_button\"})\n                    .bind('mousedown touchstart',function(){me.angle(-90); return false;})\n                    .appendTo(this.container);\n\n        $(\"<div>\", { 'class': \"iviewer_rotate_right iviewer_common iviewer_button\" })\n                    .bind('mousedown touchstart',function(){me.angle(90); return false;})\n                    .appendTo(this.container);\n\n        this.update_status(); //initial status update\n    }\n\n} );\n\n/**\n * @class $.ui.iviewer.ImageObject Class represents image and provides public api without\n *     extending image prototype.\n * @constructor\n * @param {boolean} do_anim Do we want to animate image on dimension changes?\n */\n$.ui.iviewer.ImageObject = function(do_anim) {\n    this._img = $(\"<img>\")\n            //this is needed, because chromium sets them auto otherwise\n            .css({ position: \"absolute\", top :\"0px\", left: \"0px\"});\n\n    this._loaded = false;\n    this._swapDimensions = false;\n    this._do_anim = do_anim || false;\n    this.x(0, true);\n    this.y(0, true);\n    this.angle(0);\n};\n\n\n/** @lends $.ui.iviewer.ImageObject.prototype */\n(function() {\n    /**\n     * Restore initial object state.\n     *\n     * @param {number} w Image width.\n     * @param {number} h Image height.\n     */\n    this._reset = function(w, h) {\n        this._angle = 0;\n        this._swapDimensions = false;\n        this.x(0);\n        this.y(0);\n\n        this.orig_width(w);\n        this.orig_height(h);\n        this.display_width(w);\n        this.display_height(h);\n    };\n\n    /**\n     * Check if image is loaded.\n     *\n     * @return {boolean}\n     */\n    this.loaded = function() { return this._loaded; };\n\n    /**\n     * Load image.\n     *\n     * @param {string} src Image url.\n     * @param {Function=} loaded Function will be called on image load.\n     */\n    this.load = function(src, loaded, error) {\n        var self = this;\n\n        loaded = loaded || jQuery.noop;\n        this._loaded = false;\n\n        //If we assign new image url to the this._img IE9 fires onload event and image width and\n        //height are set to zero. So, we create another image object and load image through it.\n        var img = new Image();\n        img.onload = function() {\n            self._loaded = true;\n            self._reset(this.width, this.height);\n\n            self._img\n                .removeAttr(\"width\")\n                .removeAttr(\"height\")\n                .removeAttr(\"style\")\n                //max-width is reset, because plugin breaks in the twitter bootstrap otherwise\n                .css({ position: \"absolute\", top :\"0px\", left: \"0px\", maxWidth: \"none\"})\n\n            self._img[0].src = src;\n            loaded();\n        };\n\n        img.onerror = error;\n\n        //we need this because sometimes internet explorer 8 fires onload event\n        //right after assignment (synchronously)\n        setTimeout(function() {\n            img.src = src;\n        }, 0);\n\n        this.angle(0);\n    };\n\n    this._dimension = function(prefix, name) {\n        var horiz = '_' + prefix + '_' + name,\n            vert = '_' + prefix + '_' + (name === 'height' ? 'width' : 'height');\n        return setter(function(val) {\n                this[this._swapDimensions ? horiz: vert] = val;\n            },\n            function() {\n                return this[this._swapDimensions ? horiz: vert];\n            });\n    };\n\n    /**\n     * Getters and setter for common image dimensions.\n     *    display_ means real image tag dimensions\n     *    orig_ means physical image dimensions.\n     *  Note, that dimensions are swapped if image is rotated. It necessary,\n     *  because as little as possible code should know about rotation.\n     */\n    this.display_width = this._dimension('display', 'width'),\n    this.display_height = this._dimension('display', 'height'),\n    this.display_diff = function() { return Math.floor( this.display_width() - this.display_height() ) };\n    this.orig_width = this._dimension('orig', 'width'),\n    this.orig_height = this._dimension('orig', 'height'),\n\n    /**\n     * Setter for  X coordinate. If image is rotated we need to additionaly shift an\n     *     image to map image coordinate to the visual position.\n     *\n     * @param {number} val Coordinate value.\n     * @param {boolean} skipCss If true, we only set the value and do not touch the dom.\n     */\n    this.x = setter(function(val, skipCss) {\n            this._x = val;\n            if (!skipCss) {\n                this._finishAnimation();\n                this._img.css(\"left\",this._x + (this._swapDimensions ? this.display_diff() / 2 : 0) + \"px\");\n            }\n        },\n        function() {\n            return this._x;\n        });\n\n    /**\n     * Setter for  Y coordinate. If image is rotated we need to additionaly shift an\n     *     image to map image coordinate to the visual position.\n     *\n     * @param {number} val Coordinate value.\n     * @param {boolean} skipCss If true, we only set the value and do not touch the dom.\n     */\n    this.y = setter(function(val, skipCss) {\n            this._y = val;\n            if (!skipCss) {\n                this._finishAnimation();\n                this._img.css(\"top\",this._y - (this._swapDimensions ? this.display_diff() / 2 : 0) + \"px\");\n            }\n        },\n       function() {\n            return this._y;\n       });\n\n    /**\n     * Perform image rotation.\n     *\n     * @param {number} deg Absolute image angle. The method will work with values 0, 90, 180, 270 degrees.\n     */\n    this.angle = setter(function(deg) {\n            var prevSwap = this._swapDimensions;\n\n            this._angle = deg;\n            this._swapDimensions = deg % 180 !== 0;\n\n            if (prevSwap !== this._swapDimensions) {\n                var verticalMod = this._swapDimensions ? -1 : 1;\n                this.x(this.x() - verticalMod * this.display_diff() / 2, true);\n                this.y(this.y() + verticalMod * this.display_diff() / 2, true);\n            };\n\n            var cssVal = 'rotate(' + deg + 'deg)',\n                img = this._img;\n\n            jQuery.each(['', '-webkit-', '-moz-', '-o-', '-ms-'], function(i, prefix) {\n                img.css(prefix + 'transform', cssVal);\n            });\n\n            if (useIeTransforms) {\n                jQuery.each(['-ms-', ''], function(i, prefix) {\n                    img.css(prefix + 'filter', ieTransforms[deg].filter);\n                });\n\n                img.css({\n                    marginLeft: ieTransforms[deg].marginLeft * this.display_diff() / 2,\n                    marginTop: ieTransforms[deg].marginTop * this.display_diff() / 2\n                });\n            }\n        },\n       function() { return this._angle; });\n\n    /**\n     * Map point in the container coordinates to the point in image coordinates.\n     *     You will get coordinates of point on image with respect to rotation,\n     *     but will be set as if image was not rotated.\n     *     So, if image was rotated 90 degrees, it's (0,0) point will be on the\n     *     top right corner.\n     *\n     * @param {{x: number, y: number}} point Point in container coordinates.\n     * @return  {{x: number, y: number}}\n     */\n    this.toOriginalCoords = function(point) {\n        switch (this.angle()) {\n            case 0: return { x: point.x, y: point.y }\n            case 90: return { x: point.y, y: this.display_width() - point.x }\n            case 180: return { x: this.display_width() - point.x, y: this.display_height() - point.y }\n            case 270: return { x: this.display_height() - point.y, y: point.x }\n        }\n    };\n\n    /**\n     * Map point in the image coordinates to the point in container coordinates.\n     *     You will get coordinates of point on container with respect to rotation.\n     *     Note, if image was rotated 90 degrees, it's (0,0) point will be on the\n     *     top right corner.\n     *\n     * @param {{x: number, y: number}} point Point in container coordinates.\n     * @return  {{x: number, y: number}}\n     */\n    this.toRealCoords = function(point) {\n        switch (this.angle()) {\n            case 0: return { x: this.x() + point.x, y: this.y() + point.y }\n            case 90: return { x: this.x() + this.display_width() - point.y, y: this.y() + point.x}\n            case 180: return { x: this.x() + this.display_width() - point.x, y: this.y() + this.display_height() - point.y}\n            case 270: return { x: this.x() + point.y, y: this.y() + this.display_height() - point.x}\n        }\n    };\n\n    /**\n     * @return {jQuery} Return image node. this is needed to add event handlers.\n     */\n    this.object = setter(jQuery.noop,\n                           function() { return this._img; });\n\n    /**\n     * Change image properties.\n     *\n     * @param {number} disp_w Display width;\n     * @param {number} disp_h Display height;\n     * @param {number} x\n     * @param {number} y\n     * @param {boolean} skip_animation If true, the animation will be skiped despite the\n     *     value set in constructor.\n     * @param {Function=} complete Call back will be fired when zoom will be complete.\n     */\n    this.setImageProps = function(disp_w, disp_h, x, y, skip_animation, complete) {\n        complete = complete || jQuery.noop;\n\n        this.display_width(disp_w);\n        this.display_height(disp_h);\n        this.x(x, true);\n        this.y(y, true);\n\n        var w = this._swapDimensions ? disp_h : disp_w;\n        var h = this._swapDimensions ? disp_w : disp_h;\n\n        var params = {\n            width: w,\n            height: h,\n            top: y - (this._swapDimensions ? this.display_diff() / 2 : 0) + \"px\",\n            left: x + (this._swapDimensions ? this.display_diff() / 2 : 0) + \"px\"\n        };\n\n        if (useIeTransforms) {\n            jQuery.extend(params, {\n                marginLeft: ieTransforms[this.angle()].marginLeft * this.display_diff() / 2,\n                marginTop: ieTransforms[this.angle()].marginTop * this.display_diff() / 2\n            });\n        }\n\n        var swapDims = this._swapDimensions,\n            img = this._img;\n\n        //here we come: another IE oddness. If image is rotated 90 degrees with a filter, than\n        //width and height getters return real width and height of rotated image. The bad news\n        //is that to set height you need to set a width and vice versa. Fuck IE.\n        //So, in this case we have to animate width and height manually.\n        if(useIeTransforms && swapDims) {\n            var ieh = this._img.width(),\n                iew = this._img.height(),\n                iedh = params.height - ieh;\n                iedw = params.width - iew;\n\n            delete params.width;\n            delete params.height;\n        }\n\n        if (this._do_anim && !skip_animation) {\n            this._img.stop(true)\n                .animate(params, {\n                    duration: 200,\n                    complete: complete,\n                    step: function(now, fx) {\n                        if(useIeTransforms && swapDims && (fx.prop === 'top')) {\n                            var percent = (now - fx.start) / (fx.end - fx.start);\n\n                            img.height(ieh + iedh * percent);\n                            img.width(iew + iedw * percent);\n                            img.css('top', now);\n                        }\n                    }\n                });\n        } else {\n            this._img.css(params);\n            setTimeout(complete, 0); //both if branches should behave equally.\n        }\n    };\n\n    //if we set image coordinates we need to be sure that no animation is active atm\n    this._finishAnimation = function() {\n      this._img.stop(true, true);\n    }\n\n}).apply($.ui.iviewer.ImageObject.prototype);\n\n\n\nvar util = {\n    scaleValue: function(value, toZoom)\n    {\n        return value * toZoom / 100;\n    },\n\n    descaleValue: function(value, fromZoom)\n    {\n        return value * 100 / fromZoom;\n    }\n};\n\n } )( jQuery, undefined );\n"
  },
  {
    "path": "docs/api/js/jquery.mousewheel.js",
    "content": "/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)\n * Licensed under the MIT License (LICENSE.txt).\n *\n * Version: 3.1.9\n *\n * Requires: jQuery 1.2.2+\n */\n\n(function (factory) {\n    if ( typeof define === 'function' && define.amd ) {\n        // AMD. Register as an anonymous module.\n        define(['jquery'], factory);\n    } else if (typeof exports === 'object') {\n        // Node/CommonJS style for Browserify\n        module.exports = factory;\n    } else {\n        // Browser globals\n        factory(jQuery);\n    }\n}(function ($) {\n\n    var toFix  = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],\n        toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?\n                    ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],\n        slice  = Array.prototype.slice,\n        nullLowestDeltaTimeout, lowestDelta;\n\n    if ( $.event.fixHooks ) {\n        for ( var i = toFix.length; i; ) {\n            $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;\n        }\n    }\n\n    var special = $.event.special.mousewheel = {\n        version: '3.1.9',\n\n        setup: function() {\n            if ( this.addEventListener ) {\n                for ( var i = toBind.length; i; ) {\n                    this.addEventListener( toBind[--i], handler, false );\n                }\n            } else {\n                this.onmousewheel = handler;\n            }\n            // Store the line height and page height for this particular element\n            $.data(this, 'mousewheel-line-height', special.getLineHeight(this));\n            $.data(this, 'mousewheel-page-height', special.getPageHeight(this));\n        },\n\n        teardown: function() {\n            if ( this.removeEventListener ) {\n                for ( var i = toBind.length; i; ) {\n                    this.removeEventListener( toBind[--i], handler, false );\n                }\n            } else {\n                this.onmousewheel = null;\n            }\n        },\n\n        getLineHeight: function(elem) {\n            return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);\n        },\n\n        getPageHeight: function(elem) {\n            return $(elem).height();\n        },\n\n        settings: {\n            adjustOldDeltas: true\n        }\n    };\n\n    $.fn.extend({\n        mousewheel: function(fn) {\n            return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');\n        },\n\n        unmousewheel: function(fn) {\n            return this.unbind('mousewheel', fn);\n        }\n    });\n\n\n    function handler(event) {\n        var orgEvent   = event || window.event,\n            args       = slice.call(arguments, 1),\n            delta      = 0,\n            deltaX     = 0,\n            deltaY     = 0,\n            absDelta   = 0;\n        event = $.event.fix(orgEvent);\n        event.type = 'mousewheel';\n\n        // Old school scrollwheel delta\n        if ( 'detail'      in orgEvent ) { deltaY = orgEvent.detail * -1;      }\n        if ( 'wheelDelta'  in orgEvent ) { deltaY = orgEvent.wheelDelta;       }\n        if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY;      }\n        if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }\n\n        // Firefox < 17 horizontal scrolling related to DOMMouseScroll event\n        if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {\n            deltaX = deltaY * -1;\n            deltaY = 0;\n        }\n\n        // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy\n        delta = deltaY === 0 ? deltaX : deltaY;\n\n        // New school wheel delta (wheel event)\n        if ( 'deltaY' in orgEvent ) {\n            deltaY = orgEvent.deltaY * -1;\n            delta  = deltaY;\n        }\n        if ( 'deltaX' in orgEvent ) {\n            deltaX = orgEvent.deltaX;\n            if ( deltaY === 0 ) { delta  = deltaX * -1; }\n        }\n\n        // No change actually happened, no reason to go any further\n        if ( deltaY === 0 && deltaX === 0 ) { return; }\n\n        // Need to convert lines and pages to pixels if we aren't already in pixels\n        // There are three delta modes:\n        //   * deltaMode 0 is by pixels, nothing to do\n        //   * deltaMode 1 is by lines\n        //   * deltaMode 2 is by pages\n        if ( orgEvent.deltaMode === 1 ) {\n            var lineHeight = $.data(this, 'mousewheel-line-height');\n            delta  *= lineHeight;\n            deltaY *= lineHeight;\n            deltaX *= lineHeight;\n        } else if ( orgEvent.deltaMode === 2 ) {\n            var pageHeight = $.data(this, 'mousewheel-page-height');\n            delta  *= pageHeight;\n            deltaY *= pageHeight;\n            deltaX *= pageHeight;\n        }\n\n        // Store lowest absolute delta to normalize the delta values\n        absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );\n\n        if ( !lowestDelta || absDelta < lowestDelta ) {\n            lowestDelta = absDelta;\n\n            // Adjust older deltas if necessary\n            if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {\n                lowestDelta /= 40;\n            }\n        }\n\n        // Adjust older deltas if necessary\n        if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {\n            // Divide all the things by 40!\n            delta  /= 40;\n            deltaX /= 40;\n            deltaY /= 40;\n        }\n\n        // Get a whole, normalized value for the deltas\n        delta  = Math[ delta  >= 1 ? 'floor' : 'ceil' ](delta  / lowestDelta);\n        deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);\n        deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);\n\n        // Add information to the event object\n        event.deltaX = deltaX;\n        event.deltaY = deltaY;\n        event.deltaFactor = lowestDelta;\n        // Go ahead and set deltaMode to 0 since we converted to pixels\n        // Although this is a little odd since we overwrite the deltaX/Y\n        // properties with normalized deltas.\n        event.deltaMode = 0;\n\n        // Add event and delta to the front of the arguments\n        args.unshift(event, delta, deltaX, deltaY);\n\n        // Clearout lowestDelta after sometime to better\n        // handle multiple device types that give different\n        // a different lowestDelta\n        // Ex: trackpad = 3 and mouse wheel = 120\n        if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }\n        nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);\n\n        return ($.event.dispatch || $.event.handle).apply(this, args);\n    }\n\n    function nullLowestDelta() {\n        lowestDelta = null;\n    }\n\n    function shouldAdjustOldDeltas(orgEvent, absDelta) {\n        // If this is an older event and the delta is divisable by 120,\n        // then we are assuming that the browser is treating this as an\n        // older mouse wheel event and that we should divide the deltas\n        // by 40 to try and get a more usable deltaFactor.\n        // Side note, this actually impacts the reported scroll distance\n        // in older browsers and can cause scrolling to be slower than native.\n        // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.\n        return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;\n    }\n\n}));\n"
  },
  {
    "path": "docs/api/js/jquery.smooth-scroll.js",
    "content": "$(document).ready(function() {\n    function filterPath(string) {\n        return string\n            .replace(/^\\//,'')\n            .replace(/(index|default).[a-zA-Z]{3,4}$/,'')\n            .replace(/\\/$/,'');\n    }\n    var locationPath = filterPath(location.pathname);\n\n    $('a[href*=#]').each(function() {\n        var thisPath = filterPath(this.pathname) || locationPath;\n        if (  locationPath == thisPath\n            && (location.hostname == this.hostname || !this.hostname)\n            && this.hash.replace(/#/,'') ) {\n            var $target = $(this.hash), target = this.hash;\n            if (target) {\n                $(this).click(function(event) {\n                    if (!$(this.hash).offset()) {\n                        return;\n                    }\n\n                    event.preventDefault();\n                    position = $(this.hash).offset().top;\n\n                    $('html,body').animate({scrollTop: position}, 400, function() {\n                        location.hash = target;\n                    });\n                });\n            }\n        }\n    });\n});\n"
  },
  {
    "path": "docs/api/namespaces/default.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>CImage API Documentaion</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    \n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n                                <div class=\"accordion\" style=\"margin-bottom: 0\">\n        <div class=\"accordion-group\">\n            <div class=\"accordion-heading\">\n                                    <a class=\"accordion-toggle \" data-toggle=\"collapse\" data-target=\"#namespace-1997823667\"></a>\n                                <a href=\"../namespaces/default.html\" style=\"margin-left: 30px; padding-left: 0\">\\</a>\n            </div>\n            <div id=\"namespace-1997823667\" class=\"accordion-body collapse in\">\n                <div class=\"accordion-inner\">\n\n                    \n                    <ul>\n                                                                                                    <li class=\"class\"><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CHttpGet.html\">CHttpGet</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CImage.html\">CImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></li>\n                                                    <li class=\"class\"><a href=\"../classes/CWhitelist.html\">CWhitelist</a></li>\n                                            </ul>\n                </div>\n            </div>\n        </div>\n    </div>\n\n        </div>\n    </section>\n    <section class=\"row-fluid\">\n        <div class=\"span10 offset2\">\n            <div class=\"row-fluid\">\n                <div class=\"span8 content namespace\">\n                    <nav>\n                                                \n                                            </nav>\n                    <h1><small></small>\\</h1>\n\n                    \n                    \n                    \n                                        <h2>Classes</h2>\n                    <table class=\"table table-hover\">\n                                            <tr>\n                            <td><a href=\"../classes/CAsciiArt.html\">CAsciiArt</a></td>\n                            <td><em>Create an ASCII version of an image.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CHttpGet.html\">CHttpGet</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CImage.html\">CImage</a></td>\n                            <td><em>Resize and crop images on the fly, store generated images in a cache.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CRemoteImage.html\">CRemoteImage</a></td>\n                            <td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>\n                        </tr>\n                                            <tr>\n                            <td><a href=\"../classes/CWhitelist.html\">CWhitelist</a></td>\n                            <td><em>Act as whitelist (or blacklist).</em></td>\n                        </tr>\n                                        </table>\n                                    </div>\n\n                <aside class=\"span4 detailsbar\">\n                    <dl>\n                        <dt>Namespace hierarchy</dt>\n                        <dd class=\"hierarchy\">\n                                                                                                                                                <div class=\"namespace-wrapper\">\\</div>\n                        </dd>\n                    </dl>\n                </aside>\n            </div>\n\n            \n                        <div class=\"row-fluid\">\n                <section class=\"span8 content namespace\">\n                    <h2>Functions</h2>\n                </section>\n                <aside class=\"span4 detailsbar\"></aside>\n            </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_errorPage\" name=\"method_errorPage\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">errorPage()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">errorPage(string  <span class=\"argument\">$msg</span>) : void</pre>\n                <p><em>Display error message.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to display.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_get\" name=\"method_get\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">get()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">get(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default = null</span>) : mixed</pre>\n                <p><em>Get input from query string or return default value if not set.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value from $_GET or default value.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getConfig\" name=\"method_getConfig\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getConfig()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getConfig(string  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$default</span>) : mixed</pre>\n                <p><em>Get value from config array or default if key is not set in config array.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$key </td>\n                                <td><p>the key in the config array.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$default </td>\n                                <td><p>value to be default if $key is not set in config.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $config[$key] or $default.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_getDefined\" name=\"method_getDefined\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">getDefined()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">getDefined(mixed  <span class=\"argument\">$key</span>, mixed  <span class=\"argument\">$defined</span>, mixed  <span class=\"argument\">$undefined</span>) : mixed</pre>\n                <p><em>Get input from query string and set to $defined if defined or else $undefined.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$key </td>\n                                <td><p>as string or array of string values to look for in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$defined </td>\n                                <td><p>value to return when $key is set in $_GET.</p></td>\n                            </tr>\n                                                    <tr>\n                                <td>mixed</td>\n                                <td>$undefined </td>\n                                <td><p>value to return when $key is not set in $_GET.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                                    <h4>Returns</h4>\n                    mixed\n                                            &mdash; <p>value as $defined or $undefined.</p>\n                                    \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                                        <div class=\"row-fluid\">\n        <div class=\"span8 content class\">\n            <a id=\"method_verbose\" name=\"method_verbose\" class=\"anchor\"></a>\n            <article class=\"method\">\n                <h3 class=\" \">verbose()</h3>\n                <a href=\"#source-view\" role=\"button\" class=\"pull-right btn\" data-toggle=\"modal\" style=\"font-size: 1.1em; padding: 9px 14px\"><i class=\"icon-code\"></i></a>\n                <pre class=\"signature\" style=\"margin-right: 54px;\">verbose(string  <span class=\"argument\">$msg = null</span>) : void</pre>\n                <p><em>Log when verbose mode, when used without argument it returns the result.</em></p>\n                \n\n                                    <h4>Parameters</h4>\n                    <table class=\"table table-condensed table-hover\">\n                                                    <tr>\n                                <td>string</td>\n                                <td>$msg </td>\n                                <td><p>to log.</p></td>\n                            </tr>\n                                            </table>\n                \n                \n                \t\t\t\t\n                            </article>\n        </div>\n        <aside class=\"span4 detailsbar\">\n            <h1><i class=\"icon-arrow-down\"></i></h1>\n                                                            <dl>\n                                    <dt>File</dt>\n                    <dd><a href=\"\"><div class=\"path-wrapper\"></div></a></dd>\n                                                                            </dl>\n            <h2>Tags</h2>\n            <table class=\"table table-condensed\">\n                                    <tr>\n                        <th>\n                            package\n                        </th>\n                        <td>\n                                                                                            <p>Default</p>\n                                                    </td>\n                    </tr>\n                            </table>\n        </aside>\n    </div>\n\n                            \n        </div>\n    </section>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/reports/deprecated.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>     &raquo; Deprecated elements\n</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    \n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <div class=\"row-fluid\">\n\n        <div class=\"span2 sidebar\">\n            <ul class=\"side-nav nav nav-list\">\n                <li class=\"nav-header\">Navigation</li>\n                            </ul>\n        </div>\n\n        <div class=\"span10 offset2\">\n            <ul class=\"breadcrumb\">\n                <li><a href=\"../\"><i class=\"icon-remove-sign\"></i></a><span class=\"divider\">\\</span></li>\n                <li>Deprecated elements</li>\n            </ul>\n\n            <div id=\"marker-accordion\">\n                                    <div class=\"alert alert-info\">No deprecated elements have been found in this project.</div>\n                                    </table>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/reports/errors.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>     &raquo; Compilation errors\n</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    \n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n\n            <ul class=\"side-nav nav nav-list\">\n                <li class=\"nav-header\">Navigation</li>\n                                                                                                                                    <li><a href=\"#CRemoteImage.php\"><i class=\"icon-file\"></i> CRemoteImage.php</a></li>\n                                                                                                    <li><a href=\"#CImage.php\"><i class=\"icon-file\"></i> CImage.php</a></li>\n                                                                                                    <li><a href=\"#CAsciiArt.php\"><i class=\"icon-file\"></i> CAsciiArt.php</a></li>\n                                                                                                                                                            <li><a href=\"#CHttpGet.php\"><i class=\"icon-file\"></i> CHttpGet.php</a></li>\n                                                                                                    <li><a href=\"#CWhitelist.php\"><i class=\"icon-file\"></i> CWhitelist.php</a></li>\n                                                                                                                            </ul>\n        </div>\n\n        <div class=\"span10 offset2\">\n            <ul class=\"breadcrumb\">\n                <li><a href=\"../\"><i class=\"icon-remove-sign\"></i></a><span class=\"divider\">\\</span></li>\n                <li>Compilation Errors</li>\n            </ul>\n\n            \n                            <div class=\"package-contents\">\n                                    </div>\n                            <div class=\"package-contents\">\n                                            <a name=\"CRemoteImage.php\" id=\"CRemoteImage.php\"></a>\n                        <h3>\n                            <i class=\"icon-file\"></i>\n                            CRemoteImage.php\n                            <small style=\"float: right;padding-right: 10px;\">1</small>\n                        </h3>\n                        <div>\n                            <table class=\"table markers table-bordered\">\n                                <thead>\n                                <tr>\n                                    <th>Type</th>\n                                    <th>Line</th>\n                                    <th>Description</th>\n                                </tr>\n                                </thead>\n                                <tbody>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>0</td>\n                                        <td>No summary was found for this file</td>\n                                    </tr>\n                                                            </tbody>\n                            </table>\n                        </div>\n                                    </div>\n                            <div class=\"package-contents\">\n                                            <a name=\"CImage.php\" id=\"CImage.php\"></a>\n                        <h3>\n                            <i class=\"icon-file\"></i>\n                            CImage.php\n                            <small style=\"float: right;padding-right: 10px;\">34</small>\n                        </h3>\n                        <div>\n                            <table class=\"table markers table-bordered\">\n                                <thead>\n                                <tr>\n                                    <th>Type</th>\n                                    <th>Line</th>\n                                    <th>Description</th>\n                                </tr>\n                                </thead>\n                                <tbody>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>0</td>\n                                        <td>No summary was found for this file</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $dst_image is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $src_image is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $dst_x is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $dst_y is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $src_x is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $src_y is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $dst_w is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $dst_h is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $src_w is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>1641</td>\n                                        <td>Argument $src_h is missing from the Docblock of imageCopyResampled</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>94</td>\n                                        <td>No summary for property $bgColorDefault</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>196</td>\n                                        <td>No summary for property $pngFilterCmd</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>204</td>\n                                        <td>No summary for property $pngDeflateCmd</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>212</td>\n                                        <td>No summary for property $jpegOptimizeCmd</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>220</td>\n                                        <td>No summary for property $height</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>227</td>\n                                        <td>No summary for property $newWidthOrig</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>228</td>\n                                        <td>No summary for property $newHeight</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>229</td>\n                                        <td>No summary for property $newHeightOrig</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>242</td>\n                                        <td>No summary for property $upscale</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>250</td>\n                                        <td>No summary for property $cropOrig</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>350</td>\n                                        <td>No summary for property $fillHeight</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>365</td>\n                                        <td>No summary for property $remotePattern</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>380</td>\n                                        <td>No summary for property $remoteHostWhitelist</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>387</td>\n                                        <td>No summary for property $verboseFileName</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>394</td>\n                                        <td>No summary for property $asciiOptions</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>403</td>\n                                        <td>No summary for property $copyStrategy</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>415</td>\n                                        <td>No summary for property $cropToFit</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>416</td>\n                                        <td>No summary for property $cropWidth</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>417</td>\n                                        <td>No summary for property $cropHeight</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>418</td>\n                                        <td>No summary for property $crop_x</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>419</td>\n                                        <td>No summary for property $crop_y</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>420</td>\n                                        <td>No summary for property $filters</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>421</td>\n                                        <td>No summary for property $attr</td>\n                                    </tr>\n                                                            </tbody>\n                            </table>\n                        </div>\n                                    </div>\n                            <div class=\"package-contents\">\n                                            <a name=\"CAsciiArt.php\" id=\"CAsciiArt.php\"></a>\n                        <h3>\n                            <i class=\"icon-file\"></i>\n                            CAsciiArt.php\n                            <small style=\"float: right;padding-right: 10px;\">1</small>\n                        </h3>\n                        <div>\n                            <table class=\"table markers table-bordered\">\n                                <thead>\n                                <tr>\n                                    <th>Type</th>\n                                    <th>Line</th>\n                                    <th>Description</th>\n                                </tr>\n                                </thead>\n                                <tbody>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>0</td>\n                                        <td>No summary was found for this file</td>\n                                    </tr>\n                                                            </tbody>\n                            </table>\n                        </div>\n                                    </div>\n                            <div class=\"package-contents\">\n                                    </div>\n                            <div class=\"package-contents\">\n                                            <a name=\"CHttpGet.php\" id=\"CHttpGet.php\"></a>\n                        <h3>\n                            <i class=\"icon-file\"></i>\n                            CHttpGet.php\n                            <small style=\"float: right;padding-right: 10px;\">3</small>\n                        </h3>\n                        <div>\n                            <table class=\"table markers table-bordered\">\n                                <thead>\n                                <tr>\n                                    <th>Type</th>\n                                    <th>Line</th>\n                                    <th>Description</th>\n                                </tr>\n                                </thead>\n                                <tbody>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>0</td>\n                                        <td>No summary was found for this file</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>8</td>\n                                        <td>No summary for property $request</td>\n                                    </tr>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>9</td>\n                                        <td>No summary for property $response</td>\n                                    </tr>\n                                                            </tbody>\n                            </table>\n                        </div>\n                                    </div>\n                            <div class=\"package-contents\">\n                                            <a name=\"CWhitelist.php\" id=\"CWhitelist.php\"></a>\n                        <h3>\n                            <i class=\"icon-file\"></i>\n                            CWhitelist.php\n                            <small style=\"float: right;padding-right: 10px;\">1</small>\n                        </h3>\n                        <div>\n                            <table class=\"table markers table-bordered\">\n                                <thead>\n                                <tr>\n                                    <th>Type</th>\n                                    <th>Line</th>\n                                    <th>Description</th>\n                                </tr>\n                                </thead>\n                                <tbody>\n                                                                    <tr>\n                                        <td>error</td>\n                                        <td>0</td>\n                                        <td>No summary was found for this file</td>\n                                    </tr>\n                                                            </tbody>\n                            </table>\n                        </div>\n                                    </div>\n                            <div class=\"package-contents\">\n                                    </div>\n                    </div>\n    </section>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/api/reports/markers.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\n    <meta charset=\"utf-8\"/>\n    <title>     &raquo; Markers\n</title>\n    <meta name=\"author\" content=\"\"/>\n    <meta name=\"description\" content=\"\"/>\n\n    <link href=\"../css/bootstrap-combined.no-icons.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/font-awesome.min.css\" rel=\"stylesheet\">\n    <link href=\"../css/prism.css\" rel=\"stylesheet\" media=\"all\"/>\n    <link href=\"../css/template.css\" rel=\"stylesheet\" media=\"all\"/>\n    \n    <!--[if lt IE 9]>\n    <script src=\"../js/html5.js\"></script>\n    <![endif]-->\n    <script src=\"../js/jquery-1.11.0.min.js\"></script>\n    <script src=\"../js/ui/1.10.4/jquery-ui.min.js\"></script>\n    <script src=\"../js/bootstrap.min.js\"></script>\n    <script src=\"../js/jquery.smooth-scroll.js\"></script>\n    <script src=\"../js/prism.min.js\"></script>\n    <!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->\n    \n    <link rel=\"shortcut icon\" href=\"../images/favicon.ico\"/>\n    <link rel=\"apple-touch-icon\" href=\"../images/apple-touch-icon.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"../images/apple-touch-icon-72x72.png\"/>\n    <link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"../images/apple-touch-icon-114x114.png\"/>\n</head>\n<body>\n\n<div class=\"navbar navbar-fixed-top\">\n    <div class=\"navbar-inner\">\n        <div class=\"container\">\n            <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">\n                <i class=\"icon-ellipsis-vertical\"></i>\n            </a>\n            <a class=\"brand\" href=\"../index.html\">CImage API Documentaion</a>\n\n            <div class=\"nav-collapse\">\n                <ul class=\"nav pull-right\">\n                                        <li class=\"dropdown\" id=\"charts-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Charts <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../graphs/class.html\">\n                                    <i class=\"icon-list-alt\"></i>&#160;Class hierarchy diagram\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                    <li class=\"dropdown\" id=\"reports-menu\">\n                        <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\n                            Reports <b class=\"caret\"></b>\n                        </a>\n                        <ul class=\"dropdown-menu\">\n                            <li>\n                                <a href=\"../reports/errors.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Errors <span class=\"label label-info pull-right\">40</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/markers.html\">\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Markers <span class=\"label label-info pull-right\">2</span>\n                                </a>\n                            </li>\n                            <li>\n                                <a href=\"../reports/deprecated.html\">\n                                                                                                            <i class=\"icon-list-alt\"></i>&#160;Deprecated <span class=\"label label-info pull-right\">0</span>\n                                </a>\n                            </li>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n    <!--<div class=\"go_to_top\">-->\n    <!--<a href=\"#___\" style=\"color: inherit\">Back to top&#160;&#160;<i class=\"icon-upload icon-white\"></i></a>-->\n    <!--</div>-->\n</div>\n\n<div id=\"___\" class=\"container-fluid\">\n        <section class=\"row-fluid\">\n        <div class=\"span2 sidebar\">\n            <ul class=\"side-nav nav nav-list\">\n                <li class=\"nav-header\">Navigation</li>\n                                                                                                                                                                                        <li><a href=\"#CImage.php\"><i class=\"icon-file\"></i> CImage.php</a></li>\n                                                                                                                                                                                                                                                                                                                                                            </ul>\n        </div>\n\n        <div class=\"span10 offset2\">\n\n            <ul class=\"breadcrumb\">\n                <li><a href=\"../\"><i class=\"icon-map-marker\"></i></a><span class=\"divider\">\\</span></li>\n                <li>Markers</li>\n            </ul>\n\n            \n            <div id=\"marker-accordion\">\n                                                                                                                                    <div class=\"package-contents\">\n                            <a name=\"CImage.php\" id=\"CImage.php\"></a>\n                            <h3>\n                            <i class=\"icon-file\"></i>\n                                CImage.php\n                                <small style=\"float: right;padding-right: 10px;\">2</small>\n                            </h3>\n                            <div>\n                                <table class=\"table markers table-bordered\">\n                                    <tr>\n                                        <th>Type</th>\n                                        <th>Line</th>\n                                        <th>Description</th>\n                                    </tr>\n                                                                            <tr>\n                                            <td>TODO</td>\n                                            <td>467</td>\n                                            <td>clean up how $this-&gt;saveFolder is used in other methods.</td>\n                                        </tr>\n                                                                            <tr>\n                                            <td>TODO</td>\n                                            <td>414</td>\n                                            <td>Clean up these and check if and how they are used</td>\n                                        </tr>\n                                                                    </table>\n                            </div>\n                        </div>\n                                                                                                                                                                                                                                    </div>\n        </div>\n    </section>\n\n    <footer class=\"row-fluid\">\n        <section class=\"span10 offset2\">\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <section class=\"row-fluid footer-sections\">\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-code\"></i></h1>\n                            <div>\n                                <ul>\n                                                                    </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-bar-chart\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../graphs/class.html\">Class Hierarchy Diagram</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                        <section class=\"span4\">\n                                                        <h1><i class=\"icon-pushpin\"></i></h1>\n                            <div>\n                                <ul>\n                                    <li><a href=\"../reports/errors.html\">Errors</a></li>\n                                    <li><a href=\"../reports/markers.html\">Markers</a></li>\n                                </ul>\n                            </div>\n                        </section>\n                    </section>\n                </section>\n            </section>\n            <section class=\"row-fluid\">\n                <section class=\"span10 offset1\">\n                    <hr />\n                    Documentation is powered by <a href=\"http://www.phpdoc.org/\">phpDocumentor </a> and authored\n                    on December 2nd, 2015 at 11:04.\n                </section>\n            </section>\n        </section>\n    </footer>\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "functions.php",
    "content": "<?php\n/**\n * General functions to use in img.php.\n */\n\n\n\n/**\n * Trace and log execution to logfile, useful for debugging and development.\n *\n * @param string $msg message to log to file.\n *\n * @return void\n */\nfunction trace($msg)\n{\n    $file = CIMAGE_DEBUG_FILE;\n    if (!is_writable($file)) {\n        return;\n    }\n\n    $timer = number_format((microtime(true) - $_SERVER[\"REQUEST_TIME_FLOAT\"]), 6);\n    $details  = \"{$timer}ms\";\n    $details .= \":\" . round(memory_get_peak_usage()/1024/1024, 3) . \"MB\";\n    $details .= \":\" . count(get_included_files());\n    file_put_contents($file, \"$details:$msg\\n\", FILE_APPEND);\n}\n\n\n\n/**\n * Display error message.\n *\n * @param string $msg to display.\n * @param int $type of HTTP error to display.\n *\n * @return void\n */\nfunction errorPage($msg, $type = 500)\n{\n    global $mode;\n\n    switch ($type) {\n        case 403:\n            $header = \"403 Forbidden\";\n            break;\n        case 404:\n            $header = \"404 Not Found\";\n            break;\n        default:\n            $header = \"500 Internal Server Error\";\n    }\n\n    if ($mode == \"strict\") {\n        $header = \"404 Not Found\";\n    }\n\n    header(\"HTTP/1.0 $header\");\n\n    if ($mode == \"development\") {\n        die(\"[img.php] $msg\");\n    }\n\n    error_log(\"[img.php] $msg\");\n    die(\"HTTP/1.0 $header\");\n}\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value of input from query string or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $undefined value to return when $key has no, or empty value in $_GET.\n *\n * @return mixed value as or $undefined.\n */\nfunction getValue($key, $undefined)\n{\n    $val = get($key);\n    if (is_null($val) || $val === \"\") {\n        return $undefined;\n    }\n    return $val;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null, $arg = \"\")\n{\n    global $verbose, $verboseFile;\n    static $log = array();\n\n    if (!($verbose || $verboseFile)) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    if (is_null($arg)) {\n        $arg = \"null\";\n    } elseif ($arg === false) {\n        $arg = \"false\";\n    } elseif ($arg === true) {\n        $arg = \"true\";\n    }\n\n    $log[] = $msg . $arg;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction checkExternalCommand($what, $enabled, $commandString)\n{\n    $no = $enabled ? null : 'NOT';\n    $text = \"Post processing $what is $no enabled.<br>\";\n\n    list($command) = explode(\" \", $commandString);\n    $no = is_executable($command) ? null : 'NOT';\n    $text .= \"The command for $what is $no an executable.<br>\";\n\n    return $text;\n}\n"
  },
  {
    "path": "phpcs.xml",
    "content": "<?xml version=\"1.0\"?>\n<ruleset name=\"PHPCS rule set\">\n    <description>Custom rule set.</description>\n\n    <file>.</file>\n    <file>test</file>\n    <file>autoload.php</file>\n\n    <exclude-pattern>docs/*</exclude-pattern>\n    <exclude-pattern>coverage/*</exclude-pattern>\n    <exclude-pattern>webroot/imgs.php</exclude-pattern>\n    <exclude-pattern>webroot/imgp.php</exclude-pattern>\n    <exclude-pattern>webroot/imgd.php</exclude-pattern>\n    <exclude-pattern>webroot/test/*</exclude-pattern>\n    <exclude-pattern>webroot/js/*</exclude-pattern>\n    <exclude-pattern>webroot/compare/*</exclude-pattern>\n\n    <arg name=\"encoding\" value=\"utf-8\"/>\n    <!--<arg name=\"extensions\" value=\".php\"/>-->\n    <!--<arg name=\"colors\" value=\"1\"/>-->\n    <!--<arg name=\"warning-severity\" value=\"5\"/>-->\n\n    <rule ref=\"PSR2\">\n        <exclude name=\"PSR1.Classes.ClassDeclaration.MissingNamespace\" />         <exclude name=\"Squiz.Commenting.FileComment\" />\n        <exclude name=\"Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace\" />\n\n        <!--\n        <exclude name=\"PSR1.Classes.ClassDeclaration.MissingNamespace\" />\n        -->\n    </rule>\n    \n</ruleset>\n"
  },
  {
    "path": "phpdoc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<phpdoc>\n    <title>CImage API Documentaion</title>\n    <parser>\n        <target>docs/api</target>\n    </parser>\n    <transformer>\n        <target>docs/api</target>\n    </transformer>\n    <files>\n        <file>./*.php</file>\n        <file>webroot/img.php</file>\n        <file>webroot/img_config.php</file>\n    </files>\n</phpdoc>\n"
  },
  {
    "path": "phpunit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<phpunit\n    bootstrap=\"test/config.php\">\n\n    <testsuites>\n        <testsuite name=\"all\">\n            <directory>test</directory>\n        </testsuite>\n    </testsuites>\n\n    <logging>\n        <log type=\"coverage-html\" target=\"coverage\" charset=\"UTF-8\" highlight=\"true\" lowUpperBound=\"35\" highLowerBound=\"70\" />\n        <log type=\"coverage-clover\" target=\"coverage.clover\" />\n   </logging>\n\n   <filter>\n       <whitelist processUncoveredFilesFromWhitelist=\"true\">\n           <file>*.php</file>\n       </whitelist>\n   </filter>\n\n</phpunit>\n"
  },
  {
    "path": "test/CCacheTest.php",
    "content": "<?php\n/**\n * A testclass\n *\n */\nclass CCacheTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * Test\n     *\n     * @return void\n     */\n    public function testSetCacheDir()\n    {\n        $cache = new CCache();\n        $cache->setDir(CACHE_PATH);\n\n        $exp = \"exists, writable\";\n        $res = $cache->getStatusOfSubdir(\"\");\n        $this->assertEquals($exp, $res, \"Status of cache dir missmatch.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @expectedException Exception\n     *\n     * @return void\n     */\n    public function testSetWrongCacheDir()\n    {\n        $cache = new CCache();\n        $cache->setDir(CACHE_PATH . \"/NO_EXISTS\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     */\n    public function testCreateSubdir()\n    {\n        $cache = new CCache();\n        $cache->setDir(CACHE_PATH);\n        \n        $subdir = \"__test__\";\n        $cache->removeSubdir($subdir);\n        \n        $exp = \"does not exist\";\n        $res = $cache->getStatusOfSubdir($subdir, false);\n        $this->assertEquals($exp, $res, \"Subdir should not be created.\");\n        \n        $res = $cache->getPathToSubdir($subdir);\n        $exp = realpath(CACHE_PATH . \"/$subdir\");\n        $this->assertEquals($exp, $res, \"Subdir path missmatch.\");\n\n        $exp = \"exists, writable\";\n        $res = $cache->getStatusOfSubdir($subdir);\n        $this->assertEquals($exp, $res, \"Subdir should exist.\");\n\n        $res = $cache->removeSubdir($subdir);\n        $this->assertTrue($res, \"Remove subdir.\");\n    }\n}\n"
  },
  {
    "path": "test/CImageDummyTest.php",
    "content": "<?php\n/**\n * A testclass\n *\n */\nclass CImageDummyTest extends \\PHPUnit_Framework_TestCase\n{\n    const DUMMY = \"__dummy__\";\n    private $cachepath;\n\n\n\n    /**\n     * Setup environment\n     *\n     * @return void\n     */\n    protected function setUp()\n    {\n        $cache = new CCache();\n        $cache->setDir(CACHE_PATH);\n        $this->cachepath = $cache->getPathToSubdir(self::DUMMY);\n    }\n\n\n\n    /**\n     * Clean up cache dir content.\n     *\n     * @return void\n     */\n    protected function removeFilesInCacheDir()\n    {\n        $files = glob($this->cachepath . \"/*\");\n        foreach ($files as $file) {\n            if (is_file($file)) {\n                unlink($file);\n            }\n        }\n    }\n\n\n\n    /**\n     * Teardown environment\n     *\n     * @return void\n     */\n    protected function tearDown()\n    {\n        $cache = new CCache();\n        $cache->setDir(CACHE_PATH);\n        $this->removeFilesInCacheDir();\n        $cache->removeSubdir(self::DUMMY);\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     */\n    public function testCreate1()\n    {\n        $img = new CImage();\n\n        $img->setSaveFolder($this->cachepath);\n        $img->setSource(self::DUMMY, $this->cachepath);\n        $img->createDummyImage();\n        $img->generateFilename(null, false);\n        $img->save(null, null, false);\n\n        $filename = $img->getTarget();\n\n        $this->assertEquals(basename($filename), self::DUMMY . \"_100_100\", \"Filename not as expected on dummy image.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     */\n    public function testCreate2()\n    {\n        $img = new CImage();\n\n        $img->setSaveFolder($this->cachepath);\n        $img->setSource(self::DUMMY, $this->cachepath);\n        $img->createDummyImage(200, 400);\n        $img->generateFilename(null, false);\n        $img->save(null, null, false);\n\n        $filename = $img->getTarget();\n\n        $this->assertEquals(basename($filename), self::DUMMY . \"_200_400\", \"Filename not as expected on dummy image.\");\n    }\n}\n"
  },
  {
    "path": "test/CImageRemoteDownloadTest.php",
    "content": "<?php\n/**\n * A testclass\n *\n */\nclass CImageRemoteDownloadTest extends \\PHPUnit_Framework_TestCase\n{\n    /*\n     * remote_whitelist\n     */\n    private $remote_whitelist = [\n        '\\.facebook\\.com$',\n        '^(?:images|photos-[a-z])\\.ak\\.instagram\\.com$',\n        '\\.google\\.com$',\n    ];\n    \n    \n    \n    /**\n     * Provider for valid remote sources.\n     *\n     * @return array\n     */\n    public function providerValidRemoteSource()\n    {\n        return [\n            [\n                \"http://dbwebb.se/img.jpg\",\n                \"https://dbwebb.se/img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Provider for invalid remote sources.\n     *\n     * @return array\n     */\n    public function providerInvalidRemoteSource()\n    {\n        return [\n            [\n                \"ftp://dbwebb.se/img.jpg\",\n                \"dbwebb.se/img.jpg\",\n                \"img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     *\n     * @dataProvider providerValidRemoteSource\n     */\n    public function testAllowRemoteDownloadDefaultPatternValid($source)\n    {\n        $img = new CImage();\n        $img->setRemoteDownload(true, \"\");\n        \n        $res = $img->isRemoteSource($source);\n        $this->assertTrue($res, \"Should be a valid remote source: '$source'.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     *\n     * @dataProvider providerInvalidRemoteSource\n     */\n    public function testAllowRemoteDownloadDefaultPatternInvalid($source)\n    {\n        $img = new CImage();\n        $img->setRemoteDownload(true, \"\");\n        \n        $res = $img->isRemoteSource($source);\n        $this->assertFalse($res, \"Should not be a valid remote source: '$source'.\");\n    }\n\n\n\n    /**\n     * Provider for hostname matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameMatch()\n    {\n        return [\n            [\n                \"any.facebook.com\",\n                \"images.ak.instagram.com\",\n                \"google.com\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname matches the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameMatch\n     *\n     */\n    public function testRemoteHostWhitelistMatch($hostname)\n    {\n        $img = new CImage();\n        $img->setRemoteHostWhitelist($this->remote_whitelist);\n        \n        $res = $img->isRemoteSourceOnWhitelist(\"http://$hostname/img.jpg\");\n        $this->assertTrue($res, \"Should be a valid hostname on the whitelist: '$hostname'.\");\n    }\n\n\n\n    /**\n     * Provider for hostname not matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameNoMatch()\n    {\n        return [\n            [\n                \"example.com\",\n                \".com\",\n                \"img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname not matching the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameNoMatch\n     *\n     */\n    public function testRemoteHostWhitelistNoMatch($hostname)\n    {\n        $img = new CImage();\n        $img->setRemoteHostWhitelist($this->remote_whitelist);\n        \n        $res = $img->isRemoteSourceOnWhitelist(\"http://$hostname/img.jpg\");\n        $this->assertFalse($res, \"Should not be a valid hostname on the whitelist: '$hostname'.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     *\n     */\n    public function testRemoteHostWhitelistNotConfigured()\n    {\n        $img = new CImage();\n        $res = $img->isRemoteSourceOnWhitelist(null);\n        $this->assertTrue($res, \"Should allow when whitelist not configured.\");\n    }\n}\n"
  },
  {
    "path": "test/CImageSRGBTest.php",
    "content": "<?php\n/**\n * A testclass\n *\n */\nclass CImageSRGBTest extends \\PHPUnit_Framework_TestCase\n{\n    private $srgbDir = \"srgb\";\n    private $cache;\n    private $srgbColorProfile;\n\n    \n    \n    /**\n     * Setup before test\n     *\n     * @return void\n     */\n    protected function setUp()\n    {\n        $this->srgbColorProfile = __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc';\n        $this->cache = CACHE_PATH . \"/\" . $this->srgbDir;\n        \n        if (!is_writable($this->cache)) {\n            mkdir($this->cache);\n        }\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     */\n    public function testCreate1()\n    {\n        $img = new CImage();\n\n        $filename = $img->convert2sRGBColorSpace(\n            'car.png',\n            IMAGE_PATH,\n            $this->cache,\n            $this->srgbColorProfile\n        );\n\n        if (class_exists(\"Imagick\")) {\n            $this->assertEquals(\"srgb_car.png\", basename($filename), \"Filename not as expected on image.\");\n        } else {\n            $this->assertFalse($filename, \"ImageMagick not installed, silent fail\");\n        }\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     */\n    public function testCreate2()\n    {\n        $img = new CImage();\n\n        $filename = $img->convert2sRGBColorSpace(\n            'car.jpg',\n            IMAGE_PATH,\n            $this->cache,\n            $this->srgbColorProfile\n        );\n\n        $this->assertFalse($filename);\n    }\n}\n"
  },
  {
    "path": "test/CWhitelistTest.php",
    "content": "<?php\n/**\n * A testclass\n *\n */\nclass CWhitelistTest extends \\PHPUnit_Framework_TestCase\n{\n    /*\n     * remote_whitelist\n     */\n    private $remote_whitelist = [\n        '\\.facebook\\.com$',\n        '^(?:images|photos-[a-z])\\.ak\\.instagram\\.com$',\n        '\\.google\\.com$',\n    ];\n    \n    \n    \n    /**\n     * Provider for hostname matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameMatch()\n    {\n        return [\n            [\n                \"any.facebook.com\",\n                \"images.ak.instagram.com\",\n                \"google.com\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Provider for hostname not matching the whitelist.\n     *\n     * @return array\n     */\n    public function providerHostnameNoMatch()\n    {\n        return [\n            [\n                \"example.com\",\n                \".com\",\n                \"img.jpg\",\n            ],\n        ];\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname matches the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameMatch\n     *\n     */\n    public function testRemoteHostWhitelistMatch($hostname)\n    {\n        $whitelist = new CWhitelist();\n        $whitelist->set($this->remote_whitelist);\n        \n        $res = $whitelist->check($hostname);\n        $this->assertTrue($res, \"Should be a valid hostname on the whitelist: '$hostname'.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @param string $hostname not matching the whitelist\n     *\n     * @return void\n     *\n     * @dataProvider providerHostnameNoMatch\n     *\n     */\n    public function testRemoteHostWhitelistNoMatch($hostname)\n    {\n        $whitelist = new CWhitelist();\n        $whitelist->set($this->remote_whitelist);\n        \n        $res = $whitelist->check($hostname);\n        $this->assertFalse($res, \"Should not be a valid hostname on the whitelist: '$hostname'.\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @expectedException Exception\n     *\n     * @return void\n     *\n     */\n    public function testInvalidFormat()\n    {\n        $whitelist = new CWhitelist();\n        $whitelist->set(\"should fail\");\n    }\n\n\n\n    /**\n     * Test\n     *\n     * @return void\n     *\n     */\n    public function testCheckEmpty()\n    {\n        $whitelist = new CWhitelist();\n        $whitelist->set($this->remote_whitelist);\n        \n        $hostname = \"\";\n        $res = $whitelist->check($hostname);\n        $this->assertFalse($res, \"Should not be a valid hostname on the whitelist: '$hostname'.\");\n    }\n}\n"
  },
  {
    "path": "test/config.php",
    "content": "<?php\n/**\n * Get all configuration details to be able to execute the test suite.\n *\n */\nrequire __DIR__ . \"/../autoload.php\";\n\ndefine('IMAGE_PATH', __DIR__ . '/../webroot/img/');\ndefine('CACHE_PATH', __DIR__ . '/../cache/');\n"
  },
  {
    "path": "webroot/check_system.php",
    "content": "<?php\n\necho 'Current PHP version: ' . phpversion() . '<br><br>';\n\necho 'Running on: ' . htmlentities($_SERVER['SERVER_SOFTWARE']) . '<br><br>';\n\n$no = extension_loaded('exif') ? null : 'NOT';\necho \"Extension exif is $no loaded.<br>\";\n\n$no = extension_loaded('curl') ? null : 'NOT';\necho \"Extension curl is $no loaded.<br>\";\n\n$no = extension_loaded('imagick') ? null : 'NOT';\necho \"Extension imagick is $no loaded.<br>\";\n\n$no = extension_loaded('gd') ? null : 'NOT';\necho \"Extension gd is $no loaded.<br>\";\nif (!$no) {\n    echo \"<pre>\", var_dump(gd_info()), \"</pre>\";\n}\n\necho \"<strong>Checking path for postprocessing tools</strong>\";\n\necho \"<br>pngquant: \";\nsystem(\"which pngquant\");\n\necho \"<br>optipng: \";\nsystem(\"which optipng\");\n\necho \"<br>pngout: \";\nsystem(\"which pngout\");\n\necho \"<br>jpegtran: \";\nsystem(\"which jpegtran\");\n"
  },
  {
    "path": "webroot/compare/compare-test.php",
    "content": "<?php\n$script = <<<EOD\nCImage.compare({\n    \"input1\": \"../img.php?src=car.png\",\n    \"input2\": \"../img.php?src=car.png&sharpen\",\n    \"input3\": \"../img.php?src=car.png&blur\",\n    \"input4\": \"../img.php?src=car.png&emboss\",\n    \"json\": true,\n    \"stack\": false\n});\nEOD;\n\ninclude __DIR__ . \"/compare.php\";\n"
  },
  {
    "path": "webroot/compare/compare.php",
    "content": "<!doctype html>\n<html lang=en>\n<head>\n<style>\n\n<?php\nfunction e($str) {\n    return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');\n}\n?>\n\nbody {\n}\n\ninput[type=text] {\n    width: 400px;\n}\n\n.hidden {\n    display: none;\n}\n\n#wrap {\n    position: relative;\n    overflow: visible;\n\n}\n\n.stack {\n    position: absolute;\n    left: 0;\n    top: 0;\n}\n\n.area {\n    float: left;\n    padding: 1em;\n    background-color: #eee;\n}\n\n.invert {\n    background-color: #666;\n    color: white;\n}\n\n.json {\n    min-height: 100px;\n}\n\n.top {\n    z-index: 10;\n}\n\n</style>\n</head>\n\n<body>\n<h1>Compare images</h1>\n<p>Add link to images and visually compare them. Change the link och press return to load the image. Add <code>&amp;black</code> to the querystring to get a black background. <a href=\"http://dbwebb.se/opensource/cimage\">Read more...</a></p>\n\n<p><a id=\"permalink\" href=\"?\">Direct link to this setup.</a></p>\n\n<form>\n    <p>\n        <label>Image 1: <input type=\"text\" id=\"input1\" data-id=\"1\"></label> <img id=\"thumb1\"></br>\n        <label>Image 2: <input type=\"text\" id=\"input2\" data-id=\"2\"></label> <img id=\"thumb2\"></br>\n        <label>Image 3: <input type=\"text\" id=\"input3\" data-id=\"3\"></label> <img id=\"thumb3\"></br>\n        <label>Image 4: <input type=\"text\" id=\"input4\" data-id=\"4\"></label> <img id=\"thumb4\"></br>\n        <label>Image 5: <input type=\"text\" id=\"input5\" data-id=\"5\"></label> <img id=\"thumb5\"></br>\n        <label>Image 6: <input type=\"text\" id=\"input6\" data-id=\"6\"></label> <img id=\"thumb6\"></br>\n        <label><input type=\"checkbox\" id=\"viewDetails\">Show image details</label><br/>\n        <label><input type=\"checkbox\" id=\"stack\">Stack images?</label><br/>\n        <label><input type=\"checkbox\" id=\"bg\">Dark background?</label>\n    </p>\n</form>\n\n<div id=\"buttonWrap\" class=\"hidden\">\n    <button id=\"button1\" class=\"button\" data-id=\"1\">Image 1</button>\n    <button id=\"button2\" class=\"button\" data-id=\"2\">Image 2</button>\n    <button id=\"button3\" class=\"button\" data-id=\"3\">Image 3</button>\n    <button id=\"button4\" class=\"button\" data-id=\"4\">Image 4</button>\n    <button id=\"button5\" class=\"button\" data-id=\"5\">Image 5</button>\n    <button id=\"button6\" class=\"button\" data-id=\"6\">Image 6</button>\n</div>\n\n<div id=\"wrap\">\n\n    <div id=\"area1\" class=\"area\">\n        <code>Image 1</code><br>\n        <img id=\"img1\">\n        <pre id=\"json1\" class=\"json hidden\"></pre>\n    </div>\n\n    <div id=\"area2\" class=\"area\">\n        <code>Image 2</code><br>\n        <img id=\"img2\">\n        <pre id=\"json2\" class=\"json hidden\"></pre>\n    </div>\n\n    <div id=\"area3\" class=\"area\">\n        <code>Image 3</code><br>\n        <img id=\"img3\">\n        <pre id=\"json3\" class=\"json hidden\"></pre>\n    </div>\n\n    <div id=\"area4\" class=\"area\">\n        <code>Image 4</code><br>\n        <img id=\"img4\">\n        <pre id=\"json4\" class=\"json hidden\"></pre>\n    </div>\n\n    <div id=\"area5\" class=\"area\">\n        <code>Image 5</code><br>\n        <img id=\"img5\">\n        <pre id=\"json5\" class=\"json hidden\"></pre>\n    </div>\n\n    <div id=\"area6\" class=\"area\">\n        <code>Image 6</code><br>\n        <img id=\"img6\">\n        <pre id=\"json6\" class=\"json hidden\"></pre>\n    </div>\n\n</div>\n\n\n</body>\n\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script src=\"../js/cimage.js\"></script>\n<script>\n<?php\nif (isset($_GET['input1'])) {\n    // Use incoming from querystring as defaults\n?>\n    CImage.compare({\n        \"input1\": \"<?=e($_GET['input1'])?>\",\n        \"input2\": \"<?=e($_GET['input2'])?>\",\n        \"input3\": \"<?=e($_GET['input3'])?>\",\n        \"input4\": \"<?=e($_GET['input4'])?>\",\n        \"input5\": \"<?=e($_GET['input5'])?>\",\n        \"input6\": \"<?=e($_GET['input6'])?>\",\n        \"json\": <?=e($_GET['json'])?>,\n        \"stack\": <?=e($_GET['stack'])?>,\n        \"bg\": <?=e($_GET['bg'])?>\n    });\n<?php\n} elseif (isset($script)) {\n    // Use default setup from js configuration\n    echo $script;\n} else {\n    // Use defaults\n    echo \"CImage.compare({});\";\n} ?>\n</script>\n\n</html>\n"
  },
  {
    "path": "webroot/compare/issue117-PNG24.php",
    "content": "<?php\n$script = <<<EOD\nCImage.compare({\n    \"input1\": \"../img.php?src=issue117/tri_original.png\",\n    \"input2\": \"../img.php?src=issue117/tri_imageresizing.png\",\n    \"input3\": \"../img.php?src=issue117/tri_cimage.png\",\n    \"input4\": \"../img.php?src=issue117/tri_imagemagick.png\",\n    \"input5\": \"../img.php?src=issue117/tri_original.png&w=190\",\n    \"input6\": \"../img.php?src=issue117/tri_original.png&w=190&no-resample\",\n    \"json\": true,\n    \"stack\": false,\n    \"bg\": true\n});\nEOD;\n\ninclude __DIR__ . \"/compare.php\";\n"
  },
  {
    "path": "webroot/htaccess",
    "content": "#\n# Rewrite to have friendly urls to img.php, edit it to suite your environment.\n#\n# The example is set up as following.\n#\n#  img                 A directory where all images are stored\n#  img/me.jpg          Access a image as usually.\n#  image/me.jpg        Access a image though img.php using htaccess rewrite.\n#  image/me.jpg?w=300  Using options to img.php.\n# \n# Subdirectories also work.\n#  img/me/me.jpg          Direct access to the image.\n#  image/me/me.jpg        Accessed through img.php.\n#  image/me/me.jpg?w=300  Using options to img.php.\n#\nRewriteEngine on\nRewriteRule ^image/(.*)$   img.php?src=$1 [QSA,NC,L]\n"
  },
  {
    "path": "webroot/img.php",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\n        \"<p><b>img.php: Uncaught exception:</b> <p>\"\n        . $exception->getMessage()\n        . \"</p><pre>\"\n        . $exception->getTraceAsString()\n        . \"</pre>\",\n        500\n    );\n});\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} elseif (!isset($config)) {\n    $config = array();\n}\n\n// Make CIMAGE_DEBUG false by default, if not already defined\nif (!defined(\"CIMAGE_DEBUG\")) {\n    define(\"CIMAGE_DEBUG\", false);\n}\n\n\n\n/**\n * Setup the autoloader, but not when using a bundle.\n */\nif (!defined(\"CIMAGE_BUNDLE\")) {\n    if (!isset($config[\"autoloader\"])) {\n        die(\"CImage: Missing autoloader.\");\n    }\n\n    require $config[\"autoloader\"];\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n* vf - do verbose dump to file\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\n$verboseFile = getDefined('vf', true, false);\nverbose(\"img.php version = \" . CIMAGE_VERSION);\n\n\n\n/**\n* status - do a verbose dump of the configuration\n*/\n$status = getDefined('status', true, false);\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is not loaded.\", 500);\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n\n} elseif ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n\n} elseif ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n    $verboseFile = false;\n\n} elseif ($mode == 'test') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\", 500);\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} elseif (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwdType     = getConfig('password_type', 'text');\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwd) {\n    switch ($pwdType) {\n        case 'md5':\n            $passwordMatch = ($pwdConfig === md5($pwd));\n            break;\n        case 'hash':\n            $passwordMatch = password_verify($pwd, $pwdConfig);\n            break;\n        case 'text':\n            $passwordMatch = ($pwdConfig === $pwd);\n            break;\n        default:\n            $passwordMatch = false;\n    }\n}\n\nif ($pwdAlways && $passwordMatch !== true) {\n    errorPage(\"Password required and does not match or exists.\", 403);\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer ?? \"\", PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n        verbose(\"Hotlinking since passwordmatch\");\n    } elseif ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\", 403);\n    } elseif (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\", 403);\n    } elseif (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n        verbose(\"Hotlinking disallowed but serverName matches refererHost.\");\n    } elseif (!empty($hotlinkingWhitelist)) {\n        $whitelist = new CWhitelist();\n        $allowedByWhitelist = $whitelist->check($refererHost, $hotlinkingWhitelist);\n\n        if ($allowedByWhitelist) {\n            verbose(\"Hotlinking/leeching allowed by whitelist.\");\n        } else {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist. Referer: $referer.\", 403);\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\", 403);\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Create the class for the image.\n */\n$CImage = getConfig('CImage', 'CImage');\n$img = new $CImage();\n$img->setVerbose($verbose || $verboseFile);\n\n\n\n/**\n * Get the cachepath from config.\n */\n$CCache = getConfig('CCache', 'CCache');\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n$cache = new $CCache();\n$cache->setDir($cachePath);\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * Prepare fast track cache for swriting cache items.\n */\n$fastTrackCache = \"fasttrack\";\n$allowFastTrackCache = getConfig('fast_track_allow', false);\n\n$CFastTrackCache = getConfig('CFastTrackCache', 'CFastTrackCache');\n$ftc = new $CFastTrackCache();\n$ftc->setCacheDir($cache->getPathToSubdir($fastTrackCache))\n    ->enable($allowFastTrackCache)\n    ->setFilename(array('no-cache', 'nc'));\n$img->injectDependency(\"fastTrackCache\", $ftc);\n\n\n\n/**\n *  Load and output images from fast track cache, if items are available\n * in cache.\n */\nif ($useCache && $allowFastTrackCache) {\n    if (CIMAGE_DEBUG) {\n        trace(\"img.php fast track cache enabled and used\");\n    }\n    $ftc->output();\n}\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $cacheRemote = $cache->getPathToSubdir(\"remote\");\n\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $cacheRemote, $pattern);\n\n    $whitelist = getConfig('remote_whitelist', null);\n    $img->setRemoteHostWhitelist($whitelist);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = urldecode(get('src', \"\"))\n    or errorPage('Must set src-attribute.', 404);\n\n// Get settings for src-alt as backup image\n$srcAltImage = urldecode(get('src-alt', \"\"));\n$srcAltConfig = getConfig('src_alt', null);\nif (empty($srcAltImage)) {\n    $srcAltImage = $srcAltConfig;\n}\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \\.:]+$#');\n\n// Source is remote\n$remoteSource = false;\n\n// Dummy image feature\n$dummyEnabled  = getConfig('dummy_enabled', true);\n$dummyFilename = getConfig('dummy_filename', 'dummy');\n$dummyImage = false;\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Source filename contains invalid characters.', 404);\n\nif ($dummyEnabled && $srcImage === $dummyFilename) {\n\n    // Prepare to create a dummy image and use it as the source image.\n    $dummyImage = true;\n\n} elseif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n    $remoteSource = true;\n\n} else {\n\n    // Check if file exists on disk or try using src-alt\n    $pathToImage = realpath($imagePath . $srcImage);\n\n    if (!is_file($pathToImage) && !empty($srcAltImage)) {\n        // Try using the src-alt instead\n        $srcImage = $srcAltImage;\n        $pathToImage = realpath($imagePath . $srcImage);\n\n        preg_match($validFilename, $srcImage)\n            or errorPage('Source (alt) filename contains invalid characters.', 404);\n\n        if ($dummyEnabled && $srcImage === $dummyFilename) {\n            // Check if src-alt is the dummy image\n            $dummyImage = true;\n        }\n    }\n\n    if (!$dummyImage) {\n        is_file($pathToImage)\n            or errorPage(\n                'Source image is not a valid file, check the filename and that a\n                matching file exists on the filesystem.',\n                404\n            );\n    }\n}\n\nif ($imagePathConstraint && !$dummyImage && !$remoteSource) {\n    // Check that the image is a file below the directory 'image_path'.\n    $imageDir = realpath($imagePath);\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.',\n            404\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth && $newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.', 404);\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.', 404);\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight && $newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.', 404);\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Height out of range.', 404);\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio && $aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range', 404);\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * Do or do not resample image when resizing.\n */\n$resizeStrategy = getDefined(array('no-resample'), true, false);\n\nif ($resizeStrategy) {\n    $img->setCopyResizeStrategy($img::RESIZE);\n    verbose(\"Setting = Resize instead of resample\");\n}\n\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n$useOriginalDefault = getConfig('skip_original', false);\n\nif ($useOriginalDefault === true) {\n    verbose(\"skip original is default ON\");\n    $useOriginal = false;\n}\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n$qualityDefault = getConfig('jpg_quality', null);\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range', 404);\n\nif (is_null($quality) && !is_null($qualityDefault)) {\n    $quality = $qualityDefault;\n}\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n$compressDefault = getConfig('png_compression', null);\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range', 404);\n\nif (is_null($compress) && !is_null($compressDefault)) {\n    $compress = $compressDefault;\n}\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range', 404);\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range', 404);\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range', 404);\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n* json -  output the image as a JSON object with details on the image.\n* ascii - output the image as ASCII art.\n */\n$outputFormat = getDefined('json', 'json', null);\n$outputFormat = getDefined('ascii', 'ascii', $outputFormat);\n\nverbose(\"outputformat = $outputFormat\");\n\nif ($outputFormat == 'ascii') {\n    $defaultOptions = getConfig(\n        'ascii-options',\n        array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        )\n    );\n    $options = get('ascii');\n    $options = explode(',', $options);\n\n    if (isset($options[0]) && !empty($options[0])) {\n        $defaultOptions['characterSet'] = $options[0];\n    }\n\n    if (isset($options[1]) && !empty($options[1])) {\n        $defaultOptions['scale'] = $options[1];\n    }\n\n    if (isset($options[2]) && !empty($options[2])) {\n        $defaultOptions['luminanceStrategy'] = $options[2];\n    }\n\n    if (count($options) > 3) {\n        // Last option is custom character string\n        unset($options[0]);\n        unset($options[1]);\n        unset($options[2]);\n        $characterString = implode($options);\n        $defaultOptions['customCharacterSet'] = $characterString;\n    }\n\n    $img->setAsciiOptions($defaultOptions);\n}\n\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_lossy'        => false,\n    'png_lossy_cmd'    => '/usr/local/bin/pngquant --force --output',\n\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * lossy - Do lossy postprocessing, if available.\n */\n$lossy = getDefined(array('lossy'), true, null);\n\nverbose(\"lossy = $lossy\");\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\", 403);\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.', 404);\n\n} elseif ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.', 403);\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Add cache control HTTP header.\n */\n$cacheControl = getConfig('cache_control', null);\n\nif ($cacheControl) {\n    verbose(\"cacheControl = $cacheControl\");\n    $img->addHTTPHeader(\"Cache-Control\", $cacheControl);\n}\n\n\n\n/**\n * interlace - Enable configuration for interlaced progressive JPEG images.\n */\n$interlaceConfig  = getConfig('interlace', null);\n$interlaceValue   = getValue('interlace', null);\n$interlaceDefined = getDefined('interlace', true, null);\n$interlace = $interlaceValue ?? $interlaceDefined ?? $interlaceConfig;\nverbose(\"interlace (configfile) = \", $interlaceConfig);\nverbose(\"interlace = \", $interlace);\n\n\n\n/**\n * Prepare a dummy image and use it as source image.\n */\nif ($dummyImage === true) {\n    $dummyDir = $cache->getPathToSubdir(\"dummy\");\n\n    $img->setSaveFolder($dummyDir)\n        ->setSource($dummyFilename, $dummyDir)\n        ->setOptions(\n            array(\n                'newWidth'  => $newWidth,\n                'newHeight' => $newHeight,\n                'bgColor'   => $bgColor,\n            )\n        )\n        ->setJpegQuality($quality)\n        ->setPngCompression($compress)\n        ->createDummyImage()\n        ->generateFilename(null, false)\n        ->save(null, null, false);\n\n    $srcImage = $img->getTarget();\n    $imagePath = null;\n\n    verbose(\"src (updated) = $srcImage\");\n}\n\n\n\n/**\n * Prepare a sRGB version of the image and use it as source image.\n */\n$srgbDefault = getConfig('srgb_default', false);\n$srgbColorProfile = getConfig('srgb_colorprofile', __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc');\n$srgb = getDefined('srgb', true, null);\n\nif ($srgb || $srgbDefault) {\n\n    $filename = $img->convert2sRGBColorSpace(\n        $srcImage,\n        $imagePath,\n        $cache->getPathToSubdir(\"srgb\"),\n        $srgbColorProfile,\n        $useCache\n    );\n\n    if ($filename) {\n        $srcImage = $img->getTarget();\n        $imagePath = null;\n        verbose(\"srgb conversion and saved to cache = $srcImage\");\n    } else {\n        verbose(\"srgb not op\");\n    }\n}\n\n\n\n/**\n * Display status\n */\nif ($status) {\n    $text  = \"img.php version = \" . CIMAGE_VERSION . \"\\n\";\n    $text .= \"PHP version = \" . PHP_VERSION . \"\\n\";\n    $text .= \"Running on: \" . $_SERVER['SERVER_SOFTWARE'] . \"\\n\";\n    $text .= \"Allow remote images = $allowRemote\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"\");\n    $text .= \"Cache $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"remote\");\n    $text .= \"Cache remote $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"dummy\");\n    $text .= \"Cache dummy $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"srgb\");\n    $text .= \"Cache srgb $res\\n\";\n\n    $res = $cache->getStatusOfSubdir($fastTrackCache);\n    $text .= \"Cache fasttrack $res\\n\";\n\n    $text .= \"Alias path writable = \" . is_writable($aliasPath) . \"\\n\";\n\n    $no = extension_loaded('exif') ? null : 'NOT';\n    $text .= \"Extension exif is $no loaded.<br>\";\n\n    $no = extension_loaded('curl') ? null : 'NOT';\n    $text .= \"Extension curl is $no loaded.<br>\";\n\n    $no = extension_loaded('imagick') ? null : 'NOT';\n    $text .= \"Extension imagick is $no loaded.<br>\";\n\n    $no = extension_loaded('gd') ? null : 'NOT';\n    $text .= \"Extension gd is $no loaded.<br>\";\n\n    $text .= checkExternalCommand(\"PNG LOSSY\", $postProcessing[\"png_lossy\"], $postProcessing[\"png_lossy_cmd\"]);\n    $text .= checkExternalCommand(\"PNG FILTER\", $postProcessing[\"png_filter\"], $postProcessing[\"png_filter_cmd\"]);\n    $text .= checkExternalCommand(\"PNG DEFLATE\", $postProcessing[\"png_deflate\"], $postProcessing[\"png_deflate_cmd\"]);\n    $text .= checkExternalCommand(\"JPEG OPTIMIZE\", $postProcessing[\"jpeg_optimize\"], $postProcessing[\"jpeg_optimize_cmd\"]);\n\n    if (!$no) {\n        $text .= print_r(gd_info(), 1);\n    }\n\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage status</title>\n<pre>$text</pre>\nEOD;\n    exit;\n}\n\n\n\n/**\n * Log verbose details to file\n */\nif ($verboseFile) {\n    $img->setVerboseToFile(\"$cachePath/log.txt\");\n}\n\n\n\n/**\n * Hook after img.php configuration and before processing with CImage\n */\n$hookBeforeCImage = getConfig('hook_before_CImage', null);\n\nif (is_callable($hookBeforeCImage)) {\n    verbose(\"hookBeforeCImage activated\");\n\n    $allConfig = $hookBeforeCImage($img, array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n            'interlace' => $interlace,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n\n            // Other\n            'postProcessing' => $postProcessing,\n            'lossy' => $lossy,\n    ));\n    verbose(print_r($allConfig, 1));\n    extract($allConfig);\n}\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\nmime type: \" + data.mimeType + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio + ( data.pngType ? \"\\\\npng-type: \" + data.pngType : '');\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"PHP version: \" . phpversion())\n    ->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n            'interlace' => $interlace,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n\n            // Postprocessing using external tools\n            'lossy' => $lossy,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n"
  },
  {
    "path": "webroot/img_config.php",
    "content": "<?php\n/**\n * Configuration for img.php, name the config file the same as your img.php and\n * append _config. If you are testing out some in imgtest.php then label that\n * config-file imgtest_config.php.\n *\n */\n\n\n\n/**\n * Change to true to enable debug mode which logs additional information\n * to file. Only use for test and development. You must create the logfile\n * and make it writable by the webserver or log entries will silently fail.\n *\n * CIMAGE_DEBUG will be false by default, if its not defined.\n */\nif (!defined(\"CIMAGE_DEBUG\")) {\n    define(\"CIMAGE_DEBUG\", false);\n    //define(\"CIMAGE_DEBUG\", true);\n    define(\"CIMAGE_DEBUG_FILE\", \"/tmp/cimage\");\n}\n\n/**\n * Set this if you work with a webserver in Windows and try to access files\n * within WSL2.\n * The issue seems to be with functions like `is_writable()` and\n * `is_readable()`.\n * When WINDOWS2WSL is defined (to any value) it ignores these functions.\n */\n#define('WINDOWS2WSL', 1);\n\n\n\nreturn array(\n\n    /**\n     * Set mode as 'strict', 'production' or 'development'.\n     *\n     * development: Development mode with verbose error reporting. Option\n     *              &verbose and &status enabled.\n     * production:  Production mode logs all errors to file, giving server\n     *              error 500 for bad usage. Option &verbose and &status\n     *              disabled.\n     * strict:      Strict mode logs few errors to file, giving server error\n     *              500 for bad usage. Stripped from comments and spaces.\n     *              Option &verbose and &status disabled.\n     *\n     * Default values:\n     *  mode: 'production'\n     */\n     //'mode' => 'production',\n     'mode' => 'development',\n     //'mode' => 'strict',\n\n\n\n    /**\n     * Where to find the autoloader.\n     *\n     * Default values:\n     *  autoloader:  null\n     */\n    'autoloader'   =>  __DIR__ . '/../autoload.php',\n\n\n\n    /**\n     * Paths, where are the images stored and where is the cache.\n     * End all paths with a slash.\n     *\n     * Default values:\n     *  image_path:     __DIR__ . '/img/'\n     *  cache_path:     __DIR__ . '/../cache/'\n     *  alias_path:     null\n     */\n    'image_path'        =>  __DIR__ . '/img/',\n    'cache_path'        =>  __DIR__ . '/../cache/',\n    'alias_path'   =>  __DIR__ . '/img/alias/',\n\n\n\n    /**\n     * Fast track cache. Save a json representation of the image as a\n     * fast track to the cached version of the image. This avoids some\n     * processing and allows for quicker load times of cached images.\n     *\n     * Default values:\n     *  fast_track_allow: false\n     */\n    //'fast_track_allow' => true,\n\n\n\n    /**\n     * Class names to use, to ease dependency injection. You can change Class\n     * name if you want to use your own class instead. This is a way to extend\n     * the codebase.\n     *\n     * Default values:\n     *  CImage: CImage\n     *  CCache: CCache\n     *  CFastTrackCache: CFastTrackCache\n     */\n     //'CImage' => 'CImage',\n     //'CCache' => 'CCache',\n     //'CFastTrackCache' => 'CFastTrackCache',\n\n\n\n    /**\n     * Use password to protect from missusage, send &pwd=... or &password=..\n     * with the request to match the password or set to false to disable.\n     * Passwords are only used together with options for remote download\n     * and aliasing.\n     *\n     * Create a passwords like this, depending on the type used:\n     *  text: 'my_password'\n     *  md5:  md5('my_password')\n     *  hash: password_hash('my_password', PASSWORD_DEFAULT)\n     *\n     * Default values.\n     *  password_always: false  // do not always require password,\n     *  password:        false  // as in do not use password\n     *  password_type:   'text' // use plain password, not encoded,\n     */\n    //'password_always' => false, // always require password,\n    //'password'        => \"moped\", // \"secret-password\",\n    //'password_type'   => 'text', // supports 'text', 'md5', 'hash',\n\n\n\n    /**\n     * Allow or disallow downloading of remote images available on\n     * remote servers. Default is to disallow remote download.\n     *\n     * When enabling remote download, the default is to allow download any\n     * link starting with http or https. This can be changed using\n     * remote_pattern.\n     *\n     * When enabling remote_whitelist a check is made that the hostname of the\n     * source to download matches the whitelist. By default the check is\n     * disabled and thereby allowing download from any hosts.\n     *\n     * Default values.\n     *  remote_allow:     false\n     *  remote_pattern:   null  // use default values from CImage which is to\n     *                          // allow download from any http- and\n     *                          // https-source.\n     *  remote_whitelist: null  // use default values from CImage which is to\n     *                          // allow download from any hosts.\n     */\n    //'remote_allow'     => true,\n    //'remote_pattern'   => '#^https?://#',\n    //'remote_whitelist' => array(\n    //    '\\.facebook\\.com$',\n    //    '^(?:images|photos-[a-z])\\.ak\\.instagram\\.com$',\n    //    '\\.google\\.com$'\n    //),\n\n\n\n    /**\n     * Use backup image if src-image is not found on disk. The backup image\n     * is only available for local images and based on wether the original\n     * image is found on disk or not. The backup image must be a local image\n     * or the dummy image.\n     *\n     * Default value:\n     *  src_alt:  null //disabled by default\n     */\n     //'src_alt' => 'car.png',\n     //'src_alt' => 'dummy',\n\n\n\n    /**\n     * A regexp for validating characters in the image or alias filename.\n     *\n     * Default value:\n     *  valid_filename:  '#^[a-z0-9A-Z-/_ \\.:]+$#'\n     *  valid_aliasname: '#^[a-z0-9A-Z-_]+$#'\n     */\n     //'valid_filename'  => '#^[a-z0-9A-Z-/_ \\.:]+$#',\n     //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',\n\n\n\n     /**\n      * Change the default values for CImage quality and compression used\n      * when saving images.\n      *\n      * Default value:\n      *  jpg_quality:     null, integer between 0-100\n      *  png_compression: null, integer between 0-9\n      */\n      //'jpg_quality'  => 75,\n      //'png_compression' => 1,\n\n\n\n      /**\n       * Convert the image to srgb before processing. Saves the converted\n       * image in a cache subdir 'srgb'. This option is default false but can\n       * be changed to default true to do this conversion for all images.\n       * This option requires PHP extension imagick and will silently fail\n       * if that is not installed.\n       *\n       * Default value:\n       *  srgb_default:      false\n       *  srgb_colorprofile: __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'\n       */\n       //'srgb_default' => false,\n       //'srgb_colorprofile' => __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc',\n\n\n\n       /**\n        * Set skip-original to true to always process the image and use\n        * the cached version. Default is false and to use the original\n        * image when its no processing needed.\n        *\n        * Default value:\n        *  skip_original: false\n        */\n        //'skip_original' => true,\n\n\n\n      /**\n       * A function (hook) can be called after img.php has processed all\n       * configuration options and before processing the image using CImage.\n       * The function receives the $img variabel and an array with the\n       * majority of current settings.\n       *\n       * Default value:\n       *  hook_before_CImage:     null\n       */\n       /*'hook_before_CImage' => function (CImage $img, Array $allConfig) {\n           if ($allConfig['newWidth'] > 10) {\n               $allConfig['newWidth'] *= 2;\n           }\n           return $allConfig;\n       },*/\n\n\n\n       /**\n        * Add header for cache control when outputting images.\n        *\n        * Default value:\n        *  cache_control: null, or set to string\n        */\n        //'cache_control' => \"max-age=86400\",\n\n\n\n     /**\n      * The name representing a dummy image which is automatically created\n      * and stored as a image in the dir CACHE_PATH/dummy. The dummy image\n      * can then be used as a placeholder image.\n      * The dir CACHE_PATH/dummy is automatically created when needed.\n      * Write protect the CACHE_PATH/dummy to prevent creation of new\n      * dummy images, but continue to use the existing ones.\n      *\n      * Default value:\n      *  dummy_enabled:  true as default, disable dummy feature by setting\n      *                  to false.\n      *  dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.\n      */\n      //'dummy_enabled' => true,\n      //'dummy_filename' => 'dummy',\n\n\n\n     /**\n     * Check that the imagefile is a file below 'image_path' using realpath().\n     * Security constraint to avoid reaching images outside image_path.\n     * This means that symbolic links to images outside the image_path will\n     * fail.\n     *\n     * Default value:\n     *  image_path_constraint: true\n     */\n     //'image_path_constraint' => false,\n\n\n\n     /**\n     * Set default timezone.\n     *\n     * Default values.\n     *  default_timezone: ini_get('default_timezone') or 'UTC'\n     */\n    //'default_timezone' => 'UTC',\n\n\n\n    /**\n     * Max image dimensions, larger dimensions results in 404.\n     * This is basically a security constraint to avoid using resources on creating\n     * large (unwanted) images.\n     *\n     * Default values.\n     *  max_width:  2000\n     *  max_height: 2000\n     */\n    //'max_width'     => 2000,\n    //'max_height'    => 2000,\n\n\n\n    /**\n     * Set default background color for all images. Override it using\n     * option bgColor.\n     * Colorvalue is 6 digit hex string between 000000-FFFFFF\n     * or 8 digit hex string if using the alpha channel where\n     * the alpha value is between 00 (opaqe) and 7F (transparent),\n     * that is between 00000000-FFFFFF7F.\n     *\n     * Default values.\n     *  background_color: As specified by CImage\n     */\n    //'background_color' => \"FFFFFF\",\n    //'background_color' => \"FFFFFF7F\",\n\n\n\n    /**\n     * Post processing of images using external tools, set to true or false\n     * and set command to be executed.\n     *\n     * The png_lossy can alos have a value of null which means that its\n     * enabled but not used as default. Each image having the option\n     * &lossy will be processed. This means one can individually choose\n     * when to use the lossy processing.\n     *\n     * Default values.\n     *\n     *  png_lossy:        false\n     *  png_lossy_cmd:    '/usr/local/bin/pngquant --force --output'\n     *\n     *  png_filter:        false\n     *  png_filter_cmd:    '/usr/local/bin/optipng -q'\n     *\n     *  png_deflate:       false\n     *  png_deflate_cmd:   '/usr/local/bin/pngout -q'\n     *\n     *  jpeg_optimize:     false\n     *  jpeg_optimize_cmd: '/usr/local/bin/jpegtran -copy none -optimize'\n     */\n    /*\n    'postprocessing' => array(\n        'png_lossy'       => null,\n        'png_lossy_cmd'   => '/usr/local/bin/pngquant --force --output',\n\n        'png_filter'        => false,\n        'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n        'png_deflate'       => false,\n        'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n        'jpeg_optimize'     => false,\n        'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n    ),\n    */\n\n\n\n    /**\n     * Create custom convolution expressions, matrix 3x3, divisor and\n     * offset.\n     *\n     * Default values.\n     *  convolution_constant: array()\n     */\n    /*\n    'convolution_constant' => array(\n        //'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        //'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n    ),\n    */\n\n\n\n    /**\n     * Prevent leeching of images by controlling the hostname of those who\n     * can access the images. Default is to allow hotlinking.\n     *\n     * Password apply when hotlinking is disallowed, use password to allow\n     * hotlinking.\n     *\n     * The whitelist is an array of regexpes for allowed hostnames that can\n     * hotlink images.\n     *\n     * Default values.\n     *  allow_hotlinking:     true\n     *  hotlinking_whitelist: array()\n     */\n     /*\n    'allow_hotlinking' => false,\n    'hotlinking_whitelist' => array(\n        '^dbwebb\\.se$',\n    ),\n    */\n\n\n    /**\n     * Create custom shortcuts for more advanced expressions.\n     *\n     * Default values.\n     *  shortcut: array(\n     *      'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n     *  )\n     */\n     /*\n    'shortcut' => array(\n        'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n    ),*/\n\n\n\n    /**\n     * Predefined size constants.\n     *\n     * These can be used together with &width or &height to create a constant value\n     * for a width or height where can be changed in one place.\n     * Useful when your site changes its layout or if you have a grid to fit images into.\n     *\n     * Example:\n     *  &width=w1  // results in width=613\n     *  &width=c2  // results in spanning two columns with a gutter, 30*2+10=70\n     *  &width=c24 // results in spanning whole grid 24*30+((24-1)*10)=950\n     *\n     * Default values.\n     *  size_constant: As specified by the function below.\n     */\n    /*\n    'size_constant' => function () {\n\n        // Set sizes to map constant to value, easier to use with width or height\n        $sizes = array(\n          'w1' => 613,\n          'w2' => 630,\n        );\n\n        // Add grid column width, useful for use as predefined size for width (or height).\n        $gridColumnWidth = 30;\n        $gridGutterWidth = 10;\n        $gridColumns     = 24;\n\n        for ($i = 1; $i <= $gridColumns; $i++) {\n            $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n        }\n\n        return $sizes;\n    },*/\n\n\n\n    /**\n     * Predefined aspect ratios.\n     *\n     * Default values.\n     *  aspect_ratio_constant: As the function below.\n     */\n    /*'aspect_ratio_constant' => function () {\n        return array(\n            '3:1'   => 3/1,\n            '3:2'   => 3/2,\n            '4:3'   => 4/3,\n            '8:5'   => 8/5,\n            '16:10' => 16/10,\n            '16:9'  => 16/9,\n            'golden' => 1.618,\n        );\n    },*/\n\n\n\n    /**\n     * Default options for ascii image.\n     *\n     * Default values as specified below in the array.\n     *  ascii-options:\n     *   characterSet:       Choose any character set available in CAsciiArt.\n     *   scale:              How many pixels should each character\n     *                       translate to.\n     *   luminanceStrategy:  Choose any strategy available in CAsciiArt.\n     *   customCharacterSet: Define your own character set.\n     */\n    /*'ascii-options' => array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        ), */\n\n\n\n    /**\n     * Default options  for creating interlaced progressive JPEG images. Set\n     * to true to always render jpeg images as interlaced. This setting can\n     * be overridden by using `?interlace`, `?interlace=true` or\n     * `?interlace=false`.\n     *\n     * Default values are:\n     *  interlace:  false\n     */\n     /*'interlace' => false,*/\n);\n"
  },
  {
    "path": "webroot/img_header.php",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * This version is a all-in-one version of img.php, it is not dependant an any other file\n * so you can simply copy it to any place you want it.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\ndefine(\"CIMAGE_BUNDLE\", true);\n\n\n/**\n * Change configuration details in the array below or create a separate file\n * where you store the configuration details.\n *\n * The configuration file should be named the same name as this file and then\n * add '_config.php'. If this file is named 'img.php' then name the\n * config file should be named 'img_config.php'.\n *\n * The settings below are only a few of the available ones. Check the file in\n * webroot/img_config.php for a complete list of configuration options.\n */\n$config = array(\n\n    //'mode'         => 'production',               // 'production', 'development', 'strict'\n    //'image_path'   =>  __DIR__ . '/img/',\n    //'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n    //'remote_allow' => true,\n    //'password'     => false,                      // \"secret-password\",\n\n);\n"
  },
  {
    "path": "webroot/imgd.php",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * This version is a all-in-one version of img.php, it is not dependant an any other file\n * so you can simply copy it to any place you want it.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\ndefine(\"CIMAGE_BUNDLE\", true);\n\n\n/**\n * Change configuration details in the array below or create a separate file\n * where you store the configuration details.\n *\n * The configuration file should be named the same name as this file and then\n * add '_config.php'. If this file is named 'img.php' then name the\n * config file should be named 'img_config.php'.\n *\n * The settings below are only a few of the available ones. Check the file in\n * webroot/img_config.php for a complete list of configuration options.\n */\n$config = array(\n\n    'mode'         => 'development',               // 'production', 'development', 'strict'\n    //'image_path'   =>  __DIR__ . '/img/',\n    //'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n    //'remote_allow' => true,\n    //'password'     => false,                      // \"secret-password\",\n\n);\n\n\n\n// Version of cimage and img.php\ndefine(\"CIMAGE_VERSION\", \"v0.8.6 (2023-10-27)\");\n\n// For CRemoteImage\ndefine(\"CIMAGE_USER_AGENT\", \"CImage/\" . CIMAGE_VERSION);\n\n// Image type IMG_WEBP is only defined from 5.6.25\nif (!defined(\"IMG_WEBP\")) {\n    define(\"IMG_WEBP\", -1);\n}\n\n\n\n/**\n * General functions to use in img.php.\n */\n\n\n\n/**\n * Trace and log execution to logfile, useful for debugging and development.\n *\n * @param string $msg message to log to file.\n *\n * @return void\n */\nfunction trace($msg)\n{\n    $file = CIMAGE_DEBUG_FILE;\n    if (!is_writable($file)) {\n        return;\n    }\n\n    $timer = number_format((microtime(true) - $_SERVER[\"REQUEST_TIME_FLOAT\"]), 6);\n    $details  = \"{$timer}ms\";\n    $details .= \":\" . round(memory_get_peak_usage()/1024/1024, 3) . \"MB\";\n    $details .= \":\" . count(get_included_files());\n    file_put_contents($file, \"$details:$msg\\n\", FILE_APPEND);\n}\n\n\n\n/**\n * Display error message.\n *\n * @param string $msg to display.\n * @param int $type of HTTP error to display.\n *\n * @return void\n */\nfunction errorPage($msg, $type = 500)\n{\n    global $mode;\n\n    switch ($type) {\n        case 403:\n            $header = \"403 Forbidden\";\n            break;\n        case 404:\n            $header = \"404 Not Found\";\n            break;\n        default:\n            $header = \"500 Internal Server Error\";\n    }\n\n    if ($mode == \"strict\") {\n        $header = \"404 Not Found\";\n    }\n\n    header(\"HTTP/1.0 $header\");\n\n    if ($mode == \"development\") {\n        die(\"[img.php] $msg\");\n    }\n\n    error_log(\"[img.php] $msg\");\n    die(\"HTTP/1.0 $header\");\n}\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value of input from query string or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $undefined value to return when $key has no, or empty value in $_GET.\n *\n * @return mixed value as or $undefined.\n */\nfunction getValue($key, $undefined)\n{\n    $val = get($key);\n    if (is_null($val) || $val === \"\") {\n        return $undefined;\n    }\n    return $val;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null, $arg = \"\")\n{\n    global $verbose, $verboseFile;\n    static $log = array();\n\n    if (!($verbose || $verboseFile)) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    if (is_null($arg)) {\n        $arg = \"null\";\n    } elseif ($arg === false) {\n        $arg = \"false\";\n    } elseif ($arg === true) {\n        $arg = \"true\";\n    }\n\n    $log[] = $msg . $arg;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction checkExternalCommand($what, $enabled, $commandString)\n{\n    $no = $enabled ? null : 'NOT';\n    $text = \"Post processing $what is $no enabled.<br>\";\n\n    list($command) = explode(\" \", $commandString);\n    $no = is_executable($command) ? null : 'NOT';\n    $text .= \"The command for $what is $no an executable.<br>\";\n\n    return $text;\n}\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CHttpGet\n{\n    private $request  = array();\n    private $response = array();\n\n\n\n    /**\n    * Constructor\n    *\n    */\n    public function __construct()\n    {\n        $this->request['header'] = array();\n    }\n\n\n\n    /**\n     * Build an encoded url.\n     *\n     * @param string $baseUrl This is the original url which will be merged.\n     * @param string $merge   Thse parts should be merged into the baseUrl,\n     *                        the format is as parse_url.\n     *\n     * @return string $url as the modified url.\n     */\n    public function buildUrl($baseUrl, $merge)\n    {\n        $parts = parse_url($baseUrl);\n        $parts = array_merge($parts, $merge);\n\n        $url  = $parts['scheme'];\n        $url .= \"://\";\n        $url .= $parts['host'];\n        $url .= isset($parts['port'])\n            ? \":\" . $parts['port']\n            : \"\" ;\n        $url .= $parts['path'];\n\n        return $url;\n    }\n\n\n\n    /**\n     * Set the url for the request.\n     *\n     * @param string $url\n     *\n     * @return $this\n     */\n    public function setUrl($url)\n    {\n        $parts = parse_url($url);\n        \n        $path = \"\";\n        if (isset($parts['path'])) {\n            $pathParts = explode('/', $parts['path']);\n            unset($pathParts[0]);\n            foreach ($pathParts as $value) {\n                $path .= \"/\" . rawurlencode($value);\n            }\n        }\n        $url = $this->buildUrl($url, array(\"path\" => $path));\n\n        $this->request['url'] = $url;\n        return $this;\n    }\n\n\n\n    /**\n     * Set custom header field for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function setHeader($field, $value)\n    {\n        $this->request['header'][] = \"$field: $value\";\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function parseHeader()\n    {\n        //$header = explode(\"\\r\\n\", rtrim($this->response['headerRaw'], \"\\r\\n\"));\n        \n        $rawHeaders = rtrim($this->response['headerRaw'], \"\\r\\n\");\n        # Handle multiple responses e.g. with redirections (proxies too)\n        $headerGroups = explode(\"\\r\\n\\r\\n\", $rawHeaders);\n        # We're only interested in the last one\n        $header = explode(\"\\r\\n\", end($headerGroups));\n\n        $output = array();\n\n        if ('HTTP' === substr($header[0], 0, 4)) {\n            list($output['version'], $output['status']) = explode(' ', $header[0]);\n            unset($header[0]);\n        }\n\n        foreach ($header as $entry) {\n            $pos = strpos($entry, ':');\n            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));\n        }\n\n        $this->response['header'] = $output;\n        return $this;\n    }\n\n\n\n    /**\n     * Perform the request.\n     *\n     * @param boolean $debug set to true to dump headers.\n     *\n     * @throws Exception when curl fails to retrieve url.\n     *\n     * @return boolean\n     */\n    public function doGet($debug = false)\n    {\n        $options = array(\n            CURLOPT_URL             => $this->request['url'],\n            CURLOPT_HEADER          => 1,\n            CURLOPT_HTTPHEADER      => $this->request['header'],\n            CURLOPT_AUTOREFERER     => true,\n            CURLOPT_RETURNTRANSFER  => true,\n            CURLINFO_HEADER_OUT     => $debug,\n            CURLOPT_CONNECTTIMEOUT  => 5,\n            CURLOPT_TIMEOUT         => 5,\n            CURLOPT_FOLLOWLOCATION  => true,\n            CURLOPT_MAXREDIRS       => 2,\n        );\n\n        $ch = curl_init();\n        curl_setopt_array($ch, $options);\n        $response = curl_exec($ch);\n\n        if (!$response) {\n            throw new Exception(\"Failed retrieving url, details follows: \" . curl_error($ch));\n        }\n\n        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n        $this->response['headerRaw'] = substr($response, 0, $headerSize);\n        $this->response['body']      = substr($response, $headerSize);\n\n        $this->parseHeader();\n\n        if ($debug) {\n            $info = curl_getinfo($ch);\n            echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\";\n            echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\";\n            echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\";\n        }\n\n        curl_close($ch);\n        return true;\n    }\n\n\n\n    /**\n     * Get HTTP code of response.\n     *\n     * @return integer as HTTP status code or null if not available.\n     */\n    public function getStatus()\n    {\n        return isset($this->response['header']['status'])\n            ? (int) $this->response['header']['status']\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @return int as timestamp.\n     */\n    public function getLastModified()\n    {\n        return isset($this->response['header']['Last-Modified'])\n            ? strtotime($this->response['header']['Last-Modified'])\n            : null;\n    }\n\n\n\n    /**\n     * Get content type.\n     *\n     * @return string as the content type or null if not existing or invalid.\n     */\n    public function getContentType()\n    {\n        $type = isset($this->response['header']['Content-Type'])\n            ? $this->response['header']['Content-Type']\n            : '';\n\n        return preg_match('#[a-z]+/[a-z]+#', $type)\n            ? $type\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @param mixed $default as default value (int seconds) if date is\n     *                       missing in response header.\n     *\n     * @return int as timestamp or $default if Date is missing in\n     *             response header.\n     */\n    public function getDate($default = false)\n    {\n        return isset($this->response['header']['Date'])\n            ? strtotime($this->response['header']['Date'])\n            : $default;\n    }\n\n\n\n    /**\n     * Get max age of cachable item.\n     *\n     * @param mixed $default as default value if date is missing in response\n     *                       header.\n     *\n     * @return int as timestamp or false if not available.\n     */\n    public function getMaxAge($default = false)\n    {\n        $cacheControl = isset($this->response['header']['Cache-Control'])\n            ? $this->response['header']['Cache-Control']\n            : null;\n\n        $maxAge = null;\n        if ($cacheControl) {\n            // max-age=2592000\n            $part = explode('=', $cacheControl);\n            $maxAge = ($part[0] == \"max-age\")\n                ? (int) $part[1]\n                : null;\n        }\n\n        if ($maxAge) {\n            return $maxAge;\n        }\n\n        $expire = isset($this->response['header']['Expires'])\n            ? strtotime($this->response['header']['Expires'])\n            : null;\n\n        return $expire ? $expire : $default;\n    }\n\n\n\n    /**\n     * Get body of response.\n     *\n     * @return string as body.\n     */\n    public function getBody()\n    {\n        return $this->response['body'];\n    }\n}\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CRemoteImage\n{\n    /**\n     * Path to cache files.\n     */\n    private $saveFolder = null;\n\n\n\n    /**\n     * Use cache or not.\n     */\n    private $useCache = true;\n\n\n\n    /**\n     * HTTP object to aid in download file.\n     */\n    private $http;\n\n\n\n    /**\n     * Status of the HTTP request.\n     */\n    private $status;\n\n\n\n    /**\n     * Defalt age for cached items 60*60*24*7.\n     */\n    private $defaultMaxAge = 604800;\n\n\n\n    /**\n     * Url of downloaded item.\n     */\n    private $url;\n\n\n\n    /**\n     * Base name of cache file for downloaded item and name of image.\n     */\n    private $fileName;\n\n\n\n    /**\n     * Filename for json-file with details of cached item.\n     */\n    private $fileJson;\n\n\n\n    /**\n     * Cache details loaded from file.\n     */\n    private $cache;\n\n\n\n    /**\n     * Get status of last HTTP request.\n     *\n     * @return int as status\n     */\n    public function getStatus()\n    {\n        return $this->status;\n    }\n\n\n\n    /**\n     * Get JSON details for cache item.\n     *\n     * @return array with json details on cache.\n     */\n    public function getDetails()\n    {\n        return $this->cache;\n    }\n\n\n\n    /**\n     * Set the path to the cache directory.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function setCache($path)\n    {\n        $this->saveFolder = rtrim($path, \"/\") . \"/\";\n        return $this;\n    }\n\n\n\n    /**\n     * Check if cache is writable or throw exception.\n     *\n     * @return $this\n     *\n     * @throws Exception if cahce folder is not writable.\n     */\n    public function isCacheWritable()\n    {\n        if (!is_writable($this->saveFolder)) {\n            throw new Exception(\"Cache folder is not writable for downloaded files.\");\n        }\n        return $this;\n    }\n\n\n\n    /**\n     * Decide if the cache should be used or not before trying to download\n     * a remote file.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields.\n     *\n     * @return $this\n     */\n    public function setHeaderFields()\n    {\n        $cimageVersion = \"CImage\";\n        if (defined(\"CIMAGE_USER_AGENT\")) {\n            $cimageVersion = CIMAGE_USER_AGENT;\n        }\n        \n        $this->http->setHeader(\"User-Agent\", \"$cimageVersion (PHP/\". phpversion() . \" cURL)\");\n        $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\");\n\n        if ($this->useCache) {\n            $this->http->setHeader(\"Cache-Control\", \"max-age=0\");\n        } else {\n            $this->http->setHeader(\"Cache-Control\", \"no-cache\");\n            $this->http->setHeader(\"Pragma\", \"no-cache\");\n        }\n    }\n\n\n\n    /**\n     * Save downloaded resource to cache.\n     *\n     * @return string as path to saved file or false if not saved.\n     */\n    public function save()\n    {\n        $this->cache = array();\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n        $type         = $this->http->getContentType();\n\n        $this->cache['Date']           = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']        = $maxAge;\n        $this->cache['Content-Type']   = $type;\n        $this->cache['Url']            = $this->url;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        // Save only if body is a valid image\n        $body = $this->http->getBody();\n        $img = imagecreatefromstring($body);\n\n        if ($img !== false) {\n            file_put_contents($this->fileName, $body);\n            file_put_contents($this->fileJson, json_encode($this->cache));\n            return $this->fileName;\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Got a 304 and updates cache with new age.\n     *\n     * @return string as path to cached file.\n     */\n    public function updateCacheDetails()\n    {\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n\n        $this->cache['Date']    = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age'] = $maxAge;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        file_put_contents($this->fileJson, json_encode($this->cache));\n        return $this->fileName;\n    }\n\n\n\n    /**\n     * Download a remote file and keep a cache of downloaded files.\n     *\n     * @param string $url a remote url.\n     *\n     * @throws Exception when status code does not match 200 or 304.\n     *\n     * @return string as path to downloaded file or false if failed.\n     */\n    public function download($url)\n    {\n        $this->http = new CHttpGet();\n        $this->url = $url;\n\n        // First check if the cache is valid and can be used\n        $this->loadCacheDetails();\n\n        if ($this->useCache) {\n            $src = $this->getCachedSource();\n            if ($src) {\n                $this->status = 1;\n                return $src;\n            }\n        }\n\n        // Do a HTTP request to download item\n        $this->setHeaderFields();\n        $this->http->setUrl($this->url);\n        $this->http->doGet();\n\n        $this->status = $this->http->getStatus();\n        if ($this->status === 200) {\n            $this->isCacheWritable();\n            return $this->save();\n        } elseif ($this->status === 304) {\n            $this->isCacheWritable();\n            return $this->updateCacheDetails();\n        }\n\n        throw new Exception(\"Unknown statuscode when downloading remote image: \" . $this->status);\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return $this\n     */\n    public function loadCacheDetails()\n    {\n        $cacheFile = md5($this->url);\n        $this->fileName = $this->saveFolder . $cacheFile;\n        $this->fileJson = $this->fileName . \".json\";\n        if (is_readable($this->fileJson)) {\n            $this->cache = json_decode(file_get_contents($this->fileJson), true);\n        }\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return string as the path ot the image file or false if no cache.\n     */\n    public function getCachedSource()\n    {\n        $imageExists = is_readable($this->fileName);\n\n        // Is cache valid?\n        $date   = strtotime($this->cache['Date']);\n        $maxAge = $this->cache['Max-Age'];\n        $now    = time();\n        \n        if ($imageExists && $date + $maxAge > $now) {\n            return $this->fileName;\n        }\n\n        // Prepare for a 304 if available\n        if ($imageExists && isset($this->cache['Last-Modified'])) {\n            $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']);\n        }\n\n        return false;\n    }\n}\n\n\n\n/**\n * Act as whitelist (or blacklist).\n *\n */\nclass CWhitelist\n{\n    /**\n     * Array to contain the whitelist options.\n     */\n    private $whitelist = array();\n\n\n\n    /**\n     * Set the whitelist from an array of strings, each item in the\n     * whitelist should be a regexp without the surrounding / or #.\n     *\n     * @param array $whitelist with all valid options,\n     *                         default is to clear the whitelist.\n     *\n     * @return $this\n     */\n    public function set($whitelist = array())\n    {\n        if (!is_array($whitelist)) {\n            throw new Exception(\"Whitelist is not of a supported format.\");\n        }\n\n        $this->whitelist = $whitelist;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if item exists in the whitelist.\n     *\n     * @param string $item      string to check.\n     * @param array  $whitelist optional with all valid options, default is null.\n     *\n     * @return boolean true if item is in whitelist, else false.\n     */\n    public function check($item, $whitelist = null)\n    {\n        if ($whitelist !== null) {\n            $this->set($whitelist);\n        }\n        \n        if (empty($item) or empty($this->whitelist)) {\n            return false;\n        }\n        \n        foreach ($this->whitelist as $regexp) {\n            if (preg_match(\"#$regexp#\", $item)) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n}\n\n\n\n/**\n * Create an ASCII version of an image.\n *\n */\nclass CAsciiArt\n{\n    /**\n     * Character set to use.\n     */\n    private $characterSet = array(\n        'one' => \"#0XT|:,.' \",\n        'two' => \"@%#*+=-:. \",\n        'three' => \"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\\\"^`'. \"\n    );\n\n\n\n    /**\n     * Current character set.\n     */\n    private $characters = null;\n\n\n\n    /**\n     * Length of current character set.\n     */\n    private $charCount = null;\n\n\n\n    /**\n     * Scale of the area to swap to a character.\n     */\n    private $scale = null;\n\n\n\n    /**\n     * Strategy to calculate luminance.\n     */\n    private $luminanceStrategy = null;\n\n\n\n    /**\n     * Constructor which sets default options.\n     */\n    public function __construct()\n    {\n        $this->setOptions();\n    }\n\n\n\n    /**\n     * Add a custom character set.\n     *\n     * @param string $key   for the character set.\n     * @param string $value for the character set.\n     *\n     * @return $this\n     */\n    public function addCharacterSet($key, $value)\n    {\n        $this->characterSet[$key] = $value;\n        return $this;\n    }\n\n\n\n    /**\n     * Set options for processing, defaults are available.\n     *\n     * @param array $options to use as default settings.\n     *\n     * @return $this\n     */\n    public function setOptions($options = array())\n    {\n        $default = array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        );\n        $default = array_merge($default, $options);\n        \n        if (!is_null($default['customCharacterSet'])) {\n            $this->addCharacterSet('custom', $default['customCharacterSet']);\n            $default['characterSet'] = 'custom';\n        }\n        \n        $this->scale = $default['scale'];\n        $this->characters = $this->characterSet[$default['characterSet']];\n        $this->charCount = strlen($this->characters);\n        $this->luminanceStrategy = $default['luminanceStrategy'];\n        \n        return $this;\n    }\n\n\n\n    /**\n     * Create an Ascii image from an image file.\n     *\n     * @param string $filename of the image to use.\n     *\n     * @return string $ascii with the ASCII image.\n     */\n    public function createFromFile($filename)\n    {\n        $img = imagecreatefromstring(file_get_contents($filename));\n        list($width, $height) = getimagesize($filename);\n\n        $ascii = null;\n        $incY = $this->scale;\n        $incX = $this->scale / 2;\n        \n        for ($y = 0; $y < $height - 1; $y += $incY) {\n            for ($x = 0; $x < $width - 1; $x += $incX) {\n                $toX = min($x + $this->scale / 2, $width - 1);\n                $toY = min($y + $this->scale, $height - 1);\n                $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);\n                $ascii .= $this->luminance2character($luminance);\n            }\n            $ascii .= PHP_EOL;\n        }\n\n        return $ascii;\n    }\n\n\n\n    /**\n     * Get the luminance from a region of an image using average color value.\n     *\n     * @param string  $img the image.\n     * @param integer $x1  the area to get pixels from.\n     * @param integer $y1  the area to get pixels from.\n     * @param integer $x2  the area to get pixels from.\n     * @param integer $y2  the area to get pixels from.\n     *\n     * @return integer $luminance with a value between 0 and 100.\n     */\n    public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2)\n    {\n        $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1);\n        $luminance = 0;\n        \n        for ($x = $x1; $x <= $x2; $x++) {\n            for ($y = $y1; $y <= $y2; $y++) {\n                $rgb   = imagecolorat($img, $x, $y);\n                $red   = (($rgb >> 16) & 0xFF);\n                $green = (($rgb >> 8) & 0xFF);\n                $blue  = ($rgb & 0xFF);\n                $luminance += $this->getLuminance($red, $green, $blue);\n            }\n        }\n        \n        return $luminance / $numPixels;\n    }\n\n\n\n    /**\n     * Calculate luminance value with different strategies.\n     *\n     * @param integer $red   The color red.\n     * @param integer $green The color green.\n     * @param integer $blue  The color blue.\n     *\n     * @return float $luminance with a value between 0 and 1.\n     */\n    public function getLuminance($red, $green, $blue)\n    {\n        switch ($this->luminanceStrategy) {\n            case 1:\n                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;\n                break;\n            case 2:\n                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;\n                break;\n            case 3:\n                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;\n                break;\n            case 0:\n            default:\n                $luminance = ($red + $green + $blue) / (255 * 3);\n        }\n\n        return $luminance;\n    }\n\n\n\n    /**\n     * Translate the luminance value to a character.\n     *\n     * @param string $position a value between 0-100 representing the\n     *                         luminance.\n     *\n     * @return string with the ascii character.\n     */\n    public function luminance2character($luminance)\n    {\n        $position = (int) round($luminance * ($this->charCount - 1));\n        $char = $this->characters[$position];\n        return $char;\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n */\n#[AllowDynamicProperties]\nclass CImage\n{\n\n    /**\n     * Constants type of PNG image\n     */\n    const PNG_GREYSCALE         = 0;\n    const PNG_RGB               = 2;\n    const PNG_RGB_PALETTE       = 3;\n    const PNG_GREYSCALE_ALPHA   = 4;\n    const PNG_RGB_ALPHA         = 6;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const JPEG_QUALITY_DEFAULT = 60;\n\n\n\n    /**\n     * Quality level for JPEG images.\n     */\n    private $quality;\n\n\n\n    /**\n     * Is the quality level set from external use (true) or is it default (false)?\n     */\n    private $useQuality = false;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const PNG_COMPRESSION_DEFAULT = -1;\n\n\n\n    /**\n     * Compression level for PNG images.\n     */\n    private $compress;\n\n\n\n    /**\n     * Is the compress level set from external use (true) or is it default (false)?\n     */\n    private $useCompress = false;\n\n\n\n\n    /**\n     * Add HTTP headers for outputing image.\n     */\n    private $HTTPHeader = array();\n\n\n\n    /**\n     * Default background color, red, green, blue, alpha.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    /*\n    const BACKGROUND_COLOR = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );*/\n\n\n\n    /**\n     * Default background color to use.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    //private $bgColorDefault = self::BACKGROUND_COLOR;\n    private $bgColorDefault = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );\n\n\n    /**\n     * Background color to use, specified as part of options.\n     */\n    private $bgColor;\n\n\n\n    /**\n     * Where to save the target file.\n     */\n    private $saveFolder;\n\n\n\n    /**\n     * The working image object.\n     */\n    private $image;\n\n\n\n    /**\n     * Image filename, may include subdirectory, relative from $imageFolder\n     */\n    private $imageSrc;\n\n\n\n    /**\n     * Actual path to the image, $imageFolder . '/' . $imageSrc\n     */\n    private $pathToImage;\n\n\n\n    /**\n     * File type for source image, as provided by getimagesize()\n     */\n    private $fileType;\n\n\n\n    /**\n     * File extension to use when saving image.\n     */\n    private $extension;\n\n\n\n    /**\n     * Output format, supports null (image) or json.\n     */\n    private $outputFormat = null;\n\n\n\n    /**\n     * Do lossy output using external postprocessing tools.\n     */\n    private $lossy = null;\n\n\n\n    /**\n     * Verbose mode to print out a trace and display the created image\n     */\n    private $verbose = false;\n\n\n\n    /**\n     * Keep a log/trace on what happens\n     */\n    private $log = array();\n\n\n\n    /**\n     * Handle image as palette image\n     */\n    private $palette;\n\n\n\n    /**\n     * Target filename, with path, to save resulting image in.\n     */\n    private $cacheFileName;\n\n\n\n    /**\n     * Set a format to save image as, or null to use original format.\n     */\n    private $saveAs;\n\n\n    /**\n     * Path to command for lossy optimize, for example pngquant.\n     */\n    private $pngLossy;\n    private $pngLossyCmd;\n\n\n\n    /**\n     * Path to command for filter optimize, for example optipng.\n     */\n    private $pngFilter;\n    private $pngFilterCmd;\n\n\n\n    /**\n     * Path to command for deflate optimize, for example pngout.\n     */\n    private $pngDeflate;\n    private $pngDeflateCmd;\n\n\n\n    /**\n     * Path to command to optimize jpeg images, for example jpegtran or null.\n     */\n     private $jpegOptimize;\n     private $jpegOptimizeCmd;\n\n\n\n    /**\n     * Image dimensions, calculated from loaded image.\n     */\n    private $width;  // Calculated from source image\n    private $height; // Calculated from source image\n\n\n    /**\n     * New image dimensions, incoming as argument or calculated.\n     */\n    private $newWidth;\n    private $newWidthOrig;  // Save original value\n    private $newHeight;\n    private $newHeightOrig; // Save original value\n\n\n    /**\n     * Change target height & width when different dpr, dpr 2 means double image dimensions.\n     */\n    private $dpr = 1;\n\n\n    /**\n     * Always upscale images, even if they are smaller than target image.\n     */\n    const UPSCALE_DEFAULT = true;\n    private $upscale = self::UPSCALE_DEFAULT;\n\n\n\n    /**\n     * Array with details on how to crop, incoming as argument and calculated.\n     */\n    public $crop;\n    public $cropOrig; // Save original value\n\n\n    /**\n     * String with details on how to do image convolution. String\n     * should map a key in the $convolvs array or be a string of\n     * 11 float values separated by comma. The first nine builds\n     * up the matrix, then divisor and last offset.\n     */\n    private $convolve;\n\n\n    /**\n     * Custom convolution expressions, matrix 3x3, divisor and offset.\n     */\n    private $convolves = array(\n        'lighten'       => '0,0,0, 0,12,0, 0,0,0, 9, 0',\n        'darken'        => '0,0,0, 0,6,0, 0,0,0, 9, 0',\n        'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n        'emboss'        => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0',\n        'emboss-alt'    => '-2,-1,0, -1,1,1, 0,1,2, 1, 0',\n        'blur'          => '1,1,1, 1,15,1, 1,1,1, 23, 0',\n        'gblur'         => '1,2,1, 2,4,2, 1,2,1, 16, 0',\n        'edge'          => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0',\n        'edge-alt'      => '0,1,0, 1,-4,1, 0,1,0, 1, 0',\n        'draw'          => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0',\n        'mean'          => '1,1,1, 1,1,1, 1,1,1, 9, 0',\n        'motion'        => '1,0,0, 0,1,0, 0,0,1, 3, 0',\n    );\n\n\n    /**\n     * Resize strategy to fill extra area with background color.\n     * True or false.\n     */\n    private $fillToFit;\n\n\n\n    /**\n     * To store value for option scale.\n     */\n    private $scale;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateBefore;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateAfter;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $autoRotate;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $sharpen;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $emboss;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $blur;\n\n\n\n    /**\n     * Used with option area to set which parts of the image to use.\n     */\n    private $offset;\n\n\n\n    /**\n     * Calculate target dimension for image when using fill-to-fit resize strategy.\n     */\n    private $fillWidth;\n    private $fillHeight;\n\n\n\n    /**\n     * Allow remote file download, default is to disallow remote file download.\n     */\n    private $allowRemote = false;\n\n\n\n    /**\n     * Path to cache for remote download.\n     */\n    private $remoteCache;\n\n\n\n    /**\n     * Pattern to recognize a remote file.\n     */\n    //private $remotePattern = '#^[http|https]://#';\n    private $remotePattern = '#^https?://#';\n\n\n\n    /**\n     * Use the cache if true, set to false to ignore the cached file.\n     */\n    private $useCache = true;\n\n\n    /**\n    * Disable the fasttrackCacke to start with, inject an object to enable it.\n    */\n    private $fastTrackCache = null;\n\n\n\n    /*\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     */\n    private $remoteHostWhitelist = null;\n\n\n\n    /*\n     * Do verbose logging to file by setting this to a filename.\n     */\n    private $verboseFileName = null;\n\n\n\n    /*\n     * Output to ascii can take som options as an array.\n     */\n    private $asciiOptions = array();\n\n\n\n    /*\n     * Use interlaced progressive mode for JPEG images.\n     */\n    private $interlace = false;\n\n\n\n    /*\n     * Image copy strategy, defaults to RESAMPLE.\n     */\n     const RESIZE = 1;\n     const RESAMPLE = 2;\n     private $copyStrategy = NULL;\n\n\n\n    /**\n     * Properties, the class is mutable and the method setOptions()\n     * decides (partly) what properties are created.\n     *\n     * @todo Clean up these and check if and how they are used\n     */\n\n    public $keepRatio;\n    public $cropToFit;\n    private $cropWidth;\n    private $cropHeight;\n    public $crop_x;\n    public $crop_y;\n    public $filters;\n    private $attr; // Calculated from source image\n\n\n\n\n    /**\n     * Constructor, can take arguments to init the object.\n     *\n     * @param string $imageSrc    filename which may contain subdirectory.\n     * @param string $imageFolder path to root folder for images.\n     * @param string $saveFolder  path to folder where to save the new file or null to skip saving.\n     * @param string $saveName    name of target file when saveing.\n     */\n    public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null)\n    {\n        $this->setSource($imageSrc, $imageFolder);\n        $this->setTarget($saveFolder, $saveName);\n    }\n\n\n\n    /**\n     * Inject object and use it, must be available as member.\n     *\n     * @param string $property to set as object.\n     * @param object $object   to set to property.\n     *\n     * @return $this\n     */\n    public function injectDependency($property, $object)\n    {\n        if (!property_exists($this, $property)) {\n            $this->raiseError(\"Injecting unknown property.\");\n        }\n        $this->$property = $object;\n        return $this;\n    }\n\n\n\n    /**\n     * Set verbose mode.\n     *\n     * @param boolean $mode true or false to enable and disable verbose mode,\n     *                      default is true.\n     *\n     * @return $this\n     */\n    public function setVerbose($mode = true)\n    {\n        $this->verbose = $mode;\n        return $this;\n    }\n\n\n\n    /**\n     * Set save folder, base folder for saving cache files.\n     *\n     * @todo clean up how $this->saveFolder is used in other methods.\n     *\n     * @param string $path where to store cached files.\n     *\n     * @return $this\n     */\n    public function setSaveFolder($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Use cache or not.\n     *\n     * @param boolean $use true or false to use cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Create and save a dummy image. Use dimensions as stated in\n     * $this->newWidth, or $width or default to 100 (same for height.\n     *\n     * @param integer $width  use specified width for image dimension.\n     * @param integer $height use specified width for image dimension.\n     *\n     * @return $this\n     */\n    public function createDummyImage($width = null, $height = null)\n    {\n        $this->newWidth  = $this->newWidth  ?: $width  ?: 100;\n        $this->newHeight = $this->newHeight ?: $height ?: 100;\n\n        $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Allow or disallow remote image download.\n     *\n     * @param boolean $allow   true or false to enable and disable.\n     * @param string  $cache   path to cache dir.\n     * @param string  $pattern to use to detect if its a remote file.\n     *\n     * @return $this\n     */\n    public function setRemoteDownload($allow, $cache, $pattern = null)\n    {\n        $this->allowRemote = $allow;\n        $this->remoteCache = $cache;\n        $this->remotePattern = is_null($pattern) ? $this->remotePattern : $pattern;\n\n        $this->log(\n            \"Set remote download to: \"\n            . ($this->allowRemote ? \"true\" : \"false\")\n            . \" using pattern \"\n            . $this->remotePattern\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the image resource is a remote file or not.\n     *\n     * @param string $src check if src is remote.\n     *\n     * @return boolean true if $src is a remote file, else false.\n     */\n    public function isRemoteSource($src)\n    {\n        $remote = preg_match($this->remotePattern, $src);\n        $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\"));\n        return !!$remote;\n    }\n\n\n\n    /**\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     *\n     * @param array $whitelist with regexp hostnames to allow download from.\n     *\n     * @return $this\n     */\n    public function setRemoteHostWhitelist($whitelist = null)\n    {\n        $this->remoteHostWhitelist = $whitelist;\n        $this->log(\n            \"Setting remote host whitelist to: \"\n            . (is_null($whitelist) ? \"null\" : print_r($whitelist, 1))\n        );\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the hostname for the remote image, is on a whitelist,\n     * if the whitelist is defined.\n     *\n     * @param string $src the remote source.\n     *\n     * @return boolean true if hostname on $src is in the whitelist, else false.\n     */\n    public function isRemoteSourceOnWhitelist($src)\n    {\n        if (is_null($this->remoteHostWhitelist)) {\n            $this->log(\"Remote host on whitelist not configured - allowing.\");\n            return true;\n        }\n\n        $whitelist = new CWhitelist();\n        $hostname = parse_url($src, PHP_URL_HOST);\n        $allow = $whitelist->check($hostname, $this->remoteHostWhitelist);\n\n        $this->log(\n            \"Remote host is on whitelist: \"\n            . ($allow ? \"true\" : \"false\")\n        );\n        return $allow;\n    }\n\n\n\n    /**\n     * Check if file extension is valid as a file extension.\n     *\n     * @param string $extension of image file.\n     *\n     * @return $this\n     */\n    private function checkFileExtension($extension)\n    {\n        $valid = array('jpg', 'jpeg', 'png', 'gif', 'webp');\n\n        in_array(strtolower($extension), $valid)\n            or $this->raiseError('Not a valid file extension.');\n\n        return $this;\n    }\n\n\n\n    /**\n     * Normalize the file extension.\n     *\n     * @param string $extension of image file or skip to use internal.\n     *\n     * @return string $extension as a normalized file extension.\n     */\n    private function normalizeFileExtension($extension = \"\")\n    {\n        $extension = strtolower($extension ? $extension : $this->extension ?? \"\");\n\n        if ($extension == 'jpeg') {\n                $extension = 'jpg';\n        }\n\n        return $extension;\n    }\n\n\n\n    /**\n     * Download a remote image and return path to its local copy.\n     *\n     * @param string $src remote path to image.\n     *\n     * @return string as path to downloaded remote source.\n     */\n    public function downloadRemoteSource($src)\n    {\n        if (!$this->isRemoteSourceOnWhitelist($src)) {\n            throw new Exception(\"Hostname is not on whitelist for remote sources.\");\n        }\n\n        $remote = new CRemoteImage();\n\n        if (!is_writable($this->remoteCache)) {\n            $this->log(\"The remote cache is not writable.\");\n        }\n\n        $remote->setCache($this->remoteCache);\n        $remote->useCache($this->useCache);\n        $src = $remote->download($src);\n\n        $this->log(\"Remote HTTP status: \" . $remote->getStatus());\n        $this->log(\"Remote item is in local cache: $src\");\n        $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true));\n\n        return $src;\n    }\n\n\n\n    /**\n     * Set source file to use as image source.\n     *\n     * @param string $src of image.\n     * @param string $dir as optional base directory where images are.\n     *\n     * @return $this\n     */\n    public function setSource($src, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->imageSrc = null;\n            $this->pathToImage = null;\n            return $this;\n        }\n\n        if ($this->allowRemote && $this->isRemoteSource($src)) {\n            $src = $this->downloadRemoteSource($src);\n            $dir = null;\n        }\n\n        if (!isset($dir)) {\n            $dir = dirname($src);\n            $src = basename($src);\n        }\n\n        $this->imageSrc     = ltrim($src, '/');\n        $imageFolder        = rtrim($dir, '/');\n        $this->pathToImage  = $imageFolder . '/' . $this->imageSrc;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set target file.\n     *\n     * @param string $src of target image.\n     * @param string $dir as optional base directory where images are stored.\n     *                    Uses $this->saveFolder if null.\n     *\n     * @return $this\n     */\n    public function setTarget($src = null, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->cacheFileName = null;\n            return $this;\n        }\n\n        if (isset($dir)) {\n            $this->saveFolder = rtrim($dir, '/');\n        }\n\n        $this->cacheFileName  = $this->saveFolder . '/' . $src;\n\n        // Sanitize filename\n        $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName);\n        $this->log(\"The cache file name is: \" . $this->cacheFileName);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get filename of target file.\n     *\n     * @return Boolean|String as filename of target or false if not set.\n     */\n    public function getTarget()\n    {\n        return $this->cacheFileName;\n    }\n\n\n\n    /**\n     * Set options to use when processing image.\n     *\n     * @param array $args used when processing image.\n     *\n     * @return $this\n     */\n    public function setOptions($args)\n    {\n        $this->log(\"Set new options for processing image.\");\n\n        $defaults = array(\n            // Options for calculate dimensions\n            'newWidth'    => null,\n            'newHeight'   => null,\n            'aspectRatio' => null,\n            'keepRatio'   => true,\n            'cropToFit'   => false,\n            'fillToFit'   => null,\n            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),\n            'area'        => null, //'0,0,0,0',\n            'upscale'     => self::UPSCALE_DEFAULT,\n\n            // Options for caching or using original\n            'useCache'    => true,\n            'useOriginal' => true,\n\n            // Pre-processing, before resizing is done\n            'scale'        => null,\n            'rotateBefore' => null,\n            'autoRotate'  => false,\n\n            // General options\n            'bgColor'     => null,\n\n            // Post-processing, after resizing is done\n            'palette'     => null,\n            'filters'     => null,\n            'sharpen'     => null,\n            'emboss'      => null,\n            'blur'        => null,\n            'convolve'       => null,\n            'rotateAfter' => null,\n            'interlace' => null,\n\n            // Output format\n            'outputFormat' => null,\n            'dpr'          => 1,\n\n            // Postprocessing using external tools\n            'lossy' => null,\n        );\n\n        // Convert crop settings from string to array\n        if (isset($args['crop']) && !is_array($args['crop'])) {\n            $pices = explode(',', $args['crop']);\n            $args['crop'] = array(\n                'width'   => $pices[0],\n                'height'  => $pices[1],\n                'start_x' => $pices[2],\n                'start_y' => $pices[3],\n            );\n        }\n\n        // Convert area settings from string to array\n        if (isset($args['area']) && !is_array($args['area'])) {\n                $pices = explode(',', $args['area']);\n                $args['area'] = array(\n                    'top'    => $pices[0],\n                    'right'  => $pices[1],\n                    'bottom' => $pices[2],\n                    'left'   => $pices[3],\n                );\n        }\n\n        // Convert filter settings from array of string to array of array\n        if (isset($args['filters']) && is_array($args['filters'])) {\n            foreach ($args['filters'] as $key => $filterStr) {\n                $parts = explode(',', $filterStr);\n                $filter = $this->mapFilter($parts[0]);\n                $filter['str'] = $filterStr;\n                for ($i=1; $i<=$filter['argc']; $i++) {\n                    if (isset($parts[$i])) {\n                        $filter[\"arg{$i}\"] = $parts[$i];\n                    } else {\n                        throw new Exception(\n                            'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php'\n                        );\n                    }\n                }\n                $args['filters'][$key] = $filter;\n            }\n        }\n\n        // Merge default arguments with incoming and set properties.\n        //$args = array_merge_recursive($defaults, $args);\n        $args = array_merge($defaults, $args);\n        foreach ($defaults as $key => $val) {\n            $this->{$key} = $args[$key];\n        }\n\n        if ($this->bgColor) {\n            $this->setDefaultBackgroundColor($this->bgColor);\n        }\n\n        // Save original values to enable re-calculating\n        $this->newWidthOrig  = $this->newWidth;\n        $this->newHeightOrig = $this->newHeight;\n        $this->cropOrig      = $this->crop;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Map filter name to PHP filter and id.\n     *\n     * @param string $name the name of the filter.\n     *\n     * @return array with filter settings\n     * @throws Exception\n     */\n    private function mapFilter($name)\n    {\n        $map = array(\n            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),\n            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),\n            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),\n            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),\n            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),\n            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),\n            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),\n            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),\n            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),\n            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),\n            'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),\n            'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),\n        );\n\n        if (isset($map[$name])) {\n            return $map[$name];\n        } else {\n            throw new Exception('No such filter.');\n        }\n    }\n\n\n\n    /**\n     * Load image details from original image file.\n     *\n     * @param string $file the file to load or null to use $this->pathToImage.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function loadImageDetails($file = null)\n    {\n        $file = $file ? $file : $this->pathToImage;\n\n        // Special case to solve Windows 2 WSL integration\n        if (!defined('WINDOWS2WSL')) {\n            is_readable($file)\n                or $this->raiseError('Image file does not exist.');\n        }\n\n        $info = list($this->width, $this->height, $this->fileType) = getimagesize($file);\n        if (empty($info)) {\n            // To support webp\n            $this->fileType = false;\n            if (function_exists(\"exif_imagetype\")) {\n                $this->fileType = exif_imagetype($file);\n                if ($this->fileType === false) {\n                    if (function_exists(\"imagecreatefromwebp\")) {\n                        $webp = imagecreatefromwebp($file);\n                        if ($webp !== false) {\n                            $this->width  = imagesx($webp);\n                            $this->height = imagesy($webp);\n                            $this->fileType = IMG_WEBP;\n                        }\n                    }\n                }\n            }\n        }\n\n        if (!$this->fileType) {\n            throw new Exception(\"Loading image details, the file doesn't seem to be a valid image.\");\n        }\n\n        if ($this->verbose) {\n            $this->log(\"Loading image details for: {$file}\");\n            $this->log(\" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType}).\");\n            $this->log(\" Image filesize: \" . filesize($file) . \" bytes.\");\n            $this->log(\" Image mimetype: \" . $this->getMimeType());\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get mime type for image type.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    protected function getMimeType()\n    {\n        if ($this->fileType === IMG_WEBP) {\n            return \"image/webp\";\n        }\n\n        return image_type_to_mime_type($this->fileType);\n    }\n\n\n\n    /**\n     * Init new width and height and do some sanity checks on constraints, before any\n     * processing can be done.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function initDimensions()\n    {\n        $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // width as %\n        if ($this->newWidth\n            && $this->newWidth[strlen($this->newWidth)-1] == '%') {\n            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;\n            $this->log(\"Setting new width based on % to {$this->newWidth}\");\n        }\n\n        // height as %\n        if ($this->newHeight\n            && $this->newHeight[strlen($this->newHeight)-1] == '%') {\n            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;\n            $this->log(\"Setting new height based on % to {$this->newHeight}\");\n        }\n\n        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');\n\n        // width & height from aspect ratio\n        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {\n            if ($this->aspectRatio >= 1) {\n                $this->newWidth   = $this->width;\n                $this->newHeight  = $this->width / $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n\n            } else {\n                $this->newHeight  = $this->height;\n                $this->newWidth   = $this->height * $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n            }\n\n        } elseif ($this->aspectRatio && is_null($this->newWidth)) {\n            $this->newWidth   = $this->newHeight * $this->aspectRatio;\n            $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\");\n\n        } elseif ($this->aspectRatio && is_null($this->newHeight)) {\n            $this->newHeight  = $this->newWidth / $this->aspectRatio;\n            $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\");\n        }\n\n        // Change width & height based on dpr\n        if ($this->dpr != 1) {\n            if (!is_null($this->newWidth)) {\n                $this->newWidth  = round($this->newWidth * $this->dpr);\n                $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\");\n            }\n            if (!is_null($this->newHeight)) {\n                $this->newHeight = round($this->newHeight * $this->dpr);\n                $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\");\n            }\n        }\n\n        // Check values to be within domain\n        is_null($this->newWidth)\n            or is_numeric($this->newWidth)\n            or $this->raiseError('Width not numeric');\n\n        is_null($this->newHeight)\n            or is_numeric($this->newHeight)\n            or $this->raiseError('Height not numeric');\n\n        $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Calculate new width and height of image, based on settings.\n     *\n     * @return $this\n     */\n    public function calculateNewWidthAndHeight()\n    {\n        // Crop, use cropped width and height as base for calulations\n        $this->log(\"Calculate new width and height.\");\n        $this->log(\"Original width x height is {$this->width} x {$this->height}.\");\n        $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // Check if there is an area to crop off\n        if (isset($this->area)) {\n            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);\n            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);\n            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);\n            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);\n            $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];\n            $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];\n            $this->width  = $this->offset['width'];\n            $this->height = $this->offset['height'];\n            $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\");\n            $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\");\n        }\n\n        $width  = $this->width;\n        $height = $this->height;\n\n        // Check if crop is set\n        if ($this->crop) {\n            $width  = $this->crop['width']  = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];\n            $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];\n\n            if ($this->crop['start_x'] == 'left') {\n                $this->crop['start_x'] = 0;\n            } elseif ($this->crop['start_x'] == 'right') {\n                $this->crop['start_x'] = $this->width - $width;\n            } elseif ($this->crop['start_x'] == 'center') {\n                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);\n            }\n\n            if ($this->crop['start_y'] == 'top') {\n                $this->crop['start_y'] = 0;\n            } elseif ($this->crop['start_y'] == 'bottom') {\n                $this->crop['start_y'] = $this->height - $height;\n            } elseif ($this->crop['start_y'] == 'center') {\n                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);\n            }\n\n            $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\");\n        }\n\n        // Calculate new width and height if keeping aspect-ratio.\n        if ($this->keepRatio) {\n\n            $this->log(\"Keep aspect ratio.\");\n\n            // Crop-to-fit and both new width and height are set.\n            if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Use newWidth and newHeigh as width/height, image should fit in box.\n                $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\");\n\n            } elseif (isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Both new width and height are set.\n                // Use newWidth and newHeigh as max width/height, image should not be larger.\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n                $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;\n                $this->newWidth  = round($width  / $ratio);\n                $this->newHeight = round($height / $ratio);\n                $this->log(\"New width and height was set.\");\n\n            } elseif (isset($this->newWidth)) {\n\n                // Use new width as max-width\n                $factor = (float)$this->newWidth / (float)$width;\n                $this->newHeight = round($factor * $height);\n                $this->log(\"New width was set.\");\n\n            } elseif (isset($this->newHeight)) {\n\n                // Use new height as max-hight\n                $factor = (float)$this->newHeight / (float)$height;\n                $this->newWidth = round($factor * $width);\n                $this->log(\"New height was set.\");\n\n            } else {\n\n                // Use existing width and height as new width and height.\n                $this->newWidth = $width;\n                $this->newHeight = $height;\n            }\n\n\n            // Get image dimensions for pre-resize image.\n            if ($this->cropToFit || $this->fillToFit) {\n\n                // Get relations of original & target image\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n\n                if ($this->cropToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Crop to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;\n                    $this->cropWidth  = round($width  / $ratio);\n                    $this->cropHeight = round($height / $ratio);\n                    $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\");\n\n                } elseif ($this->fillToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Fill to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;\n                    $this->fillWidth  = round($width  / $ratio);\n                    $this->fillHeight = round($height / $ratio);\n                    $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\");\n                }\n            }\n        }\n\n        // Crop, ensure to set new width and height\n        if ($this->crop) {\n            $this->log(\"Crop.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }\n\n        // Fill to fit, ensure to set new width and height\n        /*if ($this->fillToFit) {\n            $this->log(\"FillToFit.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }*/\n\n        // No new height or width is set, use existing measures.\n        $this->newWidth  = round(isset($this->newWidth) ? $this->newWidth : $this->width);\n        $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height);\n        $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Re-calculate image dimensions when original image dimension has changed.\n     *\n     * @return $this\n     */\n    public function reCalculateDimensions()\n    {\n        $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight);\n\n        $this->newWidth  = $this->newWidthOrig;\n        $this->newHeight = $this->newHeightOrig;\n        $this->crop      = $this->cropOrig;\n\n        $this->initDimensions()\n             ->calculateNewWidthAndHeight();\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set extension for filename to save as.\n     *\n     * @param string $saveas extension to save image as\n     *\n     * @return $this\n     */\n    public function setSaveAsExtension($saveAs = null)\n    {\n        if (isset($saveAs)) {\n            $saveAs = strtolower($saveAs);\n            $this->checkFileExtension($saveAs);\n            $this->saveAs = $saveAs;\n            $this->extension = $saveAs;\n        }\n\n        $this->log(\"Prepare to save image as: \" . $this->extension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set JPEG quality to use when saving image\n     *\n     * @param int $quality as the quality to set.\n     *\n     * @return $this\n     */\n    public function setJpegQuality($quality = null)\n    {\n        if ($quality) {\n            $this->useQuality = true;\n        }\n\n        $this->quality = isset($quality)\n            ? $quality\n            : self::JPEG_QUALITY_DEFAULT;\n\n        (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting JPEG quality to {$this->quality}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set PNG compressen algorithm to use when saving image\n     *\n     * @param int $compress as the algorithm to use.\n     *\n     * @return $this\n     */\n    public function setPngCompression($compress = null)\n    {\n        if ($compress) {\n            $this->useCompress = true;\n        }\n\n        $this->compress = isset($compress)\n            ? $compress\n            : self::PNG_COMPRESSION_DEFAULT;\n\n        (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting PNG compression level to {$this->compress}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Use original image if possible, check options which affects image processing.\n     *\n     * @param boolean $useOrig default is to use original if possible, else set to false.\n     *\n     * @return $this\n     */\n    public function useOriginalIfPossible($useOrig = true)\n    {\n        if ($useOrig\n            && ($this->newWidth == $this->width)\n            && ($this->newHeight == $this->height)\n            && !$this->area\n            && !$this->crop\n            && !$this->cropToFit\n            && !$this->fillToFit\n            && !$this->filters\n            && !$this->sharpen\n            && !$this->emboss\n            && !$this->blur\n            && !$this->convolve\n            && !$this->palette\n            && !$this->useQuality\n            && !$this->useCompress\n            && !$this->saveAs\n            && !$this->rotateBefore\n            && !$this->rotateAfter\n            && !$this->autoRotate\n            && !$this->bgColor\n            && ($this->upscale === self::UPSCALE_DEFAULT)\n            && !$this->lossy\n        ) {\n            $this->log(\"Using original image.\");\n            $this->output($this->pathToImage);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Generate filename to save file in cache.\n     *\n     * @param string  $base      as optional basepath for storing file.\n     * @param boolean $useSubdir use or skip the subdir part when creating the\n     *                           filename.\n     * @param string  $prefix    to add as part of filename\n     *\n     * @return $this\n     */\n    public function generateFilename($base = null, $useSubdir = true, $prefix = null)\n    {\n        $filename     = basename($this->pathToImage);\n        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;\n        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;\n        $crop_x       = $this->crop_x       ? \"_x{$this->crop_x}\"        : null;\n        $crop_y       = $this->crop_y       ? \"_y{$this->crop_y}\"        : null;\n        $scale        = $this->scale        ? \"_s{$this->scale}\"         : null;\n        $bgColor      = $this->bgColor      ? \"_bgc{$this->bgColor}\"     : null;\n        $quality      = $this->quality      ? \"_q{$this->quality}\"       : null;\n        $compress     = $this->compress     ? \"_co{$this->compress}\"     : null;\n        $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null;\n        $rotateAfter  = $this->rotateAfter  ? \"_ra{$this->rotateAfter}\"  : null;\n        $lossy        = $this->lossy        ? \"_l\"                       : null;\n        $interlace    = $this->interlace    ? \"_i\"                       : null;\n\n        $saveAs = $this->normalizeFileExtension();\n        $saveAs = $saveAs ? \"_$saveAs\" : null;\n\n        $copyStrat = null;\n        if ($this->copyStrategy === self::RESIZE) {\n            $copyStrat = \"_rs\";\n        }\n\n        $width  = $this->newWidth  ? '_' . $this->newWidth  : null;\n        $height = $this->newHeight ? '_' . $this->newHeight : null;\n\n        $offset = isset($this->offset)\n            ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left']\n            : null;\n\n        $crop = $this->crop\n            ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y']\n            : null;\n\n        $filters = null;\n        if (isset($this->filters)) {\n            foreach ($this->filters as $filter) {\n                if (is_array($filter)) {\n                    $filters .= \"_f{$filter['id']}\";\n                    for ($i=1; $i<=$filter['argc']; $i++) {\n                        $filters .= \"-\".$filter[\"arg{$i}\"];\n                    }\n                }\n            }\n        }\n\n        $sharpen = $this->sharpen ? 's' : null;\n        $emboss  = $this->emboss  ? 'e' : null;\n        $blur    = $this->blur    ? 'b' : null;\n        $palette = $this->palette ? 'p' : null;\n\n        $autoRotate = $this->autoRotate ? 'ar' : null;\n\n        $optimize  = $this->jpegOptimize ? 'o' : null;\n        $optimize .= $this->pngFilter    ? 'f' : null;\n        $optimize .= $this->pngDeflate   ? 'd' : null;\n\n        $convolve = null;\n        if ($this->convolve) {\n            $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve);\n        }\n\n        $upscale = null;\n        if ($this->upscale !== self::UPSCALE_DEFAULT) {\n            $upscale = '_nu';\n        }\n\n        $subdir = null;\n        if ($useSubdir === true) {\n            $subdir = str_replace('/', '-', dirname($this->imageSrc));\n            $subdir = ($subdir == '.') ? '_.' : $subdir;\n            $subdir .= '_';\n        }\n\n        $file = $prefix . $subdir . $filename . $width . $height\n            . $offset . $crop . $cropToFit . $fillToFit\n            . $crop_x . $crop_y . $upscale\n            . $quality . $filters . $sharpen . $emboss . $blur . $palette\n            . $optimize . $compress\n            . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor\n            . $convolve . $copyStrat . $lossy . $interlace . $saveAs;\n\n        return $this->setTarget($file, $base);\n    }\n\n\n\n    /**\n     * Use cached version of image, if possible.\n     *\n     * @param boolean $useCache is default true, set to false to avoid using cached object.\n     *\n     * @return $this\n     */\n    public function useCacheIfPossible($useCache = true)\n    {\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime   = filemtime($this->pathToImage);\n            $cacheTime  = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                if ($this->useCache) {\n                    if ($this->verbose) {\n                        $this->log(\"Use cached file.\");\n                        $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $this->output($this->cacheFileName, $this->outputFormat);\n                } else {\n                    $this->log(\"Cache is valid but ignoring it by intention.\");\n                }\n            } else {\n                $this->log(\"Original file is modified, ignoring cache.\");\n            }\n        } else {\n            $this->log(\"Cachefile does not exists or ignoring it.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Load image from disk. Try to load image without verbose error message,\n     * if fail, load again and display error messages.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     *\n     */\n    public function load($src = null, $dir = null)\n    {\n        if (isset($src)) {\n            $this->setSource($src, $dir);\n        }\n\n        $this->loadImageDetails();\n\n        if ($this->fileType === IMG_WEBP) {\n            $this->image = imagecreatefromwebp($this->pathToImage);\n        } else {\n            $imageAsString = file_get_contents($this->pathToImage);\n            $this->image = imagecreatefromstring($imageAsString);\n        }\n        if ($this->image === false) {\n            throw new Exception(\"Could not load image.\");\n        }\n\n        /* Removed v0.7.7\n        if (image_type_to_mime_type($this->fileType) == 'image/png') {\n            $type = $this->getPngType();\n            $hasFewColors = imagecolorstotal($this->image);\n\n            if ($type == self::PNG_RGB_PALETTE || ($hasFewColors > 0 && $hasFewColors <= 256)) {\n                if ($this->verbose) {\n                    $this->log(\"Handle this image as a palette image.\");\n                }\n                $this->palette = true;\n            }\n        }\n        */\n\n        if ($this->verbose) {\n            $this->log(\"### Image successfully loaded from file.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->colorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index >= 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the type of PNG image.\n     *\n     * @param string $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    public function getPngType($filename = null)\n    {\n        $filename = $filename ? $filename : $this->pathToImage;\n\n        $pngType = ord(file_get_contents($filename, false, null, 25, 1));\n\n        if ($this->verbose) {\n            $this->log(\"Checking png type of: \" . $filename);\n            $this->log($this->getPngTypeAsString($pngType));\n        }\n\n        return $pngType;\n    }\n\n\n\n    /**\n     * Get the type of PNG image as a verbose string.\n     *\n     * @param integer $type     to use, default is to check the type.\n     * @param string  $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    private function getPngTypeAsString($pngType = null, $filename = null)\n    {\n        if ($filename || !$pngType) {\n            $pngType = $this->getPngType($filename);\n        }\n\n        $index = imagecolortransparent($this->image);\n        $transparent = null;\n        if ($index != -1) {\n            $transparent = \" (transparent)\";\n        }\n\n        switch ($pngType) {\n\n            case self::PNG_GREYSCALE:\n                $text = \"PNG is type 0, Greyscale$transparent\";\n                break;\n\n            case self::PNG_RGB:\n                $text = \"PNG is type 2, RGB$transparent\";\n                break;\n\n            case self::PNG_RGB_PALETTE:\n                $text = \"PNG is type 3, RGB with palette$transparent\";\n                break;\n\n            case self::PNG_GREYSCALE_ALPHA:\n                $text = \"PNG is type 4, Greyscale with alpha channel\";\n                break;\n\n            case self::PNG_RGB_ALPHA:\n                $text = \"PNG is type 6, RGB with alpha channel (PNG 32-bit)\";\n                break;\n\n            default:\n                $text = \"PNG is UNKNOWN type, is it really a PNG image?\";\n        }\n\n        return $text;\n    }\n\n\n\n\n    /**\n     * Calculate number of colors in an image.\n     *\n     * @param resource $im the image.\n     *\n     * @return int\n     */\n    private function colorsTotal($im)\n    {\n        if (imageistruecolor($im)) {\n            $this->log(\"Colors as true color.\");\n            $h = imagesy($im);\n            $w = imagesx($im);\n            $c = array();\n            for ($x=0; $x < $w; $x++) {\n                for ($y=0; $y < $h; $y++) {\n                    @$c['c'.imagecolorat($im, $x, $y)]++;\n                }\n            }\n            return count($c);\n        } else {\n            $this->log(\"Colors as palette.\");\n            return imagecolorstotal($im);\n        }\n    }\n\n\n\n    /**\n     * Preprocess image before rezising it.\n     *\n     * @return $this\n     */\n    public function preResize()\n    {\n        $this->log(\"### Pre-process before resizing\");\n\n        // Rotate image\n        if ($this->rotateBefore) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateBefore, $this->bgColor)\n                 ->reCalculateDimensions();\n        }\n\n        // Auto-rotate image\n        if ($this->autoRotate) {\n            $this->log(\"Auto rotating image.\");\n            $this->rotateExif()\n                 ->reCalculateDimensions();\n        }\n\n        // Scale the original image before starting\n        if (isset($this->scale)) {\n            $this->log(\"Scale by {$this->scale}%\");\n            $newWidth  = $this->width * $this->scale / 100;\n            $newHeight = $this->height * $this->scale / 100;\n            $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);\n            imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);\n            $this->image = $img;\n            $this->width = $newWidth;\n            $this->height = $newHeight;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Resize or resample the image while resizing.\n     *\n     * @param int $strategy as CImage::RESIZE or CImage::RESAMPLE\n     *\n     * @return $this\n     */\n     public function setCopyResizeStrategy($strategy)\n     {\n         $this->copyStrategy = $strategy;\n         return $this;\n     }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return void\n     */\n    public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)\n    {\n        if($this->copyStrategy == self::RESIZE) {\n            $this->log(\"Copy by resize\");\n            imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        } else {\n            $this->log(\"Copy by resample\");\n            imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        }\n    }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return $this\n     */\n    public function resize()\n    {\n\n        $this->log(\"### Starting to Resize()\");\n        $this->log(\"Upscale = '$this->upscale'\");\n\n        // Only use a specified area of the image, $this->offset is defining the area to use\n        if (isset($this->offset)) {\n\n            $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\");\n            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);\n            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);\n            $this->image = $img;\n            $this->width = $this->offset['width'];\n            $this->height = $this->offset['height'];\n        }\n\n        if ($this->crop) {\n\n            // Do as crop, take only part of image\n            $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\");\n            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);\n            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);\n            $this->image = $img;\n            $this->width = $this->crop['width'];\n            $this->height = $this->crop['height'];\n        }\n\n        if (!$this->upscale) {\n            // Consider rewriting the no-upscale code to fit within this if-statement,\n            // likely to be more readable code.\n            // The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch\n        }\n\n        if ($this->cropToFit) {\n\n            // Resize by crop to fit\n            $this->log(\"Resizing using strategy - Crop to fit\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                $posX = 0;\n                $posY = 0;\n                $cropX = 0;\n                $cropY = 0;\n\n                if ($this->newWidth > $this->width) {\n                    $posX = round(($this->newWidth - $this->width) / 2);\n                }\n                if ($this->newWidth < $this->width) {\n                    $cropX = round(($this->width/2) - ($this->newWidth/2));\n                }\n\n                if ($this->newHeight > $this->height) {\n                    $posY = round(($this->newHeight - $this->height) / 2);\n                }\n                if ($this->newHeight < $this->height) {\n                    $cropY = round(($this->height/2) - ($this->newHeight/2));\n                }\n                $this->log(\" cwidth: $this->cropWidth\");\n                $this->log(\" cheight: $this->cropHeight\");\n                $this->log(\" nwidth: $this->newWidth\");\n                $this->log(\" nheight: $this->newHeight\");\n                $this->log(\" width: $this->width\");\n                $this->log(\" height: $this->height\");\n                $this->log(\" posX: $posX\");\n                $this->log(\" posY: $posY\");\n                $this->log(\" cropX: $cropX\");\n                $this->log(\" cropY: $cropY\");\n\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);\n            } else {\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n                $imgPreCrop   = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif ($this->fillToFit) {\n\n            // Resize by fill to fit\n            $this->log(\"Resizing using strategy - Fill to fit\");\n\n            $posX = 0;\n            $posY = 0;\n\n            $ratioOrig = $this->width / $this->height;\n            $ratioNew  = $this->newWidth / $this->newHeight;\n\n            // Check ratio for landscape or portrait\n            if ($ratioOrig < $ratioNew) {\n                $posX = round(($this->newWidth - $this->fillWidth) / 2);\n            } else {\n                $posY = round(($this->newHeight - $this->fillHeight) / 2);\n            }\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth && $this->height < $this->newHeight)\n            ) {\n\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n                $posX = round(($this->newWidth - $this->width) / 2);\n                $posY = round(($this->newHeight - $this->height) / 2);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);\n\n            } else {\n                $imgPreFill   = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {\n\n            // Resize it\n            $this->log(\"Resizing, new height and/or width\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                if (!$this->keepRatio) {\n                    $this->log(\"Resizing - stretch to fit selected.\");\n\n                    $posX = 0;\n                    $posY = 0;\n                    $cropX = 0;\n                    $cropY = 0;\n\n                    if ($this->newWidth > $this->width && $this->newHeight > $this->height) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                    } elseif ($this->newWidth > $this->width) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $cropY = round(($this->height - $this->newHeight) / 2);\n                    } elseif ($this->newHeight > $this->height) {\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                        $cropX = round(($this->width - $this->newWidth) / 2);\n                    }\n\n                    $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                    imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);\n                    $this->image = $imageResized;\n                    $this->width = $this->newWidth;\n                    $this->height = $this->newHeight;\n                }\n            } else {\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);\n                $this->image = $imageResized;\n                $this->width = $this->newWidth;\n                $this->height = $this->newHeight;\n            }\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Postprocess image after rezising image.\n     *\n     * @return $this\n     */\n    public function postResize()\n    {\n        $this->log(\"### Post-process after resizing\");\n\n        // Rotate image\n        if ($this->rotateAfter) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateAfter, $this->bgColor);\n        }\n\n        // Apply filters\n        if (isset($this->filters) && is_array($this->filters)) {\n\n            foreach ($this->filters as $filter) {\n                $this->log(\"Applying filter {$filter['type']}.\");\n\n                switch ($filter['argc']) {\n\n                    case 0:\n                        imagefilter($this->image, $filter['type']);\n                        break;\n\n                    case 1:\n                        imagefilter($this->image, $filter['type'], $filter['arg1']);\n                        break;\n\n                    case 2:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']);\n                        break;\n\n                    case 3:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']);\n                        break;\n\n                    case 4:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']);\n                        break;\n                }\n            }\n        }\n\n        // Convert to palette image\n        if ($this->palette) {\n            $this->log(\"Converting to palette image.\");\n            $this->trueColorToPalette();\n        }\n\n        // Blur the image\n        if ($this->blur) {\n            $this->log(\"Blur.\");\n            $this->blurImage();\n        }\n\n        // Emboss the image\n        if ($this->emboss) {\n            $this->log(\"Emboss.\");\n            $this->embossImage();\n        }\n\n        // Sharpen the image\n        if ($this->sharpen) {\n            $this->log(\"Sharpen.\");\n            $this->sharpenImage();\n        }\n\n        // Custom convolution\n        if ($this->convolve) {\n            //$this->log(\"Convolve: \" . $this->convolve);\n            $this->imageConvolution();\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using angle.\n     *\n     * @param float $angle        to rotate image.\n     * @param int   $anglebgColor to fill image with if needed.\n     *\n     * @return $this\n     */\n    public function rotate($angle, $bgColor)\n    {\n        $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\");\n\n        $color = $this->getBackgroundColor();\n        $this->image = imagerotate($this->image, $angle, $color);\n\n        $this->width  = imagesx($this->image);\n        $this->height = imagesy($this->image);\n\n        $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using information in EXIF.\n     *\n     * @return $this\n     */\n    public function rotateExif()\n    {\n        if (!in_array($this->fileType, array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) {\n            $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\");\n            return $this;\n        }\n\n        $exif = exif_read_data($this->pathToImage);\n\n        if (!empty($exif['Orientation'])) {\n            switch ($exif['Orientation']) {\n                case 3:\n                    $this->log(\"Autorotate 180.\");\n                    $this->rotate(180, $this->bgColor);\n                    break;\n\n                case 6:\n                    $this->log(\"Autorotate -90.\");\n                    $this->rotate(-90, $this->bgColor);\n                    break;\n\n                case 8:\n                    $this->log(\"Autorotate 90.\");\n                    $this->rotate(90, $this->bgColor);\n                    break;\n\n                default:\n                    $this->log(\"Autorotate ignored, unknown value as orientation.\");\n            }\n        } else {\n            $this->log(\"Autorotate ignored, no orientation in EXIF.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert true color image to palette image, keeping alpha.\n     * http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\n     *\n     * @return void\n     */\n    public function trueColorToPalette()\n    {\n        $img = imagecreatetruecolor($this->width, $this->height);\n        $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);\n        imagecolortransparent($img, $bga);\n        imagefill($img, 0, 0, $bga);\n        imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);\n        imagetruecolortopalette($img, false, 255);\n        imagesavealpha($img, true);\n\n        if (imageistruecolor($this->image)) {\n            $this->log(\"Matching colors with true color image.\");\n            imagecolormatch($this->image, $img);\n        }\n\n        $this->image = $img;\n    }\n\n\n\n    /**\n     * Sharpen image using image convolution.\n     *\n     * @return $this\n     */\n    public function sharpenImage()\n    {\n        $this->imageConvolution('sharpen');\n        return $this;\n    }\n\n\n\n    /**\n     * Emboss image using image convolution.\n     *\n     * @return $this\n     */\n    public function embossImage()\n    {\n        $this->imageConvolution('emboss');\n        return $this;\n    }\n\n\n\n    /**\n     * Blur image using image convolution.\n     *\n     * @return $this\n     */\n    public function blurImage()\n    {\n        $this->imageConvolution('blur');\n        return $this;\n    }\n\n\n\n    /**\n     * Create convolve expression and return arguments for image convolution.\n     *\n     * @param string $expression constant string which evaluates to a list of\n     *                           11 numbers separated by komma or such a list.\n     *\n     * @return array as $matrix (3x3), $divisor and $offset\n     */\n    public function createConvolveArguments($expression)\n    {\n        // Check of matching constant\n        if (isset($this->convolves[$expression])) {\n            $expression = $this->convolves[$expression];\n        }\n\n        $part = explode(',', $expression);\n        $this->log(\"Creating convolution expressen: $expression\");\n\n        // Expect list of 11 numbers, split by , and build up arguments\n        if (count($part) != 11) {\n            throw new Exception(\n                \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\"\n            );\n        }\n\n        array_walk($part, function ($item, $key) {\n            if (!is_numeric($item)) {\n                throw new Exception(\"Argument to convolve expression should be float but is not.\");\n            }\n        });\n\n        return array(\n            array(\n                array($part[0], $part[1], $part[2]),\n                array($part[3], $part[4], $part[5]),\n                array($part[6], $part[7], $part[8]),\n            ),\n            $part[9],\n            $part[10],\n        );\n    }\n\n\n\n    /**\n     * Add custom expressions (or overwrite existing) for image convolution.\n     *\n     * @param array $options Key value array with strings to be converted\n     *                       to convolution expressions.\n     *\n     * @return $this\n     */\n    public function addConvolveExpressions($options)\n    {\n        $this->convolves = array_merge($this->convolves, $options);\n        return $this;\n    }\n\n\n\n    /**\n     * Image convolution.\n     *\n     * @param string $options A string with 11 float separated by comma.\n     *\n     * @return $this\n     */\n    public function imageConvolution($options = null)\n    {\n        // Use incoming options or use $this.\n        $options = $options ? $options : $this->convolve;\n\n        // Treat incoming as string, split by +\n        $this->log(\"Convolution with '$options'\");\n        $options = explode(\":\", $options);\n\n        // Check each option if it matches constant value\n        foreach ($options as $option) {\n            list($matrix, $divisor, $offset) = $this->createConvolveArguments($option);\n            imageconvolution($this->image, $matrix, $divisor, $offset);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set default background color between 000000-FFFFFF or if using\n     * alpha 00000000-FFFFFF7F.\n     *\n     * @param string $color as hex value.\n     *\n     * @return $this\n    */\n    public function setDefaultBackgroundColor($color)\n    {\n        $this->log(\"Setting default background color to '$color'.\");\n\n        if (!(strlen($color) == 6 || strlen($color) == 8)) {\n            throw new Exception(\n                \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $red    = hexdec(substr($color, 0, 2));\n        $green  = hexdec(substr($color, 2, 2));\n        $blue   = hexdec(substr($color, 4, 2));\n\n        $alpha = (strlen($color) == 8)\n            ? hexdec(substr($color, 6, 2))\n            : null;\n\n        if (($red < 0 || $red > 255)\n            || ($green < 0 || $green > 255)\n            || ($blue < 0 || $blue > 255)\n            || ($alpha < 0 || $alpha > 127)\n        ) {\n            throw new Exception(\n                \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $this->bgColor = strtolower($color);\n        $this->bgColorDefault = array(\n            'red'   => $red,\n            'green' => $green,\n            'blue'  => $blue,\n            'alpha' => $alpha\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the background color.\n     *\n     * @param resource $img the image to work with or null if using $this->image.\n     *\n     * @return color value or null if no background color is set.\n    */\n    private function getBackgroundColor($img = null)\n    {\n        $img = isset($img) ? $img : $this->image;\n\n        if ($this->bgColorDefault) {\n\n            $red   = $this->bgColorDefault['red'];\n            $green = $this->bgColorDefault['green'];\n            $blue  = $this->bgColorDefault['blue'];\n            $alpha = $this->bgColorDefault['alpha'];\n\n            if ($alpha) {\n                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);\n            } else {\n                $color = imagecolorallocate($img, $red, $green, $blue);\n            }\n\n            return $color;\n\n        } else {\n            return 0;\n        }\n    }\n\n\n\n    /**\n     * Create a image and keep transparency for png and gifs.\n     *\n     * @param int $width of the new image.\n     * @param int $height of the new image.\n     *\n     * @return image resource.\n    */\n    private function createImageKeepTransparency($width, $height)\n    {\n        $this->log(\"Creating a new working image width={$width}px, height={$height}px.\");\n        $img = imagecreatetruecolor($width, $height);\n        imagealphablending($img, false);\n        imagesavealpha($img, true);\n\n        $index = $this->image\n            ? imagecolortransparent($this->image)\n            : -1;\n\n        if ($index != -1) {\n\n            imagealphablending($img, true);\n            $transparent = imagecolorsforindex($this->image, $index);\n            $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']);\n            imagefill($img, 0, 0, $color);\n            $index = imagecolortransparent($img, $color);\n            $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\");\n\n        } elseif ($this->bgColorDefault) {\n\n            $color = $this->getBackgroundColor($img);\n            imagefill($img, 0, 0, $color);\n            $this->Log(\"Filling image with background color.\");\n        }\n\n        return $img;\n    }\n\n\n\n    /**\n     * Set optimizing  and post-processing options.\n     *\n     * @param array $options with config for postprocessing with external tools.\n     *\n     * @return $this\n     */\n    public function setPostProcessingOptions($options)\n    {\n        if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) {\n            $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd'];\n        } else {\n            $this->jpegOptimizeCmd = null;\n        }\n\n        if (array_key_exists(\"png_lossy\", $options)\n            && $options['png_lossy'] !== false) {\n            $this->pngLossy = $options['png_lossy'];\n            $this->pngLossyCmd = $options['png_lossy_cmd'];\n        } else {\n            $this->pngLossyCmd = null;\n        }\n\n        if (isset($options['png_filter']) && $options['png_filter']) {\n            $this->pngFilterCmd = $options['png_filter_cmd'];\n        } else {\n            $this->pngFilterCmd = null;\n        }\n\n        if (isset($options['png_deflate']) && $options['png_deflate']) {\n            $this->pngDeflateCmd = $options['png_deflate_cmd'];\n        } else {\n            $this->pngDeflateCmd = null;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Find out the type (file extension) for the image to be saved.\n     *\n     * @return string as image extension.\n     */\n    protected function getTargetImageExtension()\n    {\n        // switch on mimetype\n        if (isset($this->extension)) {\n            return strtolower($this->extension);\n        } elseif ($this->fileType === IMG_WEBP) {\n            return \"webp\";\n        }\n\n        return substr(image_type_to_extension($this->fileType), 1);\n    }\n\n\n\n    /**\n     * Save image.\n     *\n     * @param string  $src       as target filename.\n     * @param string  $base      as base directory where to store images.\n     * @param boolean $overwrite or not, default to always overwrite file.\n     *\n     * @return $this or false if no folder is set.\n     */\n    public function save($src = null, $base = null, $overwrite = true)\n    {\n        if (isset($src)) {\n            $this->setTarget($src, $base);\n        }\n\n        if ($overwrite === false && is_file($this->cacheFileName)) {\n            $this->Log(\"Not overwriting file since its already exists and \\$overwrite if false.\");\n            return;\n        }\n\n        if (!defined(\"WINDOWS2WSL\")) {\n            is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n        }\n\n        $type = $this->getTargetImageExtension();\n        $this->Log(\"Saving image as \" . $type);\n        switch($type) {\n\n            case 'jpeg':\n            case 'jpg':\n                // Set as interlaced progressive JPEG\n                if ($this->interlace) {\n                    $this->Log(\"Set JPEG image to be interlaced.\");\n                    $res = imageinterlace($this->image, true);\n                }\n\n                $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\");\n                imagejpeg($this->image, $this->cacheFileName, $this->quality);\n\n                // Use JPEG optimize if defined\n                if ($this->jpegOptimizeCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->log($cmd);\n                    $this->log($res);\n                }\n                break;\n\n            case 'gif':\n                $this->Log(\"Saving image as GIF to cache.\");\n                imagegif($this->image, $this->cacheFileName);\n                break;\n\n            case 'webp':\n                $this->Log(\"Saving image as WEBP to cache using quality = {$this->quality}.\");\n                imagewebp($this->image, $this->cacheFileName, $this->quality);\n                break;\n\n            case 'png':\n            default:\n                $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\");\n\n                // Turn off alpha blending and set alpha flag\n                imagealphablending($this->image, false);\n                imagesavealpha($this->image, true);\n                imagepng($this->image, $this->cacheFileName, $this->compress);\n\n                // Use external program to process lossy PNG, if defined\n                $lossyEnabled = $this->pngLossy === true;\n                $lossySoftEnabled = $this->pngLossy === null;\n                $lossyActiveEnabled = $this->lossy === true;\n                if ($lossyEnabled || ($lossySoftEnabled && $lossyActiveEnabled)) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Lossy enabled: $lossyEnabled\");\n                        $this->log(\"Lossy soft enabled: $lossySoftEnabled\");\n                        $this->Log(\"Filesize before lossy optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngLossyCmd . \" $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to filter PNG, if defined\n                if ($this->pngFilterCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngFilterCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to deflate PNG, if defined\n                if ($this->pngDeflateCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n                break;\n        }\n\n        if ($this->verbose) {\n            clearstatcache();\n            $this->log(\"Saved image to cache.\");\n            $this->log(\" Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->ColorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert image from one colorpsace/color profile to sRGB without\n     * color profile.\n     *\n     * @param string  $src      of image.\n     * @param string  $dir      as base directory where images are.\n     * @param string  $cache    as base directory where to store images.\n     * @param string  $iccFile  filename of colorprofile.\n     * @param boolean $useCache or not, default to always use cache.\n     *\n     * @return string | boolean false if no conversion else the converted\n     *                          filename.\n     */\n    public function convert2sRGBColorSpace($src, $dir, $cache, $iccFile, $useCache = true)\n    {\n        if ($this->verbose) {\n            $this->log(\"# Converting image to sRGB colorspace.\");\n        }\n\n        if (!class_exists(\"Imagick\")) {\n            $this->log(\" Ignoring since Imagemagick is not installed.\");\n            return false;\n        }\n\n        // Prepare\n        $this->setSaveFolder($cache)\n             ->setSource($src, $dir)\n             ->generateFilename(null, false, 'srgb_');\n\n        // Check if the cached version is accurate.\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime  = filemtime($this->pathToImage);\n            $cacheTime = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                $this->log(\" Using cached version: \" . $this->cacheFileName);\n                return $this->cacheFileName;\n            }\n        }\n\n        // Only covert if cachedir is writable\n        if (is_writable($this->saveFolder)) {\n            // Load file and check if conversion is needed\n            $image      = new Imagick($this->pathToImage);\n            $colorspace = $image->getImageColorspace();\n            $this->log(\" Current colorspace: \" . $colorspace);\n\n            $profiles      = $image->getImageProfiles('*', false);\n            $hasICCProfile = (array_search('icc', $profiles) !== false);\n            $this->log(\" Has ICC color profile: \" . ($hasICCProfile ? \"YES\" : \"NO\"));\n\n            if ($colorspace != Imagick::COLORSPACE_SRGB || $hasICCProfile) {\n                $this->log(\" Converting to sRGB.\");\n\n                $sRGBicc = file_get_contents($iccFile);\n                $image->profileImage('icc', $sRGBicc);\n\n                $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);\n                $image->writeImage($this->cacheFileName);\n                return $this->cacheFileName;\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Create a hard link, as an alias, to the cached file.\n     *\n     * @param string $alias where to store the link,\n     *                      filename without extension.\n     *\n     * @return $this\n     */\n    public function linkToCacheFile($alias)\n    {\n        if ($alias === null) {\n            $this->log(\"Ignore creating alias.\");\n            return $this;\n        }\n\n        if (is_readable($alias)) {\n            unlink($alias);\n        }\n\n        $res = link($this->cacheFileName, $alias);\n\n        if ($res) {\n            $this->log(\"Created an alias as: $alias\");\n        } else {\n            $this->log(\"Failed to create the alias: $alias\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Add HTTP header for output together with image.\n     *\n     * @param string $type  the header type such as \"Cache-Control\"\n     * @param string $value the value to use\n     *\n     * @return void\n     */\n    public function addHTTPHeader($type, $value)\n    {\n        $this->HTTPHeader[$type] = $value;\n    }\n\n\n\n    /**\n     * Output image to browser using caching.\n     *\n     * @param string $file   to read and output, default is to\n     *                       use $this->cacheFileName\n     * @param string $format set to json to output file as json\n     *                       object with details\n     *\n     * @return void\n     */\n    public function output($file = null, $format = null)\n    {\n        if (is_null($file)) {\n            $file = $this->cacheFileName;\n        }\n\n        if (is_null($format)) {\n            $format = $this->outputFormat;\n        }\n\n        $this->log(\"### Output\");\n        $this->log(\"Output format is: $format\");\n\n        if (!$this->verbose && $format == 'json') {\n            header('Content-type: application/json');\n            echo $this->json($file);\n            exit;\n        } elseif ($format == 'ascii') {\n            header('Content-type: text/plain');\n            echo $this->ascii($file);\n            exit;\n        }\n\n        $this->log(\"Outputting image: $file\");\n\n        // Get image modification time\n        clearstatcache();\n        $lastModified = filemtime($file);\n        $lastModifiedFormat = \"D, d M Y H:i:s\";\n        $gmdate = gmdate($lastModifiedFormat, $lastModified);\n\n        if (!$this->verbose) {\n            $header = \"Last-Modified: $gmdate GMT\";\n            header($header);\n            $this->fastTrackCache->addHeader($header);\n            $this->fastTrackCache->setLastModified($lastModified);\n        }\n\n        foreach ($this->HTTPHeader as $key => $val) {\n            $header = \"$key: $val\";\n            header($header);\n            $this->fastTrackCache->addHeader($header);\n        }\n\n        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])\n            && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {\n\n            if ($this->verbose) {\n                $this->log(\"304 not modified\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            header(\"HTTP/1.0 304 Not Modified\");\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 304\");\n            }\n\n        } else {\n\n            $this->loadImageDetails($file);\n            $mime = $this->getMimeType();\n            $size = filesize($file);\n\n            if ($this->verbose) {\n                $this->log(\"Last-Modified: \" . $gmdate . \" GMT\");\n                $this->log(\"Content-type: \" . $mime);\n                $this->log(\"Content-length: \" . $size);\n                $this->verboseOutput();\n\n                if (is_null($this->verboseFileName)) {\n                    exit;\n                }\n            }\n\n            $header = \"Content-type: $mime\";\n            header($header);\n            $this->fastTrackCache->addHeaderOnOutput($header);\n\n            $header = \"Content-length: $size\";\n            header($header);\n            $this->fastTrackCache->addHeaderOnOutput($header);\n\n            $this->fastTrackCache->setSource($file);\n            $this->fastTrackCache->writeToCache();\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 200\");\n            }\n            readfile($file);\n        }\n\n        exit;\n    }\n\n\n\n    /**\n     * Create a JSON object from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string json-encoded representation of the image.\n     */\n    public function json($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $details = array();\n\n        clearstatcache();\n\n        $details['src']       = $this->imageSrc;\n        $lastModified         = filemtime($this->pathToImage);\n        $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $details['cache']       = basename($this->cacheFileName ?? \"\");\n        $lastModified           = filemtime($this->cacheFileName ?? \"\");\n        $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $this->load($file);\n\n        $details['filename']    = basename($file ?? \"\");\n        $details['mimeType']    = $this->getMimeType($this->fileType);\n        $details['width']       = $this->width;\n        $details['height']      = $this->height;\n        $details['aspectRatio'] = round($this->width / $this->height, 3);\n        $details['size']        = filesize($file ?? \"\");\n        $details['colors'] = $this->colorsTotal($this->image);\n        $details['includedFiles'] = count(get_included_files());\n        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . \" MB\" ;\n        $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . \" MB\";\n        $details['memoryLimit'] = ini_get('memory_limit');\n\n        if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {\n            $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . \"s\";\n        }\n\n        if ($details['mimeType'] == 'image/png') {\n            $details['pngType'] = $this->getPngTypeAsString(null, $file);\n        }\n\n        $options = null;\n        if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) {\n            $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;\n        }\n\n        return json_encode($details, $options);\n    }\n\n\n\n    /**\n     * Set options for creating ascii version of image.\n     *\n     * @param array $options empty to use default or set options to change.\n     *\n     * @return void.\n     */\n    public function setAsciiOptions($options = array())\n    {\n        $this->asciiOptions = $options;\n    }\n\n\n\n    /**\n     * Create an ASCII version from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string ASCII representation of the image.\n     */\n    public function ascii($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $asciiArt = new CAsciiArt();\n        $asciiArt->setOptions($this->asciiOptions);\n        return $asciiArt->createFromFile($file);\n    }\n\n\n\n    /**\n     * Log an event if verbose mode.\n     *\n     * @param string $message to log.\n     *\n     * @return this\n     */\n    public function log($message)\n    {\n        if ($this->verbose) {\n            $this->log[] = $message;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Do verbose output to a file.\n     *\n     * @param string $fileName where to write the verbose output.\n     *\n     * @return void\n     */\n    public function setVerboseToFile($fileName)\n    {\n        $this->log(\"Setting verbose output to file.\");\n        $this->verboseFileName = $fileName;\n    }\n\n\n\n    /**\n     * Do verbose output and print out the log and the actual images.\n     *\n     * @return void\n     */\n    private function verboseOutput()\n    {\n        $log = null;\n        $this->log(\"### Summary of verbose log\");\n        $this->log(\"As JSON: \\n\" . $this->json());\n        $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\");\n        $this->log(\"Memory limit: \" . ini_get('memory_limit'));\n\n        $included = get_included_files();\n        $this->log(\"Included files: \" . count($included));\n\n        foreach ($this->log as $val) {\n            if (is_array($val)) {\n                foreach ($val as $val1) {\n                    $log .= htmlentities($val1) . '<br/>';\n                }\n            } else {\n                $log .= htmlentities($val) . '<br/>';\n            }\n        }\n\n        if (!is_null($this->verboseFileName)) {\n            file_put_contents(\n                $this->verboseFileName,\n                str_replace(\"<br/>\", \"\\n\", $log)\n            );\n        } else {\n            echo <<<EOD\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n        }\n    }\n\n\n\n    /**\n     * Raise error, enables to implement a selection of error methods.\n     *\n     * @param string $message the error message to display.\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function raiseError($message)\n    {\n        throw new Exception($message);\n    }\n}\n\n\n\n/**\n * Deal with the cache directory and cached items.\n *\n */\nclass CCache\n{\n    /**\n     * Path to the cache directory.\n     */\n    private $path;\n\n\n\n    /**\n     * Set the path to the cache dir which must exist.\n     *\n     * @param string path to the cache dir.\n     *\n     * @throws Exception when $path is not a directory.\n     *\n     * @return $this\n     */\n    public function setDir($path)\n    {\n        if (!is_dir($path)) {\n            throw new Exception(\"Cachedir is not a directory.\");\n        }\n\n        $this->path = $path;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the path to the cache subdir and try to create it if its not there.\n     *\n     * @param string $subdir name of subdir\n     * @param array  $create default is to try to create the subdir\n     *\n     * @return string | boolean as real path to the subdir or\n     *                          false if it does not exists\n     */\n    public function getPathToSubdir($subdir, $create = true)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        if (is_dir($path)) {\n            return $path;\n        }\n\n        if ($create && defined('WINDOWS2WSL')) {\n            // Special case to solve Windows 2 WSL integration\n            $path = $this->path . \"/\" . $subdir;\n\n            if (mkdir($path)) {\n                return realpath($path);\n            }\n        }\n\n        if ($create && is_writable($this->path)) {\n            $path = $this->path . \"/\" . $subdir;\n\n            if (mkdir($path)) {\n                return realpath($path);\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Get status of the cache subdir.\n     *\n     * @param string $subdir name of subdir\n     *\n     * @return string with status\n     */\n    public function getStatusOfSubdir($subdir)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        $exists = is_dir($path);\n        $res  = $exists ? \"exists\" : \"does not exist\";\n        \n        if ($exists) {\n            $res .= is_writable($path) ? \", writable\" : \", not writable\";\n        }\n\n        return $res;\n    }\n\n\n\n    /**\n     * Remove the cache subdir.\n     *\n     * @param string $subdir name of subdir\n     *\n     * @return null | boolean true if success else false, null if no operation\n     */\n    public function removeSubdir($subdir)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        if (is_dir($path)) {\n            return rmdir($path);\n        }\n\n        return null;\n    }\n}\n\n\n\n/**\n * Enable a fast track cache with a json representation of the image delivery.\n *\n */\nclass CFastTrackCache\n{\n    /**\n     * Cache is disabled to start with.\n     */\n    private $enabled = false;\n\n\n\n    /**\n     * Path to the cache directory.\n     */\n    private $path;\n\n\n\n    /**\n     * Filename of current cache item.\n     */\n    private $filename;\n\n\n\n    /**\n     * Container with items to store as cached item.\n     */\n    private $container;\n\n\n\n    /**\n     * Enable or disable cache.\n     *\n     * @param boolean $enable set to true to enable, false to disable\n     *\n     * @return $this\n     */\n    public function enable($enabled)\n    {\n        $this->enabled = $enabled;\n        return $this;\n    }\n\n\n\n    /**\n     * Set the path to the cache dir which must exist.\n     *\n     * @param string $path to the cache dir.\n     *\n     * @throws Exception when $path is not a directory.\n     *\n     * @return $this\n     */\n    public function setCacheDir($path)\n    {\n        if (!is_dir($path)) {\n            throw new Exception(\"Cachedir is not a directory.\");\n        }\n\n        $this->path = rtrim($path, \"/\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set the filename to store in cache, use the querystring to create that\n     * filename.\n     *\n     * @param array $clear items to clear in $_GET when creating the filename.\n     *\n     * @return string as filename created.\n     */\n    public function setFilename($clear)\n    {\n        $query = $_GET;\n\n        // Remove parts from querystring that should not be part of filename\n        foreach ($clear as $value) {\n            unset($query[$value]);\n        }\n\n        arsort($query);\n        $queryAsString = http_build_query($query);\n\n        $this->filename = md5($queryAsString);\n\n        if (CIMAGE_DEBUG) {\n            $this->container[\"query-string\"] = $queryAsString;\n        }\n\n        return $this->filename;\n    }\n\n\n\n    /**\n     * Add header items.\n     *\n     * @param string $header add this as header.\n     *\n     * @return $this\n     */\n    public function addHeader($header)\n    {\n        $this->container[\"header\"][] = $header;\n        return $this;\n    }\n\n\n\n    /**\n     * Add header items on output, these are not output when 304.\n     *\n     * @param string $header add this as header.\n     *\n     * @return $this\n     */\n    public function addHeaderOnOutput($header)\n    {\n        $this->container[\"header-output\"][] = $header;\n        return $this;\n    }\n\n\n\n    /**\n     * Set path to source image to.\n     *\n     * @param string $source path to source image file.\n     *\n     * @return $this\n     */\n    public function setSource($source)\n    {\n        $this->container[\"source\"] = $source;\n        return $this;\n    }\n\n\n\n    /**\n     * Set last modified of source image, use to check for 304.\n     *\n     * @param string $lastModified\n     *\n     * @return $this\n     */\n    public function setLastModified($lastModified)\n    {\n        $this->container[\"last-modified\"] = $lastModified;\n        return $this;\n    }\n\n\n\n    /**\n     * Get filename of cached item.\n     *\n     * @return string as filename.\n     */\n    public function getFilename()\n    {\n        return $this->path . \"/\" . $this->filename;\n    }\n\n\n\n    /**\n     * Write current item to cache.\n     *\n     * @return boolean if cache file was written.\n     */\n    public function writeToCache()\n    {\n        if (!$this->enabled) {\n            return false;\n        }\n\n        if (is_dir($this->path) && is_writable($this->path)) {\n            $filename = $this->getFilename();\n            return file_put_contents($filename, json_encode($this->container)) !== false;\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Output current item from cache, if available.\n     *\n     * @return void\n     */\n    public function output()\n    {\n        $filename = $this->getFilename();\n        if (!is_readable($filename)) {\n            return;\n        }\n\n        $item = json_decode(file_get_contents($filename), true);\n\n        if (!is_readable($item[\"source\"])) {\n            return;\n        }\n\n        foreach ($item[\"header\"] as $value) {\n            header($value);\n        }\n\n        if (isset($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"])\n            && strtotime($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"]) == $item[\"last-modified\"]) {\n            header(\"HTTP/1.0 304 Not Modified\");\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 304\");\n            }\n            exit;\n        }\n\n        foreach ($item[\"header-output\"] as $value) {\n            header($value);\n        }\n\n        if (CIMAGE_DEBUG) {\n            trace(__CLASS__ . \" 200\");\n        }\n        readfile($item[\"source\"]);\n        exit;\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\n        \"<p><b>img.php: Uncaught exception:</b> <p>\"\n        . $exception->getMessage()\n        . \"</p><pre>\"\n        . $exception->getTraceAsString()\n        . \"</pre>\",\n        500\n    );\n});\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} elseif (!isset($config)) {\n    $config = array();\n}\n\n// Make CIMAGE_DEBUG false by default, if not already defined\nif (!defined(\"CIMAGE_DEBUG\")) {\n    define(\"CIMAGE_DEBUG\", false);\n}\n\n\n\n/**\n * Setup the autoloader, but not when using a bundle.\n */\nif (!defined(\"CIMAGE_BUNDLE\")) {\n    if (!isset($config[\"autoloader\"])) {\n        die(\"CImage: Missing autoloader.\");\n    }\n\n    require $config[\"autoloader\"];\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n* vf - do verbose dump to file\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\n$verboseFile = getDefined('vf', true, false);\nverbose(\"img.php version = \" . CIMAGE_VERSION);\n\n\n\n/**\n* status - do a verbose dump of the configuration\n*/\n$status = getDefined('status', true, false);\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is not loaded.\", 500);\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n\n} elseif ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n\n} elseif ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n    $verboseFile = false;\n\n} elseif ($mode == 'test') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\", 500);\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} elseif (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwdType     = getConfig('password_type', 'text');\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwd) {\n    switch ($pwdType) {\n        case 'md5':\n            $passwordMatch = ($pwdConfig === md5($pwd));\n            break;\n        case 'hash':\n            $passwordMatch = password_verify($pwd, $pwdConfig);\n            break;\n        case 'text':\n            $passwordMatch = ($pwdConfig === $pwd);\n            break;\n        default:\n            $passwordMatch = false;\n    }\n}\n\nif ($pwdAlways && $passwordMatch !== true) {\n    errorPage(\"Password required and does not match or exists.\", 403);\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer ?? \"\", PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n        verbose(\"Hotlinking since passwordmatch\");\n    } elseif ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\", 403);\n    } elseif (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\", 403);\n    } elseif (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n        verbose(\"Hotlinking disallowed but serverName matches refererHost.\");\n    } elseif (!empty($hotlinkingWhitelist)) {\n        $whitelist = new CWhitelist();\n        $allowedByWhitelist = $whitelist->check($refererHost, $hotlinkingWhitelist);\n\n        if ($allowedByWhitelist) {\n            verbose(\"Hotlinking/leeching allowed by whitelist.\");\n        } else {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist. Referer: $referer.\", 403);\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\", 403);\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Create the class for the image.\n */\n$CImage = getConfig('CImage', 'CImage');\n$img = new $CImage();\n$img->setVerbose($verbose || $verboseFile);\n\n\n\n/**\n * Get the cachepath from config.\n */\n$CCache = getConfig('CCache', 'CCache');\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n$cache = new $CCache();\n$cache->setDir($cachePath);\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * Prepare fast track cache for swriting cache items.\n */\n$fastTrackCache = \"fasttrack\";\n$allowFastTrackCache = getConfig('fast_track_allow', false);\n\n$CFastTrackCache = getConfig('CFastTrackCache', 'CFastTrackCache');\n$ftc = new $CFastTrackCache();\n$ftc->setCacheDir($cache->getPathToSubdir($fastTrackCache))\n    ->enable($allowFastTrackCache)\n    ->setFilename(array('no-cache', 'nc'));\n$img->injectDependency(\"fastTrackCache\", $ftc);\n\n\n\n/**\n *  Load and output images from fast track cache, if items are available\n * in cache.\n */\nif ($useCache && $allowFastTrackCache) {\n    if (CIMAGE_DEBUG) {\n        trace(\"img.php fast track cache enabled and used\");\n    }\n    $ftc->output();\n}\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $cacheRemote = $cache->getPathToSubdir(\"remote\");\n\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $cacheRemote, $pattern);\n\n    $whitelist = getConfig('remote_whitelist', null);\n    $img->setRemoteHostWhitelist($whitelist);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = urldecode(get('src', \"\"))\n    or errorPage('Must set src-attribute.', 404);\n\n// Get settings for src-alt as backup image\n$srcAltImage = urldecode(get('src-alt', \"\"));\n$srcAltConfig = getConfig('src_alt', null);\nif (empty($srcAltImage)) {\n    $srcAltImage = $srcAltConfig;\n}\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \\.:]+$#');\n\n// Source is remote\n$remoteSource = false;\n\n// Dummy image feature\n$dummyEnabled  = getConfig('dummy_enabled', true);\n$dummyFilename = getConfig('dummy_filename', 'dummy');\n$dummyImage = false;\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Source filename contains invalid characters.', 404);\n\nif ($dummyEnabled && $srcImage === $dummyFilename) {\n\n    // Prepare to create a dummy image and use it as the source image.\n    $dummyImage = true;\n\n} elseif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n    $remoteSource = true;\n\n} else {\n\n    // Check if file exists on disk or try using src-alt\n    $pathToImage = realpath($imagePath . $srcImage);\n\n    if (!is_file($pathToImage) && !empty($srcAltImage)) {\n        // Try using the src-alt instead\n        $srcImage = $srcAltImage;\n        $pathToImage = realpath($imagePath . $srcImage);\n\n        preg_match($validFilename, $srcImage)\n            or errorPage('Source (alt) filename contains invalid characters.', 404);\n\n        if ($dummyEnabled && $srcImage === $dummyFilename) {\n            // Check if src-alt is the dummy image\n            $dummyImage = true;\n        }\n    }\n\n    if (!$dummyImage) {\n        is_file($pathToImage)\n            or errorPage(\n                'Source image is not a valid file, check the filename and that a\n                matching file exists on the filesystem.',\n                404\n            );\n    }\n}\n\nif ($imagePathConstraint && !$dummyImage && !$remoteSource) {\n    // Check that the image is a file below the directory 'image_path'.\n    $imageDir = realpath($imagePath);\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.',\n            404\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth && $newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.', 404);\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.', 404);\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight && $newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.', 404);\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Height out of range.', 404);\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio && $aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range', 404);\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * Do or do not resample image when resizing.\n */\n$resizeStrategy = getDefined(array('no-resample'), true, false);\n\nif ($resizeStrategy) {\n    $img->setCopyResizeStrategy($img::RESIZE);\n    verbose(\"Setting = Resize instead of resample\");\n}\n\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n$useOriginalDefault = getConfig('skip_original', false);\n\nif ($useOriginalDefault === true) {\n    verbose(\"skip original is default ON\");\n    $useOriginal = false;\n}\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n$qualityDefault = getConfig('jpg_quality', null);\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range', 404);\n\nif (is_null($quality) && !is_null($qualityDefault)) {\n    $quality = $qualityDefault;\n}\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n$compressDefault = getConfig('png_compression', null);\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range', 404);\n\nif (is_null($compress) && !is_null($compressDefault)) {\n    $compress = $compressDefault;\n}\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range', 404);\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range', 404);\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range', 404);\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n* json -  output the image as a JSON object with details on the image.\n* ascii - output the image as ASCII art.\n */\n$outputFormat = getDefined('json', 'json', null);\n$outputFormat = getDefined('ascii', 'ascii', $outputFormat);\n\nverbose(\"outputformat = $outputFormat\");\n\nif ($outputFormat == 'ascii') {\n    $defaultOptions = getConfig(\n        'ascii-options',\n        array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        )\n    );\n    $options = get('ascii');\n    $options = explode(',', $options);\n\n    if (isset($options[0]) && !empty($options[0])) {\n        $defaultOptions['characterSet'] = $options[0];\n    }\n\n    if (isset($options[1]) && !empty($options[1])) {\n        $defaultOptions['scale'] = $options[1];\n    }\n\n    if (isset($options[2]) && !empty($options[2])) {\n        $defaultOptions['luminanceStrategy'] = $options[2];\n    }\n\n    if (count($options) > 3) {\n        // Last option is custom character string\n        unset($options[0]);\n        unset($options[1]);\n        unset($options[2]);\n        $characterString = implode($options);\n        $defaultOptions['customCharacterSet'] = $characterString;\n    }\n\n    $img->setAsciiOptions($defaultOptions);\n}\n\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_lossy'        => false,\n    'png_lossy_cmd'    => '/usr/local/bin/pngquant --force --output',\n\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * lossy - Do lossy postprocessing, if available.\n */\n$lossy = getDefined(array('lossy'), true, null);\n\nverbose(\"lossy = $lossy\");\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\", 403);\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.', 404);\n\n} elseif ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.', 403);\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Add cache control HTTP header.\n */\n$cacheControl = getConfig('cache_control', null);\n\nif ($cacheControl) {\n    verbose(\"cacheControl = $cacheControl\");\n    $img->addHTTPHeader(\"Cache-Control\", $cacheControl);\n}\n\n\n\n/**\n * interlace - Enable configuration for interlaced progressive JPEG images.\n */\n$interlaceConfig  = getConfig('interlace', null);\n$interlaceValue   = getValue('interlace', null);\n$interlaceDefined = getDefined('interlace', true, null);\n$interlace = $interlaceValue ?? $interlaceDefined ?? $interlaceConfig;\nverbose(\"interlace (configfile) = \", $interlaceConfig);\nverbose(\"interlace = \", $interlace);\n\n\n\n/**\n * Prepare a dummy image and use it as source image.\n */\nif ($dummyImage === true) {\n    $dummyDir = $cache->getPathToSubdir(\"dummy\");\n\n    $img->setSaveFolder($dummyDir)\n        ->setSource($dummyFilename, $dummyDir)\n        ->setOptions(\n            array(\n                'newWidth'  => $newWidth,\n                'newHeight' => $newHeight,\n                'bgColor'   => $bgColor,\n            )\n        )\n        ->setJpegQuality($quality)\n        ->setPngCompression($compress)\n        ->createDummyImage()\n        ->generateFilename(null, false)\n        ->save(null, null, false);\n\n    $srcImage = $img->getTarget();\n    $imagePath = null;\n\n    verbose(\"src (updated) = $srcImage\");\n}\n\n\n\n/**\n * Prepare a sRGB version of the image and use it as source image.\n */\n$srgbDefault = getConfig('srgb_default', false);\n$srgbColorProfile = getConfig('srgb_colorprofile', __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc');\n$srgb = getDefined('srgb', true, null);\n\nif ($srgb || $srgbDefault) {\n\n    $filename = $img->convert2sRGBColorSpace(\n        $srcImage,\n        $imagePath,\n        $cache->getPathToSubdir(\"srgb\"),\n        $srgbColorProfile,\n        $useCache\n    );\n\n    if ($filename) {\n        $srcImage = $img->getTarget();\n        $imagePath = null;\n        verbose(\"srgb conversion and saved to cache = $srcImage\");\n    } else {\n        verbose(\"srgb not op\");\n    }\n}\n\n\n\n/**\n * Display status\n */\nif ($status) {\n    $text  = \"img.php version = \" . CIMAGE_VERSION . \"\\n\";\n    $text .= \"PHP version = \" . PHP_VERSION . \"\\n\";\n    $text .= \"Running on: \" . $_SERVER['SERVER_SOFTWARE'] . \"\\n\";\n    $text .= \"Allow remote images = $allowRemote\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"\");\n    $text .= \"Cache $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"remote\");\n    $text .= \"Cache remote $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"dummy\");\n    $text .= \"Cache dummy $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"srgb\");\n    $text .= \"Cache srgb $res\\n\";\n\n    $res = $cache->getStatusOfSubdir($fastTrackCache);\n    $text .= \"Cache fasttrack $res\\n\";\n\n    $text .= \"Alias path writable = \" . is_writable($aliasPath) . \"\\n\";\n\n    $no = extension_loaded('exif') ? null : 'NOT';\n    $text .= \"Extension exif is $no loaded.<br>\";\n\n    $no = extension_loaded('curl') ? null : 'NOT';\n    $text .= \"Extension curl is $no loaded.<br>\";\n\n    $no = extension_loaded('imagick') ? null : 'NOT';\n    $text .= \"Extension imagick is $no loaded.<br>\";\n\n    $no = extension_loaded('gd') ? null : 'NOT';\n    $text .= \"Extension gd is $no loaded.<br>\";\n\n    $text .= checkExternalCommand(\"PNG LOSSY\", $postProcessing[\"png_lossy\"], $postProcessing[\"png_lossy_cmd\"]);\n    $text .= checkExternalCommand(\"PNG FILTER\", $postProcessing[\"png_filter\"], $postProcessing[\"png_filter_cmd\"]);\n    $text .= checkExternalCommand(\"PNG DEFLATE\", $postProcessing[\"png_deflate\"], $postProcessing[\"png_deflate_cmd\"]);\n    $text .= checkExternalCommand(\"JPEG OPTIMIZE\", $postProcessing[\"jpeg_optimize\"], $postProcessing[\"jpeg_optimize_cmd\"]);\n\n    if (!$no) {\n        $text .= print_r(gd_info(), 1);\n    }\n\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage status</title>\n<pre>$text</pre>\nEOD;\n    exit;\n}\n\n\n\n/**\n * Log verbose details to file\n */\nif ($verboseFile) {\n    $img->setVerboseToFile(\"$cachePath/log.txt\");\n}\n\n\n\n/**\n * Hook after img.php configuration and before processing with CImage\n */\n$hookBeforeCImage = getConfig('hook_before_CImage', null);\n\nif (is_callable($hookBeforeCImage)) {\n    verbose(\"hookBeforeCImage activated\");\n\n    $allConfig = $hookBeforeCImage($img, array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n            'interlace' => $interlace,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n\n            // Other\n            'postProcessing' => $postProcessing,\n            'lossy' => $lossy,\n    ));\n    verbose(print_r($allConfig, 1));\n    extract($allConfig);\n}\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\nmime type: \" + data.mimeType + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio + ( data.pngType ? \"\\\\npng-type: \" + data.pngType : '');\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"PHP version: \" . phpversion())\n    ->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n            'interlace' => $interlace,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n\n            // Postprocessing using external tools\n            'lossy' => $lossy,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n\n\n\n"
  },
  {
    "path": "webroot/imgf.php",
    "content": "<?php\n/**\n * Fast track cache, read entries from the cache before processing image\n * the ordinary way.\n */\n// Load the config file or use defaults\n$configFile = __DIR__\n    . \"/\"\n    . basename(__FILE__, \".php\")\n    . \"_config.php\";\n\nif (is_file($configFile) && is_readable($configFile)) {\n    $config = require $configFile;\n} elseif (!isset($config)) {\n    $config = array(\n        \"fast_track_allow\" =>  true,\n        \"autoloader\" =>  __DIR__ . \"/../autoload.php\",\n        \"cache_path\" =>  __DIR__ . \"/../cache/\",\n    );\n}\n\n// Make CIMAGE_DEBUG false by default, if not already defined\nif (!defined(\"CIMAGE_DEBUG\")) {\n    define(\"CIMAGE_DEBUG\", false);\n}\n\n// Debug mode needs additional functions\nif (CIMAGE_DEBUG) {\n    require $config[\"autoloader\"];\n}\n\n// Cache path must be valid\n$cacheIsReadable = is_dir($config[\"cache_path\"]) && is_readable($config[\"cache_path\"]);\nif (!$cacheIsReadable) {\n    die(\"imgf.php: Cache is not readable, check path in configfile.\");\n}\n\n// Prepare to check if fast cache should be used\n$cachePath = $config[\"cache_path\"] . \"/fasttrack\";\n$query = $_GET;\n\n// Do not use cache when no-cache is active\n$useCache = !(array_key_exists(\"no-cache\", $query) || array_key_exists(\"nc\", $query));\n\n// Only use cache if enabled by configuration\n$useCache = $useCache && isset($config[\"fast_track_allow\"]) && $config[\"fast_track_allow\"] === true;\n\n// Remove parts from querystring that should not be part of filename\n$clear = array(\"nc\", \"no-cache\");\nforeach ($clear as $value) {\n    unset($query[$value]);\n}\n\n// Create the cache filename\narsort($query);\n$queryAsString = http_build_query($query);\n$filename = md5($queryAsString);\n$filename = \"$cachePath/$filename\";\n\n// Check cached item, if any\nif ($useCache && is_readable($filename)) {\n    $item = json_decode(file_get_contents($filename), true);\n\n    if (is_readable($item[\"source\"])) {\n        foreach ($item[\"header\"] as $value) {\n            header($value);\n        }\n\n        if (isset($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"])\n            && strtotime($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"]) == $item[\"last-modified\"]) {\n            header(\"HTTP/1.0 304 Not Modified\");\n            if (CIMAGE_DEBUG) {\n                trace(\"imgf 304\");\n            }\n            exit;\n        }\n\n        foreach ($item[\"header-output\"] as $value) {\n            header($value);\n        }\n\n        if (CIMAGE_DEBUG) {\n            trace(\"imgf 200\");\n        }\n        readfile($item[\"source\"]);\n        exit;\n    }\n}\n\n// No fast track cache, proceed as usual\ninclude __DIR__ . \"/img.php\";\n"
  },
  {
    "path": "webroot/imgp.php",
    "content": "<?php\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * This version is a all-in-one version of img.php, it is not dependant an any other file\n * so you can simply copy it to any place you want it.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\ndefine(\"CIMAGE_BUNDLE\", true);\n\n\n/**\n * Change configuration details in the array below or create a separate file\n * where you store the configuration details.\n *\n * The configuration file should be named the same name as this file and then\n * add '_config.php'. If this file is named 'img.php' then name the\n * config file should be named 'img_config.php'.\n *\n * The settings below are only a few of the available ones. Check the file in\n * webroot/img_config.php for a complete list of configuration options.\n */\n$config = array(\n\n    //'mode'         => 'production',               // 'production', 'development', 'strict'\n    //'image_path'   =>  __DIR__ . '/img/',\n    //'cache_path'   =>  __DIR__ . '/../cache/',\n    //'alias_path'   =>  __DIR__ . '/img/alias/',\n    //'remote_allow' => true,\n    //'password'     => false,                      // \"secret-password\",\n\n);\n\n\n\n// Version of cimage and img.php\ndefine(\"CIMAGE_VERSION\", \"v0.8.6 (2023-10-27)\");\n\n// For CRemoteImage\ndefine(\"CIMAGE_USER_AGENT\", \"CImage/\" . CIMAGE_VERSION);\n\n// Image type IMG_WEBP is only defined from 5.6.25\nif (!defined(\"IMG_WEBP\")) {\n    define(\"IMG_WEBP\", -1);\n}\n\n\n\n/**\n * General functions to use in img.php.\n */\n\n\n\n/**\n * Trace and log execution to logfile, useful for debugging and development.\n *\n * @param string $msg message to log to file.\n *\n * @return void\n */\nfunction trace($msg)\n{\n    $file = CIMAGE_DEBUG_FILE;\n    if (!is_writable($file)) {\n        return;\n    }\n\n    $timer = number_format((microtime(true) - $_SERVER[\"REQUEST_TIME_FLOAT\"]), 6);\n    $details  = \"{$timer}ms\";\n    $details .= \":\" . round(memory_get_peak_usage()/1024/1024, 3) . \"MB\";\n    $details .= \":\" . count(get_included_files());\n    file_put_contents($file, \"$details:$msg\\n\", FILE_APPEND);\n}\n\n\n\n/**\n * Display error message.\n *\n * @param string $msg to display.\n * @param int $type of HTTP error to display.\n *\n * @return void\n */\nfunction errorPage($msg, $type = 500)\n{\n    global $mode;\n\n    switch ($type) {\n        case 403:\n            $header = \"403 Forbidden\";\n            break;\n        case 404:\n            $header = \"404 Not Found\";\n            break;\n        default:\n            $header = \"500 Internal Server Error\";\n    }\n\n    if ($mode == \"strict\") {\n        $header = \"404 Not Found\";\n    }\n\n    header(\"HTTP/1.0 $header\");\n\n    if ($mode == \"development\") {\n        die(\"[img.php] $msg\");\n    }\n\n    error_log(\"[img.php] $msg\");\n    die(\"HTTP/1.0 $header\");\n}\n\n\n\n/**\n * Get input from query string or return default value if not set.\n *\n * @param mixed $key     as string or array of string values to look for in $_GET.\n * @param mixed $default value to return when $key is not set in $_GET.\n *\n * @return mixed value from $_GET or default value.\n */\nfunction get($key, $default = null)\n{\n    if (is_array($key)) {\n        foreach ($key as $val) {\n            if (isset($_GET[$val])) {\n                return $_GET[$val];\n            }\n        }\n    } elseif (isset($_GET[$key])) {\n        return $_GET[$key];\n    }\n    return $default;\n}\n\n\n\n/**\n * Get input from query string and set to $defined if defined or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $defined   value to return when $key is set in $_GET.\n * @param mixed $undefined value to return when $key is not set in $_GET.\n *\n * @return mixed value as $defined or $undefined.\n */\nfunction getDefined($key, $defined, $undefined)\n{\n    return get($key) === null ? $undefined : $defined;\n}\n\n\n\n/**\n * Get value of input from query string or else $undefined.\n *\n * @param mixed $key       as string or array of string values to look for in $_GET.\n * @param mixed $undefined value to return when $key has no, or empty value in $_GET.\n *\n * @return mixed value as or $undefined.\n */\nfunction getValue($key, $undefined)\n{\n    $val = get($key);\n    if (is_null($val) || $val === \"\") {\n        return $undefined;\n    }\n    return $val;\n}\n\n\n\n/**\n * Get value from config array or default if key is not set in config array.\n *\n * @param string $key    the key in the config array.\n * @param mixed $default value to be default if $key is not set in config.\n *\n * @return mixed value as $config[$key] or $default.\n */\nfunction getConfig($key, $default)\n{\n    global $config;\n    return isset($config[$key])\n        ? $config[$key]\n        : $default;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction verbose($msg = null, $arg = \"\")\n{\n    global $verbose, $verboseFile;\n    static $log = array();\n\n    if (!($verbose || $verboseFile)) {\n        return;\n    }\n\n    if (is_null($msg)) {\n        return $log;\n    }\n\n    if (is_null($arg)) {\n        $arg = \"null\";\n    } elseif ($arg === false) {\n        $arg = \"false\";\n    } elseif ($arg === true) {\n        $arg = \"true\";\n    }\n\n    $log[] = $msg . $arg;\n}\n\n\n\n/**\n * Log when verbose mode, when used without argument it returns the result.\n *\n * @param string $msg to log.\n *\n * @return void or array.\n */\nfunction checkExternalCommand($what, $enabled, $commandString)\n{\n    $no = $enabled ? null : 'NOT';\n    $text = \"Post processing $what is $no enabled.<br>\";\n\n    list($command) = explode(\" \", $commandString);\n    $no = is_executable($command) ? null : 'NOT';\n    $text .= \"The command for $what is $no an executable.<br>\";\n\n    return $text;\n}\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CHttpGet\n{\n    private $request  = array();\n    private $response = array();\n\n\n\n    /**\n    * Constructor\n    *\n    */\n    public function __construct()\n    {\n        $this->request['header'] = array();\n    }\n\n\n\n    /**\n     * Build an encoded url.\n     *\n     * @param string $baseUrl This is the original url which will be merged.\n     * @param string $merge   Thse parts should be merged into the baseUrl,\n     *                        the format is as parse_url.\n     *\n     * @return string $url as the modified url.\n     */\n    public function buildUrl($baseUrl, $merge)\n    {\n        $parts = parse_url($baseUrl);\n        $parts = array_merge($parts, $merge);\n\n        $url  = $parts['scheme'];\n        $url .= \"://\";\n        $url .= $parts['host'];\n        $url .= isset($parts['port'])\n            ? \":\" . $parts['port']\n            : \"\" ;\n        $url .= $parts['path'];\n\n        return $url;\n    }\n\n\n\n    /**\n     * Set the url for the request.\n     *\n     * @param string $url\n     *\n     * @return $this\n     */\n    public function setUrl($url)\n    {\n        $parts = parse_url($url);\n        \n        $path = \"\";\n        if (isset($parts['path'])) {\n            $pathParts = explode('/', $parts['path']);\n            unset($pathParts[0]);\n            foreach ($pathParts as $value) {\n                $path .= \"/\" . rawurlencode($value);\n            }\n        }\n        $url = $this->buildUrl($url, array(\"path\" => $path));\n\n        $this->request['url'] = $url;\n        return $this;\n    }\n\n\n\n    /**\n     * Set custom header field for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function setHeader($field, $value)\n    {\n        $this->request['header'][] = \"$field: $value\";\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields for the request.\n     *\n     * @param string $field\n     * @param string $value\n     *\n     * @return $this\n     */\n    public function parseHeader()\n    {\n        //$header = explode(\"\\r\\n\", rtrim($this->response['headerRaw'], \"\\r\\n\"));\n        \n        $rawHeaders = rtrim($this->response['headerRaw'], \"\\r\\n\");\n        # Handle multiple responses e.g. with redirections (proxies too)\n        $headerGroups = explode(\"\\r\\n\\r\\n\", $rawHeaders);\n        # We're only interested in the last one\n        $header = explode(\"\\r\\n\", end($headerGroups));\n\n        $output = array();\n\n        if ('HTTP' === substr($header[0], 0, 4)) {\n            list($output['version'], $output['status']) = explode(' ', $header[0]);\n            unset($header[0]);\n        }\n\n        foreach ($header as $entry) {\n            $pos = strpos($entry, ':');\n            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));\n        }\n\n        $this->response['header'] = $output;\n        return $this;\n    }\n\n\n\n    /**\n     * Perform the request.\n     *\n     * @param boolean $debug set to true to dump headers.\n     *\n     * @throws Exception when curl fails to retrieve url.\n     *\n     * @return boolean\n     */\n    public function doGet($debug = false)\n    {\n        $options = array(\n            CURLOPT_URL             => $this->request['url'],\n            CURLOPT_HEADER          => 1,\n            CURLOPT_HTTPHEADER      => $this->request['header'],\n            CURLOPT_AUTOREFERER     => true,\n            CURLOPT_RETURNTRANSFER  => true,\n            CURLINFO_HEADER_OUT     => $debug,\n            CURLOPT_CONNECTTIMEOUT  => 5,\n            CURLOPT_TIMEOUT         => 5,\n            CURLOPT_FOLLOWLOCATION  => true,\n            CURLOPT_MAXREDIRS       => 2,\n        );\n\n        $ch = curl_init();\n        curl_setopt_array($ch, $options);\n        $response = curl_exec($ch);\n\n        if (!$response) {\n            throw new Exception(\"Failed retrieving url, details follows: \" . curl_error($ch));\n        }\n\n        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n        $this->response['headerRaw'] = substr($response, 0, $headerSize);\n        $this->response['body']      = substr($response, $headerSize);\n\n        $this->parseHeader();\n\n        if ($debug) {\n            $info = curl_getinfo($ch);\n            echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\";\n            echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\";\n            echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\";\n        }\n\n        curl_close($ch);\n        return true;\n    }\n\n\n\n    /**\n     * Get HTTP code of response.\n     *\n     * @return integer as HTTP status code or null if not available.\n     */\n    public function getStatus()\n    {\n        return isset($this->response['header']['status'])\n            ? (int) $this->response['header']['status']\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @return int as timestamp.\n     */\n    public function getLastModified()\n    {\n        return isset($this->response['header']['Last-Modified'])\n            ? strtotime($this->response['header']['Last-Modified'])\n            : null;\n    }\n\n\n\n    /**\n     * Get content type.\n     *\n     * @return string as the content type or null if not existing or invalid.\n     */\n    public function getContentType()\n    {\n        $type = isset($this->response['header']['Content-Type'])\n            ? $this->response['header']['Content-Type']\n            : '';\n\n        return preg_match('#[a-z]+/[a-z]+#', $type)\n            ? $type\n            : null;\n    }\n\n\n\n    /**\n     * Get file modification time of response.\n     *\n     * @param mixed $default as default value (int seconds) if date is\n     *                       missing in response header.\n     *\n     * @return int as timestamp or $default if Date is missing in\n     *             response header.\n     */\n    public function getDate($default = false)\n    {\n        return isset($this->response['header']['Date'])\n            ? strtotime($this->response['header']['Date'])\n            : $default;\n    }\n\n\n\n    /**\n     * Get max age of cachable item.\n     *\n     * @param mixed $default as default value if date is missing in response\n     *                       header.\n     *\n     * @return int as timestamp or false if not available.\n     */\n    public function getMaxAge($default = false)\n    {\n        $cacheControl = isset($this->response['header']['Cache-Control'])\n            ? $this->response['header']['Cache-Control']\n            : null;\n\n        $maxAge = null;\n        if ($cacheControl) {\n            // max-age=2592000\n            $part = explode('=', $cacheControl);\n            $maxAge = ($part[0] == \"max-age\")\n                ? (int) $part[1]\n                : null;\n        }\n\n        if ($maxAge) {\n            return $maxAge;\n        }\n\n        $expire = isset($this->response['header']['Expires'])\n            ? strtotime($this->response['header']['Expires'])\n            : null;\n\n        return $expire ? $expire : $default;\n    }\n\n\n\n    /**\n     * Get body of response.\n     *\n     * @return string as body.\n     */\n    public function getBody()\n    {\n        return $this->response['body'];\n    }\n}\n\n\n\n/**\n * Get a image from a remote server using HTTP GET and If-Modified-Since.\n *\n */\nclass CRemoteImage\n{\n    /**\n     * Path to cache files.\n     */\n    private $saveFolder = null;\n\n\n\n    /**\n     * Use cache or not.\n     */\n    private $useCache = true;\n\n\n\n    /**\n     * HTTP object to aid in download file.\n     */\n    private $http;\n\n\n\n    /**\n     * Status of the HTTP request.\n     */\n    private $status;\n\n\n\n    /**\n     * Defalt age for cached items 60*60*24*7.\n     */\n    private $defaultMaxAge = 604800;\n\n\n\n    /**\n     * Url of downloaded item.\n     */\n    private $url;\n\n\n\n    /**\n     * Base name of cache file for downloaded item and name of image.\n     */\n    private $fileName;\n\n\n\n    /**\n     * Filename for json-file with details of cached item.\n     */\n    private $fileJson;\n\n\n\n    /**\n     * Cache details loaded from file.\n     */\n    private $cache;\n\n\n\n    /**\n     * Get status of last HTTP request.\n     *\n     * @return int as status\n     */\n    public function getStatus()\n    {\n        return $this->status;\n    }\n\n\n\n    /**\n     * Get JSON details for cache item.\n     *\n     * @return array with json details on cache.\n     */\n    public function getDetails()\n    {\n        return $this->cache;\n    }\n\n\n\n    /**\n     * Set the path to the cache directory.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function setCache($path)\n    {\n        $this->saveFolder = rtrim($path, \"/\") . \"/\";\n        return $this;\n    }\n\n\n\n    /**\n     * Check if cache is writable or throw exception.\n     *\n     * @return $this\n     *\n     * @throws Exception if cahce folder is not writable.\n     */\n    public function isCacheWritable()\n    {\n        if (!is_writable($this->saveFolder)) {\n            throw new Exception(\"Cache folder is not writable for downloaded files.\");\n        }\n        return $this;\n    }\n\n\n\n    /**\n     * Decide if the cache should be used or not before trying to download\n     * a remote file.\n     *\n     * @param boolean $use true to use the cache and false to ignore cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Set header fields.\n     *\n     * @return $this\n     */\n    public function setHeaderFields()\n    {\n        $cimageVersion = \"CImage\";\n        if (defined(\"CIMAGE_USER_AGENT\")) {\n            $cimageVersion = CIMAGE_USER_AGENT;\n        }\n        \n        $this->http->setHeader(\"User-Agent\", \"$cimageVersion (PHP/\". phpversion() . \" cURL)\");\n        $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\");\n\n        if ($this->useCache) {\n            $this->http->setHeader(\"Cache-Control\", \"max-age=0\");\n        } else {\n            $this->http->setHeader(\"Cache-Control\", \"no-cache\");\n            $this->http->setHeader(\"Pragma\", \"no-cache\");\n        }\n    }\n\n\n\n    /**\n     * Save downloaded resource to cache.\n     *\n     * @return string as path to saved file or false if not saved.\n     */\n    public function save()\n    {\n        $this->cache = array();\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n        $type         = $this->http->getContentType();\n\n        $this->cache['Date']           = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age']        = $maxAge;\n        $this->cache['Content-Type']   = $type;\n        $this->cache['Url']            = $this->url;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        // Save only if body is a valid image\n        $body = $this->http->getBody();\n        $img = imagecreatefromstring($body);\n\n        if ($img !== false) {\n            file_put_contents($this->fileName, $body);\n            file_put_contents($this->fileJson, json_encode($this->cache));\n            return $this->fileName;\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Got a 304 and updates cache with new age.\n     *\n     * @return string as path to cached file.\n     */\n    public function updateCacheDetails()\n    {\n        $date         = $this->http->getDate(time());\n        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);\n        $lastModified = $this->http->getLastModified();\n\n        $this->cache['Date']    = gmdate(\"D, d M Y H:i:s T\", $date);\n        $this->cache['Max-Age'] = $maxAge;\n\n        if ($lastModified) {\n            $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified);\n        }\n\n        file_put_contents($this->fileJson, json_encode($this->cache));\n        return $this->fileName;\n    }\n\n\n\n    /**\n     * Download a remote file and keep a cache of downloaded files.\n     *\n     * @param string $url a remote url.\n     *\n     * @throws Exception when status code does not match 200 or 304.\n     *\n     * @return string as path to downloaded file or false if failed.\n     */\n    public function download($url)\n    {\n        $this->http = new CHttpGet();\n        $this->url = $url;\n\n        // First check if the cache is valid and can be used\n        $this->loadCacheDetails();\n\n        if ($this->useCache) {\n            $src = $this->getCachedSource();\n            if ($src) {\n                $this->status = 1;\n                return $src;\n            }\n        }\n\n        // Do a HTTP request to download item\n        $this->setHeaderFields();\n        $this->http->setUrl($this->url);\n        $this->http->doGet();\n\n        $this->status = $this->http->getStatus();\n        if ($this->status === 200) {\n            $this->isCacheWritable();\n            return $this->save();\n        } elseif ($this->status === 304) {\n            $this->isCacheWritable();\n            return $this->updateCacheDetails();\n        }\n\n        throw new Exception(\"Unknown statuscode when downloading remote image: \" . $this->status);\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return $this\n     */\n    public function loadCacheDetails()\n    {\n        $cacheFile = md5($this->url);\n        $this->fileName = $this->saveFolder . $cacheFile;\n        $this->fileJson = $this->fileName . \".json\";\n        if (is_readable($this->fileJson)) {\n            $this->cache = json_decode(file_get_contents($this->fileJson), true);\n        }\n    }\n\n\n\n    /**\n     * Get the path to the cached image file if the cache is valid.\n     *\n     * @return string as the path ot the image file or false if no cache.\n     */\n    public function getCachedSource()\n    {\n        $imageExists = is_readable($this->fileName);\n\n        // Is cache valid?\n        $date   = strtotime($this->cache['Date']);\n        $maxAge = $this->cache['Max-Age'];\n        $now    = time();\n        \n        if ($imageExists && $date + $maxAge > $now) {\n            return $this->fileName;\n        }\n\n        // Prepare for a 304 if available\n        if ($imageExists && isset($this->cache['Last-Modified'])) {\n            $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']);\n        }\n\n        return false;\n    }\n}\n\n\n\n/**\n * Act as whitelist (or blacklist).\n *\n */\nclass CWhitelist\n{\n    /**\n     * Array to contain the whitelist options.\n     */\n    private $whitelist = array();\n\n\n\n    /**\n     * Set the whitelist from an array of strings, each item in the\n     * whitelist should be a regexp without the surrounding / or #.\n     *\n     * @param array $whitelist with all valid options,\n     *                         default is to clear the whitelist.\n     *\n     * @return $this\n     */\n    public function set($whitelist = array())\n    {\n        if (!is_array($whitelist)) {\n            throw new Exception(\"Whitelist is not of a supported format.\");\n        }\n\n        $this->whitelist = $whitelist;\n        return $this;\n    }\n\n\n\n    /**\n     * Check if item exists in the whitelist.\n     *\n     * @param string $item      string to check.\n     * @param array  $whitelist optional with all valid options, default is null.\n     *\n     * @return boolean true if item is in whitelist, else false.\n     */\n    public function check($item, $whitelist = null)\n    {\n        if ($whitelist !== null) {\n            $this->set($whitelist);\n        }\n        \n        if (empty($item) or empty($this->whitelist)) {\n            return false;\n        }\n        \n        foreach ($this->whitelist as $regexp) {\n            if (preg_match(\"#$regexp#\", $item)) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n}\n\n\n\n/**\n * Create an ASCII version of an image.\n *\n */\nclass CAsciiArt\n{\n    /**\n     * Character set to use.\n     */\n    private $characterSet = array(\n        'one' => \"#0XT|:,.' \",\n        'two' => \"@%#*+=-:. \",\n        'three' => \"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\\\"^`'. \"\n    );\n\n\n\n    /**\n     * Current character set.\n     */\n    private $characters = null;\n\n\n\n    /**\n     * Length of current character set.\n     */\n    private $charCount = null;\n\n\n\n    /**\n     * Scale of the area to swap to a character.\n     */\n    private $scale = null;\n\n\n\n    /**\n     * Strategy to calculate luminance.\n     */\n    private $luminanceStrategy = null;\n\n\n\n    /**\n     * Constructor which sets default options.\n     */\n    public function __construct()\n    {\n        $this->setOptions();\n    }\n\n\n\n    /**\n     * Add a custom character set.\n     *\n     * @param string $key   for the character set.\n     * @param string $value for the character set.\n     *\n     * @return $this\n     */\n    public function addCharacterSet($key, $value)\n    {\n        $this->characterSet[$key] = $value;\n        return $this;\n    }\n\n\n\n    /**\n     * Set options for processing, defaults are available.\n     *\n     * @param array $options to use as default settings.\n     *\n     * @return $this\n     */\n    public function setOptions($options = array())\n    {\n        $default = array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        );\n        $default = array_merge($default, $options);\n        \n        if (!is_null($default['customCharacterSet'])) {\n            $this->addCharacterSet('custom', $default['customCharacterSet']);\n            $default['characterSet'] = 'custom';\n        }\n        \n        $this->scale = $default['scale'];\n        $this->characters = $this->characterSet[$default['characterSet']];\n        $this->charCount = strlen($this->characters);\n        $this->luminanceStrategy = $default['luminanceStrategy'];\n        \n        return $this;\n    }\n\n\n\n    /**\n     * Create an Ascii image from an image file.\n     *\n     * @param string $filename of the image to use.\n     *\n     * @return string $ascii with the ASCII image.\n     */\n    public function createFromFile($filename)\n    {\n        $img = imagecreatefromstring(file_get_contents($filename));\n        list($width, $height) = getimagesize($filename);\n\n        $ascii = null;\n        $incY = $this->scale;\n        $incX = $this->scale / 2;\n        \n        for ($y = 0; $y < $height - 1; $y += $incY) {\n            for ($x = 0; $x < $width - 1; $x += $incX) {\n                $toX = min($x + $this->scale / 2, $width - 1);\n                $toY = min($y + $this->scale, $height - 1);\n                $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);\n                $ascii .= $this->luminance2character($luminance);\n            }\n            $ascii .= PHP_EOL;\n        }\n\n        return $ascii;\n    }\n\n\n\n    /**\n     * Get the luminance from a region of an image using average color value.\n     *\n     * @param string  $img the image.\n     * @param integer $x1  the area to get pixels from.\n     * @param integer $y1  the area to get pixels from.\n     * @param integer $x2  the area to get pixels from.\n     * @param integer $y2  the area to get pixels from.\n     *\n     * @return integer $luminance with a value between 0 and 100.\n     */\n    public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2)\n    {\n        $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1);\n        $luminance = 0;\n        \n        for ($x = $x1; $x <= $x2; $x++) {\n            for ($y = $y1; $y <= $y2; $y++) {\n                $rgb   = imagecolorat($img, $x, $y);\n                $red   = (($rgb >> 16) & 0xFF);\n                $green = (($rgb >> 8) & 0xFF);\n                $blue  = ($rgb & 0xFF);\n                $luminance += $this->getLuminance($red, $green, $blue);\n            }\n        }\n        \n        return $luminance / $numPixels;\n    }\n\n\n\n    /**\n     * Calculate luminance value with different strategies.\n     *\n     * @param integer $red   The color red.\n     * @param integer $green The color green.\n     * @param integer $blue  The color blue.\n     *\n     * @return float $luminance with a value between 0 and 1.\n     */\n    public function getLuminance($red, $green, $blue)\n    {\n        switch ($this->luminanceStrategy) {\n            case 1:\n                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;\n                break;\n            case 2:\n                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;\n                break;\n            case 3:\n                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;\n                break;\n            case 0:\n            default:\n                $luminance = ($red + $green + $blue) / (255 * 3);\n        }\n\n        return $luminance;\n    }\n\n\n\n    /**\n     * Translate the luminance value to a character.\n     *\n     * @param string $position a value between 0-100 representing the\n     *                         luminance.\n     *\n     * @return string with the ascii character.\n     */\n    public function luminance2character($luminance)\n    {\n        $position = (int) round($luminance * ($this->charCount - 1));\n        $char = $this->characters[$position];\n        return $char;\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n */\n#[AllowDynamicProperties]\nclass CImage\n{\n\n    /**\n     * Constants type of PNG image\n     */\n    const PNG_GREYSCALE         = 0;\n    const PNG_RGB               = 2;\n    const PNG_RGB_PALETTE       = 3;\n    const PNG_GREYSCALE_ALPHA   = 4;\n    const PNG_RGB_ALPHA         = 6;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const JPEG_QUALITY_DEFAULT = 60;\n\n\n\n    /**\n     * Quality level for JPEG images.\n     */\n    private $quality;\n\n\n\n    /**\n     * Is the quality level set from external use (true) or is it default (false)?\n     */\n    private $useQuality = false;\n\n\n\n    /**\n     * Constant for default image quality when not set\n     */\n    const PNG_COMPRESSION_DEFAULT = -1;\n\n\n\n    /**\n     * Compression level for PNG images.\n     */\n    private $compress;\n\n\n\n    /**\n     * Is the compress level set from external use (true) or is it default (false)?\n     */\n    private $useCompress = false;\n\n\n\n\n    /**\n     * Add HTTP headers for outputing image.\n     */\n    private $HTTPHeader = array();\n\n\n\n    /**\n     * Default background color, red, green, blue, alpha.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    /*\n    const BACKGROUND_COLOR = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );*/\n\n\n\n    /**\n     * Default background color to use.\n     *\n     * @todo remake when upgrading to PHP 5.5\n     */\n    //private $bgColorDefault = self::BACKGROUND_COLOR;\n    private $bgColorDefault = array(\n        'red'   => 0,\n        'green' => 0,\n        'blue'  => 0,\n        'alpha' => null,\n    );\n\n\n    /**\n     * Background color to use, specified as part of options.\n     */\n    private $bgColor;\n\n\n\n    /**\n     * Where to save the target file.\n     */\n    private $saveFolder;\n\n\n\n    /**\n     * The working image object.\n     */\n    private $image;\n\n\n\n    /**\n     * Image filename, may include subdirectory, relative from $imageFolder\n     */\n    private $imageSrc;\n\n\n\n    /**\n     * Actual path to the image, $imageFolder . '/' . $imageSrc\n     */\n    private $pathToImage;\n\n\n\n    /**\n     * File type for source image, as provided by getimagesize()\n     */\n    private $fileType;\n\n\n\n    /**\n     * File extension to use when saving image.\n     */\n    private $extension;\n\n\n\n    /**\n     * Output format, supports null (image) or json.\n     */\n    private $outputFormat = null;\n\n\n\n    /**\n     * Do lossy output using external postprocessing tools.\n     */\n    private $lossy = null;\n\n\n\n    /**\n     * Verbose mode to print out a trace and display the created image\n     */\n    private $verbose = false;\n\n\n\n    /**\n     * Keep a log/trace on what happens\n     */\n    private $log = array();\n\n\n\n    /**\n     * Handle image as palette image\n     */\n    private $palette;\n\n\n\n    /**\n     * Target filename, with path, to save resulting image in.\n     */\n    private $cacheFileName;\n\n\n\n    /**\n     * Set a format to save image as, or null to use original format.\n     */\n    private $saveAs;\n\n\n    /**\n     * Path to command for lossy optimize, for example pngquant.\n     */\n    private $pngLossy;\n    private $pngLossyCmd;\n\n\n\n    /**\n     * Path to command for filter optimize, for example optipng.\n     */\n    private $pngFilter;\n    private $pngFilterCmd;\n\n\n\n    /**\n     * Path to command for deflate optimize, for example pngout.\n     */\n    private $pngDeflate;\n    private $pngDeflateCmd;\n\n\n\n    /**\n     * Path to command to optimize jpeg images, for example jpegtran or null.\n     */\n     private $jpegOptimize;\n     private $jpegOptimizeCmd;\n\n\n\n    /**\n     * Image dimensions, calculated from loaded image.\n     */\n    private $width;  // Calculated from source image\n    private $height; // Calculated from source image\n\n\n    /**\n     * New image dimensions, incoming as argument or calculated.\n     */\n    private $newWidth;\n    private $newWidthOrig;  // Save original value\n    private $newHeight;\n    private $newHeightOrig; // Save original value\n\n\n    /**\n     * Change target height & width when different dpr, dpr 2 means double image dimensions.\n     */\n    private $dpr = 1;\n\n\n    /**\n     * Always upscale images, even if they are smaller than target image.\n     */\n    const UPSCALE_DEFAULT = true;\n    private $upscale = self::UPSCALE_DEFAULT;\n\n\n\n    /**\n     * Array with details on how to crop, incoming as argument and calculated.\n     */\n    public $crop;\n    public $cropOrig; // Save original value\n\n\n    /**\n     * String with details on how to do image convolution. String\n     * should map a key in the $convolvs array or be a string of\n     * 11 float values separated by comma. The first nine builds\n     * up the matrix, then divisor and last offset.\n     */\n    private $convolve;\n\n\n    /**\n     * Custom convolution expressions, matrix 3x3, divisor and offset.\n     */\n    private $convolves = array(\n        'lighten'       => '0,0,0, 0,12,0, 0,0,0, 9, 0',\n        'darken'        => '0,0,0, 0,6,0, 0,0,0, 9, 0',\n        'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',\n        'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',\n        'emboss'        => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0',\n        'emboss-alt'    => '-2,-1,0, -1,1,1, 0,1,2, 1, 0',\n        'blur'          => '1,1,1, 1,15,1, 1,1,1, 23, 0',\n        'gblur'         => '1,2,1, 2,4,2, 1,2,1, 16, 0',\n        'edge'          => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0',\n        'edge-alt'      => '0,1,0, 1,-4,1, 0,1,0, 1, 0',\n        'draw'          => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0',\n        'mean'          => '1,1,1, 1,1,1, 1,1,1, 9, 0',\n        'motion'        => '1,0,0, 0,1,0, 0,0,1, 3, 0',\n    );\n\n\n    /**\n     * Resize strategy to fill extra area with background color.\n     * True or false.\n     */\n    private $fillToFit;\n\n\n\n    /**\n     * To store value for option scale.\n     */\n    private $scale;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateBefore;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $rotateAfter;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $autoRotate;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $sharpen;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $emboss;\n\n\n\n    /**\n     * To store value for option.\n     */\n    private $blur;\n\n\n\n    /**\n     * Used with option area to set which parts of the image to use.\n     */\n    private $offset;\n\n\n\n    /**\n     * Calculate target dimension for image when using fill-to-fit resize strategy.\n     */\n    private $fillWidth;\n    private $fillHeight;\n\n\n\n    /**\n     * Allow remote file download, default is to disallow remote file download.\n     */\n    private $allowRemote = false;\n\n\n\n    /**\n     * Path to cache for remote download.\n     */\n    private $remoteCache;\n\n\n\n    /**\n     * Pattern to recognize a remote file.\n     */\n    //private $remotePattern = '#^[http|https]://#';\n    private $remotePattern = '#^https?://#';\n\n\n\n    /**\n     * Use the cache if true, set to false to ignore the cached file.\n     */\n    private $useCache = true;\n\n\n    /**\n    * Disable the fasttrackCacke to start with, inject an object to enable it.\n    */\n    private $fastTrackCache = null;\n\n\n\n    /*\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     */\n    private $remoteHostWhitelist = null;\n\n\n\n    /*\n     * Do verbose logging to file by setting this to a filename.\n     */\n    private $verboseFileName = null;\n\n\n\n    /*\n     * Output to ascii can take som options as an array.\n     */\n    private $asciiOptions = array();\n\n\n\n    /*\n     * Use interlaced progressive mode for JPEG images.\n     */\n    private $interlace = false;\n\n\n\n    /*\n     * Image copy strategy, defaults to RESAMPLE.\n     */\n     const RESIZE = 1;\n     const RESAMPLE = 2;\n     private $copyStrategy = NULL;\n\n\n\n    /**\n     * Properties, the class is mutable and the method setOptions()\n     * decides (partly) what properties are created.\n     *\n     * @todo Clean up these and check if and how they are used\n     */\n\n    public $keepRatio;\n    public $cropToFit;\n    private $cropWidth;\n    private $cropHeight;\n    public $crop_x;\n    public $crop_y;\n    public $filters;\n    private $attr; // Calculated from source image\n\n\n\n\n    /**\n     * Constructor, can take arguments to init the object.\n     *\n     * @param string $imageSrc    filename which may contain subdirectory.\n     * @param string $imageFolder path to root folder for images.\n     * @param string $saveFolder  path to folder where to save the new file or null to skip saving.\n     * @param string $saveName    name of target file when saveing.\n     */\n    public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null)\n    {\n        $this->setSource($imageSrc, $imageFolder);\n        $this->setTarget($saveFolder, $saveName);\n    }\n\n\n\n    /**\n     * Inject object and use it, must be available as member.\n     *\n     * @param string $property to set as object.\n     * @param object $object   to set to property.\n     *\n     * @return $this\n     */\n    public function injectDependency($property, $object)\n    {\n        if (!property_exists($this, $property)) {\n            $this->raiseError(\"Injecting unknown property.\");\n        }\n        $this->$property = $object;\n        return $this;\n    }\n\n\n\n    /**\n     * Set verbose mode.\n     *\n     * @param boolean $mode true or false to enable and disable verbose mode,\n     *                      default is true.\n     *\n     * @return $this\n     */\n    public function setVerbose($mode = true)\n    {\n        $this->verbose = $mode;\n        return $this;\n    }\n\n\n\n    /**\n     * Set save folder, base folder for saving cache files.\n     *\n     * @todo clean up how $this->saveFolder is used in other methods.\n     *\n     * @param string $path where to store cached files.\n     *\n     * @return $this\n     */\n    public function setSaveFolder($path)\n    {\n        $this->saveFolder = $path;\n        return $this;\n    }\n\n\n\n    /**\n     * Use cache or not.\n     *\n     * @param boolean $use true or false to use cache.\n     *\n     * @return $this\n     */\n    public function useCache($use = true)\n    {\n        $this->useCache = $use;\n        return $this;\n    }\n\n\n\n    /**\n     * Create and save a dummy image. Use dimensions as stated in\n     * $this->newWidth, or $width or default to 100 (same for height.\n     *\n     * @param integer $width  use specified width for image dimension.\n     * @param integer $height use specified width for image dimension.\n     *\n     * @return $this\n     */\n    public function createDummyImage($width = null, $height = null)\n    {\n        $this->newWidth  = $this->newWidth  ?: $width  ?: 100;\n        $this->newHeight = $this->newHeight ?: $height ?: 100;\n\n        $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Allow or disallow remote image download.\n     *\n     * @param boolean $allow   true or false to enable and disable.\n     * @param string  $cache   path to cache dir.\n     * @param string  $pattern to use to detect if its a remote file.\n     *\n     * @return $this\n     */\n    public function setRemoteDownload($allow, $cache, $pattern = null)\n    {\n        $this->allowRemote = $allow;\n        $this->remoteCache = $cache;\n        $this->remotePattern = is_null($pattern) ? $this->remotePattern : $pattern;\n\n        $this->log(\n            \"Set remote download to: \"\n            . ($this->allowRemote ? \"true\" : \"false\")\n            . \" using pattern \"\n            . $this->remotePattern\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the image resource is a remote file or not.\n     *\n     * @param string $src check if src is remote.\n     *\n     * @return boolean true if $src is a remote file, else false.\n     */\n    public function isRemoteSource($src)\n    {\n        $remote = preg_match($this->remotePattern, $src);\n        $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\"));\n        return !!$remote;\n    }\n\n\n\n    /**\n     * Set whitelist for valid hostnames from where remote source can be\n     * downloaded.\n     *\n     * @param array $whitelist with regexp hostnames to allow download from.\n     *\n     * @return $this\n     */\n    public function setRemoteHostWhitelist($whitelist = null)\n    {\n        $this->remoteHostWhitelist = $whitelist;\n        $this->log(\n            \"Setting remote host whitelist to: \"\n            . (is_null($whitelist) ? \"null\" : print_r($whitelist, 1))\n        );\n        return $this;\n    }\n\n\n\n    /**\n     * Check if the hostname for the remote image, is on a whitelist,\n     * if the whitelist is defined.\n     *\n     * @param string $src the remote source.\n     *\n     * @return boolean true if hostname on $src is in the whitelist, else false.\n     */\n    public function isRemoteSourceOnWhitelist($src)\n    {\n        if (is_null($this->remoteHostWhitelist)) {\n            $this->log(\"Remote host on whitelist not configured - allowing.\");\n            return true;\n        }\n\n        $whitelist = new CWhitelist();\n        $hostname = parse_url($src, PHP_URL_HOST);\n        $allow = $whitelist->check($hostname, $this->remoteHostWhitelist);\n\n        $this->log(\n            \"Remote host is on whitelist: \"\n            . ($allow ? \"true\" : \"false\")\n        );\n        return $allow;\n    }\n\n\n\n    /**\n     * Check if file extension is valid as a file extension.\n     *\n     * @param string $extension of image file.\n     *\n     * @return $this\n     */\n    private function checkFileExtension($extension)\n    {\n        $valid = array('jpg', 'jpeg', 'png', 'gif', 'webp');\n\n        in_array(strtolower($extension), $valid)\n            or $this->raiseError('Not a valid file extension.');\n\n        return $this;\n    }\n\n\n\n    /**\n     * Normalize the file extension.\n     *\n     * @param string $extension of image file or skip to use internal.\n     *\n     * @return string $extension as a normalized file extension.\n     */\n    private function normalizeFileExtension($extension = \"\")\n    {\n        $extension = strtolower($extension ? $extension : $this->extension ?? \"\");\n\n        if ($extension == 'jpeg') {\n                $extension = 'jpg';\n        }\n\n        return $extension;\n    }\n\n\n\n    /**\n     * Download a remote image and return path to its local copy.\n     *\n     * @param string $src remote path to image.\n     *\n     * @return string as path to downloaded remote source.\n     */\n    public function downloadRemoteSource($src)\n    {\n        if (!$this->isRemoteSourceOnWhitelist($src)) {\n            throw new Exception(\"Hostname is not on whitelist for remote sources.\");\n        }\n\n        $remote = new CRemoteImage();\n\n        if (!is_writable($this->remoteCache)) {\n            $this->log(\"The remote cache is not writable.\");\n        }\n\n        $remote->setCache($this->remoteCache);\n        $remote->useCache($this->useCache);\n        $src = $remote->download($src);\n\n        $this->log(\"Remote HTTP status: \" . $remote->getStatus());\n        $this->log(\"Remote item is in local cache: $src\");\n        $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true));\n\n        return $src;\n    }\n\n\n\n    /**\n     * Set source file to use as image source.\n     *\n     * @param string $src of image.\n     * @param string $dir as optional base directory where images are.\n     *\n     * @return $this\n     */\n    public function setSource($src, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->imageSrc = null;\n            $this->pathToImage = null;\n            return $this;\n        }\n\n        if ($this->allowRemote && $this->isRemoteSource($src)) {\n            $src = $this->downloadRemoteSource($src);\n            $dir = null;\n        }\n\n        if (!isset($dir)) {\n            $dir = dirname($src);\n            $src = basename($src);\n        }\n\n        $this->imageSrc     = ltrim($src, '/');\n        $imageFolder        = rtrim($dir, '/');\n        $this->pathToImage  = $imageFolder . '/' . $this->imageSrc;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set target file.\n     *\n     * @param string $src of target image.\n     * @param string $dir as optional base directory where images are stored.\n     *                    Uses $this->saveFolder if null.\n     *\n     * @return $this\n     */\n    public function setTarget($src = null, $dir = null)\n    {\n        if (!isset($src)) {\n            $this->cacheFileName = null;\n            return $this;\n        }\n\n        if (isset($dir)) {\n            $this->saveFolder = rtrim($dir, '/');\n        }\n\n        $this->cacheFileName  = $this->saveFolder . '/' . $src;\n\n        // Sanitize filename\n        $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName);\n        $this->log(\"The cache file name is: \" . $this->cacheFileName);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get filename of target file.\n     *\n     * @return Boolean|String as filename of target or false if not set.\n     */\n    public function getTarget()\n    {\n        return $this->cacheFileName;\n    }\n\n\n\n    /**\n     * Set options to use when processing image.\n     *\n     * @param array $args used when processing image.\n     *\n     * @return $this\n     */\n    public function setOptions($args)\n    {\n        $this->log(\"Set new options for processing image.\");\n\n        $defaults = array(\n            // Options for calculate dimensions\n            'newWidth'    => null,\n            'newHeight'   => null,\n            'aspectRatio' => null,\n            'keepRatio'   => true,\n            'cropToFit'   => false,\n            'fillToFit'   => null,\n            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),\n            'area'        => null, //'0,0,0,0',\n            'upscale'     => self::UPSCALE_DEFAULT,\n\n            // Options for caching or using original\n            'useCache'    => true,\n            'useOriginal' => true,\n\n            // Pre-processing, before resizing is done\n            'scale'        => null,\n            'rotateBefore' => null,\n            'autoRotate'  => false,\n\n            // General options\n            'bgColor'     => null,\n\n            // Post-processing, after resizing is done\n            'palette'     => null,\n            'filters'     => null,\n            'sharpen'     => null,\n            'emboss'      => null,\n            'blur'        => null,\n            'convolve'       => null,\n            'rotateAfter' => null,\n            'interlace' => null,\n\n            // Output format\n            'outputFormat' => null,\n            'dpr'          => 1,\n\n            // Postprocessing using external tools\n            'lossy' => null,\n        );\n\n        // Convert crop settings from string to array\n        if (isset($args['crop']) && !is_array($args['crop'])) {\n            $pices = explode(',', $args['crop']);\n            $args['crop'] = array(\n                'width'   => $pices[0],\n                'height'  => $pices[1],\n                'start_x' => $pices[2],\n                'start_y' => $pices[3],\n            );\n        }\n\n        // Convert area settings from string to array\n        if (isset($args['area']) && !is_array($args['area'])) {\n                $pices = explode(',', $args['area']);\n                $args['area'] = array(\n                    'top'    => $pices[0],\n                    'right'  => $pices[1],\n                    'bottom' => $pices[2],\n                    'left'   => $pices[3],\n                );\n        }\n\n        // Convert filter settings from array of string to array of array\n        if (isset($args['filters']) && is_array($args['filters'])) {\n            foreach ($args['filters'] as $key => $filterStr) {\n                $parts = explode(',', $filterStr);\n                $filter = $this->mapFilter($parts[0]);\n                $filter['str'] = $filterStr;\n                for ($i=1; $i<=$filter['argc']; $i++) {\n                    if (isset($parts[$i])) {\n                        $filter[\"arg{$i}\"] = $parts[$i];\n                    } else {\n                        throw new Exception(\n                            'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php'\n                        );\n                    }\n                }\n                $args['filters'][$key] = $filter;\n            }\n        }\n\n        // Merge default arguments with incoming and set properties.\n        //$args = array_merge_recursive($defaults, $args);\n        $args = array_merge($defaults, $args);\n        foreach ($defaults as $key => $val) {\n            $this->{$key} = $args[$key];\n        }\n\n        if ($this->bgColor) {\n            $this->setDefaultBackgroundColor($this->bgColor);\n        }\n\n        // Save original values to enable re-calculating\n        $this->newWidthOrig  = $this->newWidth;\n        $this->newHeightOrig = $this->newHeight;\n        $this->cropOrig      = $this->crop;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Map filter name to PHP filter and id.\n     *\n     * @param string $name the name of the filter.\n     *\n     * @return array with filter settings\n     * @throws Exception\n     */\n    private function mapFilter($name)\n    {\n        $map = array(\n            'negate'          => array('id'=>0,  'argc'=>0, 'type'=>IMG_FILTER_NEGATE),\n            'grayscale'       => array('id'=>1,  'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE),\n            'brightness'      => array('id'=>2,  'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS),\n            'contrast'        => array('id'=>3,  'argc'=>1, 'type'=>IMG_FILTER_CONTRAST),\n            'colorize'        => array('id'=>4,  'argc'=>4, 'type'=>IMG_FILTER_COLORIZE),\n            'edgedetect'      => array('id'=>5,  'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT),\n            'emboss'          => array('id'=>6,  'argc'=>0, 'type'=>IMG_FILTER_EMBOSS),\n            'gaussian_blur'   => array('id'=>7,  'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR),\n            'selective_blur'  => array('id'=>8,  'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR),\n            'mean_removal'    => array('id'=>9,  'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL),\n            'smooth'          => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH),\n            'pixelate'        => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE),\n        );\n\n        if (isset($map[$name])) {\n            return $map[$name];\n        } else {\n            throw new Exception('No such filter.');\n        }\n    }\n\n\n\n    /**\n     * Load image details from original image file.\n     *\n     * @param string $file the file to load or null to use $this->pathToImage.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function loadImageDetails($file = null)\n    {\n        $file = $file ? $file : $this->pathToImage;\n\n        // Special case to solve Windows 2 WSL integration\n        if (!defined('WINDOWS2WSL')) {\n            is_readable($file)\n                or $this->raiseError('Image file does not exist.');\n        }\n\n        $info = list($this->width, $this->height, $this->fileType) = getimagesize($file);\n        if (empty($info)) {\n            // To support webp\n            $this->fileType = false;\n            if (function_exists(\"exif_imagetype\")) {\n                $this->fileType = exif_imagetype($file);\n                if ($this->fileType === false) {\n                    if (function_exists(\"imagecreatefromwebp\")) {\n                        $webp = imagecreatefromwebp($file);\n                        if ($webp !== false) {\n                            $this->width  = imagesx($webp);\n                            $this->height = imagesy($webp);\n                            $this->fileType = IMG_WEBP;\n                        }\n                    }\n                }\n            }\n        }\n\n        if (!$this->fileType) {\n            throw new Exception(\"Loading image details, the file doesn't seem to be a valid image.\");\n        }\n\n        if ($this->verbose) {\n            $this->log(\"Loading image details for: {$file}\");\n            $this->log(\" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType}).\");\n            $this->log(\" Image filesize: \" . filesize($file) . \" bytes.\");\n            $this->log(\" Image mimetype: \" . $this->getMimeType());\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get mime type for image type.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    protected function getMimeType()\n    {\n        if ($this->fileType === IMG_WEBP) {\n            return \"image/webp\";\n        }\n\n        return image_type_to_mime_type($this->fileType);\n    }\n\n\n\n    /**\n     * Init new width and height and do some sanity checks on constraints, before any\n     * processing can be done.\n     *\n     * @return $this\n     * @throws Exception\n     */\n    public function initDimensions()\n    {\n        $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // width as %\n        if ($this->newWidth\n            && $this->newWidth[strlen($this->newWidth)-1] == '%') {\n            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;\n            $this->log(\"Setting new width based on % to {$this->newWidth}\");\n        }\n\n        // height as %\n        if ($this->newHeight\n            && $this->newHeight[strlen($this->newHeight)-1] == '%') {\n            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;\n            $this->log(\"Setting new height based on % to {$this->newHeight}\");\n        }\n\n        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');\n\n        // width & height from aspect ratio\n        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {\n            if ($this->aspectRatio >= 1) {\n                $this->newWidth   = $this->width;\n                $this->newHeight  = $this->width / $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n\n            } else {\n                $this->newHeight  = $this->height;\n                $this->newWidth   = $this->height * $this->aspectRatio;\n                $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\");\n            }\n\n        } elseif ($this->aspectRatio && is_null($this->newWidth)) {\n            $this->newWidth   = $this->newHeight * $this->aspectRatio;\n            $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\");\n\n        } elseif ($this->aspectRatio && is_null($this->newHeight)) {\n            $this->newHeight  = $this->newWidth / $this->aspectRatio;\n            $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\");\n        }\n\n        // Change width & height based on dpr\n        if ($this->dpr != 1) {\n            if (!is_null($this->newWidth)) {\n                $this->newWidth  = round($this->newWidth * $this->dpr);\n                $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\");\n            }\n            if (!is_null($this->newHeight)) {\n                $this->newHeight = round($this->newHeight * $this->dpr);\n                $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\");\n            }\n        }\n\n        // Check values to be within domain\n        is_null($this->newWidth)\n            or is_numeric($this->newWidth)\n            or $this->raiseError('Width not numeric');\n\n        is_null($this->newHeight)\n            or is_numeric($this->newHeight)\n            or $this->raiseError('Height not numeric');\n\n        $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Calculate new width and height of image, based on settings.\n     *\n     * @return $this\n     */\n    public function calculateNewWidthAndHeight()\n    {\n        // Crop, use cropped width and height as base for calulations\n        $this->log(\"Calculate new width and height.\");\n        $this->log(\"Original width x height is {$this->width} x {$this->height}.\");\n        $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\");\n\n        // Check if there is an area to crop off\n        if (isset($this->area)) {\n            $this->offset['top']    = round($this->area['top'] / 100 * $this->height);\n            $this->offset['right']  = round($this->area['right'] / 100 * $this->width);\n            $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height);\n            $this->offset['left']   = round($this->area['left'] / 100 * $this->width);\n            $this->offset['width']  = $this->width - $this->offset['left'] - $this->offset['right'];\n            $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom'];\n            $this->width  = $this->offset['width'];\n            $this->height = $this->offset['height'];\n            $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\");\n            $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\");\n        }\n\n        $width  = $this->width;\n        $height = $this->height;\n\n        // Check if crop is set\n        if ($this->crop) {\n            $width  = $this->crop['width']  = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];\n            $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];\n\n            if ($this->crop['start_x'] == 'left') {\n                $this->crop['start_x'] = 0;\n            } elseif ($this->crop['start_x'] == 'right') {\n                $this->crop['start_x'] = $this->width - $width;\n            } elseif ($this->crop['start_x'] == 'center') {\n                $this->crop['start_x'] = round($this->width / 2) - round($width / 2);\n            }\n\n            if ($this->crop['start_y'] == 'top') {\n                $this->crop['start_y'] = 0;\n            } elseif ($this->crop['start_y'] == 'bottom') {\n                $this->crop['start_y'] = $this->height - $height;\n            } elseif ($this->crop['start_y'] == 'center') {\n                $this->crop['start_y'] = round($this->height / 2) - round($height / 2);\n            }\n\n            $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\");\n        }\n\n        // Calculate new width and height if keeping aspect-ratio.\n        if ($this->keepRatio) {\n\n            $this->log(\"Keep aspect ratio.\");\n\n            // Crop-to-fit and both new width and height are set.\n            if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Use newWidth and newHeigh as width/height, image should fit in box.\n                $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\");\n\n            } elseif (isset($this->newWidth) && isset($this->newHeight)) {\n\n                // Both new width and height are set.\n                // Use newWidth and newHeigh as max width/height, image should not be larger.\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n                $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;\n                $this->newWidth  = round($width  / $ratio);\n                $this->newHeight = round($height / $ratio);\n                $this->log(\"New width and height was set.\");\n\n            } elseif (isset($this->newWidth)) {\n\n                // Use new width as max-width\n                $factor = (float)$this->newWidth / (float)$width;\n                $this->newHeight = round($factor * $height);\n                $this->log(\"New width was set.\");\n\n            } elseif (isset($this->newHeight)) {\n\n                // Use new height as max-hight\n                $factor = (float)$this->newHeight / (float)$height;\n                $this->newWidth = round($factor * $width);\n                $this->log(\"New height was set.\");\n\n            } else {\n\n                // Use existing width and height as new width and height.\n                $this->newWidth = $width;\n                $this->newHeight = $height;\n            }\n\n\n            // Get image dimensions for pre-resize image.\n            if ($this->cropToFit || $this->fillToFit) {\n\n                // Get relations of original & target image\n                $ratioWidth  = $width  / $this->newWidth;\n                $ratioHeight = $height / $this->newHeight;\n\n                if ($this->cropToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Crop to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;\n                    $this->cropWidth  = round($width  / $ratio);\n                    $this->cropHeight = round($height / $ratio);\n                    $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\");\n\n                } elseif ($this->fillToFit) {\n\n                    // Use newWidth and newHeigh as defined width/height,\n                    // image should fit the area.\n                    $this->log(\"Fill to fit.\");\n                    $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth;\n                    $this->fillWidth  = round($width  / $ratio);\n                    $this->fillHeight = round($height / $ratio);\n                    $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\");\n                }\n            }\n        }\n\n        // Crop, ensure to set new width and height\n        if ($this->crop) {\n            $this->log(\"Crop.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }\n\n        // Fill to fit, ensure to set new width and height\n        /*if ($this->fillToFit) {\n            $this->log(\"FillToFit.\");\n            $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']);\n            $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']);\n        }*/\n\n        // No new height or width is set, use existing measures.\n        $this->newWidth  = round(isset($this->newWidth) ? $this->newWidth : $this->width);\n        $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height);\n        $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Re-calculate image dimensions when original image dimension has changed.\n     *\n     * @return $this\n     */\n    public function reCalculateDimensions()\n    {\n        $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight);\n\n        $this->newWidth  = $this->newWidthOrig;\n        $this->newHeight = $this->newHeightOrig;\n        $this->crop      = $this->cropOrig;\n\n        $this->initDimensions()\n             ->calculateNewWidthAndHeight();\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set extension for filename to save as.\n     *\n     * @param string $saveas extension to save image as\n     *\n     * @return $this\n     */\n    public function setSaveAsExtension($saveAs = null)\n    {\n        if (isset($saveAs)) {\n            $saveAs = strtolower($saveAs);\n            $this->checkFileExtension($saveAs);\n            $this->saveAs = $saveAs;\n            $this->extension = $saveAs;\n        }\n\n        $this->log(\"Prepare to save image as: \" . $this->extension);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set JPEG quality to use when saving image\n     *\n     * @param int $quality as the quality to set.\n     *\n     * @return $this\n     */\n    public function setJpegQuality($quality = null)\n    {\n        if ($quality) {\n            $this->useQuality = true;\n        }\n\n        $this->quality = isset($quality)\n            ? $quality\n            : self::JPEG_QUALITY_DEFAULT;\n\n        (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting JPEG quality to {$this->quality}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set PNG compressen algorithm to use when saving image\n     *\n     * @param int $compress as the algorithm to use.\n     *\n     * @return $this\n     */\n    public function setPngCompression($compress = null)\n    {\n        if ($compress) {\n            $this->useCompress = true;\n        }\n\n        $this->compress = isset($compress)\n            ? $compress\n            : self::PNG_COMPRESSION_DEFAULT;\n\n        (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9)\n            or $this->raiseError('Quality not in range.');\n\n        $this->log(\"Setting PNG compression level to {$this->compress}.\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Use original image if possible, check options which affects image processing.\n     *\n     * @param boolean $useOrig default is to use original if possible, else set to false.\n     *\n     * @return $this\n     */\n    public function useOriginalIfPossible($useOrig = true)\n    {\n        if ($useOrig\n            && ($this->newWidth == $this->width)\n            && ($this->newHeight == $this->height)\n            && !$this->area\n            && !$this->crop\n            && !$this->cropToFit\n            && !$this->fillToFit\n            && !$this->filters\n            && !$this->sharpen\n            && !$this->emboss\n            && !$this->blur\n            && !$this->convolve\n            && !$this->palette\n            && !$this->useQuality\n            && !$this->useCompress\n            && !$this->saveAs\n            && !$this->rotateBefore\n            && !$this->rotateAfter\n            && !$this->autoRotate\n            && !$this->bgColor\n            && ($this->upscale === self::UPSCALE_DEFAULT)\n            && !$this->lossy\n        ) {\n            $this->log(\"Using original image.\");\n            $this->output($this->pathToImage);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Generate filename to save file in cache.\n     *\n     * @param string  $base      as optional basepath for storing file.\n     * @param boolean $useSubdir use or skip the subdir part when creating the\n     *                           filename.\n     * @param string  $prefix    to add as part of filename\n     *\n     * @return $this\n     */\n    public function generateFilename($base = null, $useSubdir = true, $prefix = null)\n    {\n        $filename     = basename($this->pathToImage);\n        $cropToFit    = $this->cropToFit    ? '_cf'                      : null;\n        $fillToFit    = $this->fillToFit    ? '_ff'                      : null;\n        $crop_x       = $this->crop_x       ? \"_x{$this->crop_x}\"        : null;\n        $crop_y       = $this->crop_y       ? \"_y{$this->crop_y}\"        : null;\n        $scale        = $this->scale        ? \"_s{$this->scale}\"         : null;\n        $bgColor      = $this->bgColor      ? \"_bgc{$this->bgColor}\"     : null;\n        $quality      = $this->quality      ? \"_q{$this->quality}\"       : null;\n        $compress     = $this->compress     ? \"_co{$this->compress}\"     : null;\n        $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null;\n        $rotateAfter  = $this->rotateAfter  ? \"_ra{$this->rotateAfter}\"  : null;\n        $lossy        = $this->lossy        ? \"_l\"                       : null;\n        $interlace    = $this->interlace    ? \"_i\"                       : null;\n\n        $saveAs = $this->normalizeFileExtension();\n        $saveAs = $saveAs ? \"_$saveAs\" : null;\n\n        $copyStrat = null;\n        if ($this->copyStrategy === self::RESIZE) {\n            $copyStrat = \"_rs\";\n        }\n\n        $width  = $this->newWidth  ? '_' . $this->newWidth  : null;\n        $height = $this->newHeight ? '_' . $this->newHeight : null;\n\n        $offset = isset($this->offset)\n            ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left']\n            : null;\n\n        $crop = $this->crop\n            ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y']\n            : null;\n\n        $filters = null;\n        if (isset($this->filters)) {\n            foreach ($this->filters as $filter) {\n                if (is_array($filter)) {\n                    $filters .= \"_f{$filter['id']}\";\n                    for ($i=1; $i<=$filter['argc']; $i++) {\n                        $filters .= \"-\".$filter[\"arg{$i}\"];\n                    }\n                }\n            }\n        }\n\n        $sharpen = $this->sharpen ? 's' : null;\n        $emboss  = $this->emboss  ? 'e' : null;\n        $blur    = $this->blur    ? 'b' : null;\n        $palette = $this->palette ? 'p' : null;\n\n        $autoRotate = $this->autoRotate ? 'ar' : null;\n\n        $optimize  = $this->jpegOptimize ? 'o' : null;\n        $optimize .= $this->pngFilter    ? 'f' : null;\n        $optimize .= $this->pngDeflate   ? 'd' : null;\n\n        $convolve = null;\n        if ($this->convolve) {\n            $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve);\n        }\n\n        $upscale = null;\n        if ($this->upscale !== self::UPSCALE_DEFAULT) {\n            $upscale = '_nu';\n        }\n\n        $subdir = null;\n        if ($useSubdir === true) {\n            $subdir = str_replace('/', '-', dirname($this->imageSrc));\n            $subdir = ($subdir == '.') ? '_.' : $subdir;\n            $subdir .= '_';\n        }\n\n        $file = $prefix . $subdir . $filename . $width . $height\n            . $offset . $crop . $cropToFit . $fillToFit\n            . $crop_x . $crop_y . $upscale\n            . $quality . $filters . $sharpen . $emboss . $blur . $palette\n            . $optimize . $compress\n            . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor\n            . $convolve . $copyStrat . $lossy . $interlace . $saveAs;\n\n        return $this->setTarget($file, $base);\n    }\n\n\n\n    /**\n     * Use cached version of image, if possible.\n     *\n     * @param boolean $useCache is default true, set to false to avoid using cached object.\n     *\n     * @return $this\n     */\n    public function useCacheIfPossible($useCache = true)\n    {\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime   = filemtime($this->pathToImage);\n            $cacheTime  = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                if ($this->useCache) {\n                    if ($this->verbose) {\n                        $this->log(\"Use cached file.\");\n                        $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $this->output($this->cacheFileName, $this->outputFormat);\n                } else {\n                    $this->log(\"Cache is valid but ignoring it by intention.\");\n                }\n            } else {\n                $this->log(\"Original file is modified, ignoring cache.\");\n            }\n        } else {\n            $this->log(\"Cachefile does not exists or ignoring it.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Load image from disk. Try to load image without verbose error message,\n     * if fail, load again and display error messages.\n     *\n     * @param string $src of image.\n     * @param string $dir as base directory where images are.\n     *\n     * @return $this\n     *\n     */\n    public function load($src = null, $dir = null)\n    {\n        if (isset($src)) {\n            $this->setSource($src, $dir);\n        }\n\n        $this->loadImageDetails();\n\n        if ($this->fileType === IMG_WEBP) {\n            $this->image = imagecreatefromwebp($this->pathToImage);\n        } else {\n            $imageAsString = file_get_contents($this->pathToImage);\n            $this->image = imagecreatefromstring($imageAsString);\n        }\n        if ($this->image === false) {\n            throw new Exception(\"Could not load image.\");\n        }\n\n        /* Removed v0.7.7\n        if (image_type_to_mime_type($this->fileType) == 'image/png') {\n            $type = $this->getPngType();\n            $hasFewColors = imagecolorstotal($this->image);\n\n            if ($type == self::PNG_RGB_PALETTE || ($hasFewColors > 0 && $hasFewColors <= 256)) {\n                if ($this->verbose) {\n                    $this->log(\"Handle this image as a palette image.\");\n                }\n                $this->palette = true;\n            }\n        }\n        */\n\n        if ($this->verbose) {\n            $this->log(\"### Image successfully loaded from file.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->colorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index >= 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the type of PNG image.\n     *\n     * @param string $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    public function getPngType($filename = null)\n    {\n        $filename = $filename ? $filename : $this->pathToImage;\n\n        $pngType = ord(file_get_contents($filename, false, null, 25, 1));\n\n        if ($this->verbose) {\n            $this->log(\"Checking png type of: \" . $filename);\n            $this->log($this->getPngTypeAsString($pngType));\n        }\n\n        return $pngType;\n    }\n\n\n\n    /**\n     * Get the type of PNG image as a verbose string.\n     *\n     * @param integer $type     to use, default is to check the type.\n     * @param string  $filename to use instead of default.\n     *\n     * @return int as the type of the png-image\n     *\n     */\n    private function getPngTypeAsString($pngType = null, $filename = null)\n    {\n        if ($filename || !$pngType) {\n            $pngType = $this->getPngType($filename);\n        }\n\n        $index = imagecolortransparent($this->image);\n        $transparent = null;\n        if ($index != -1) {\n            $transparent = \" (transparent)\";\n        }\n\n        switch ($pngType) {\n\n            case self::PNG_GREYSCALE:\n                $text = \"PNG is type 0, Greyscale$transparent\";\n                break;\n\n            case self::PNG_RGB:\n                $text = \"PNG is type 2, RGB$transparent\";\n                break;\n\n            case self::PNG_RGB_PALETTE:\n                $text = \"PNG is type 3, RGB with palette$transparent\";\n                break;\n\n            case self::PNG_GREYSCALE_ALPHA:\n                $text = \"PNG is type 4, Greyscale with alpha channel\";\n                break;\n\n            case self::PNG_RGB_ALPHA:\n                $text = \"PNG is type 6, RGB with alpha channel (PNG 32-bit)\";\n                break;\n\n            default:\n                $text = \"PNG is UNKNOWN type, is it really a PNG image?\";\n        }\n\n        return $text;\n    }\n\n\n\n\n    /**\n     * Calculate number of colors in an image.\n     *\n     * @param resource $im the image.\n     *\n     * @return int\n     */\n    private function colorsTotal($im)\n    {\n        if (imageistruecolor($im)) {\n            $this->log(\"Colors as true color.\");\n            $h = imagesy($im);\n            $w = imagesx($im);\n            $c = array();\n            for ($x=0; $x < $w; $x++) {\n                for ($y=0; $y < $h; $y++) {\n                    @$c['c'.imagecolorat($im, $x, $y)]++;\n                }\n            }\n            return count($c);\n        } else {\n            $this->log(\"Colors as palette.\");\n            return imagecolorstotal($im);\n        }\n    }\n\n\n\n    /**\n     * Preprocess image before rezising it.\n     *\n     * @return $this\n     */\n    public function preResize()\n    {\n        $this->log(\"### Pre-process before resizing\");\n\n        // Rotate image\n        if ($this->rotateBefore) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateBefore, $this->bgColor)\n                 ->reCalculateDimensions();\n        }\n\n        // Auto-rotate image\n        if ($this->autoRotate) {\n            $this->log(\"Auto rotating image.\");\n            $this->rotateExif()\n                 ->reCalculateDimensions();\n        }\n\n        // Scale the original image before starting\n        if (isset($this->scale)) {\n            $this->log(\"Scale by {$this->scale}%\");\n            $newWidth  = $this->width * $this->scale / 100;\n            $newHeight = $this->height * $this->scale / 100;\n            $img = $this->CreateImageKeepTransparency($newWidth, $newHeight);\n            imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);\n            $this->image = $img;\n            $this->width = $newWidth;\n            $this->height = $newHeight;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Resize or resample the image while resizing.\n     *\n     * @param int $strategy as CImage::RESIZE or CImage::RESAMPLE\n     *\n     * @return $this\n     */\n     public function setCopyResizeStrategy($strategy)\n     {\n         $this->copyStrategy = $strategy;\n         return $this;\n     }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return void\n     */\n    public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)\n    {\n        if($this->copyStrategy == self::RESIZE) {\n            $this->log(\"Copy by resize\");\n            imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        } else {\n            $this->log(\"Copy by resample\");\n            imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n        }\n    }\n\n\n\n    /**\n     * Resize and or crop the image.\n     *\n     * @return $this\n     */\n    public function resize()\n    {\n\n        $this->log(\"### Starting to Resize()\");\n        $this->log(\"Upscale = '$this->upscale'\");\n\n        // Only use a specified area of the image, $this->offset is defining the area to use\n        if (isset($this->offset)) {\n\n            $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\");\n            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);\n            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);\n            $this->image = $img;\n            $this->width = $this->offset['width'];\n            $this->height = $this->offset['height'];\n        }\n\n        if ($this->crop) {\n\n            // Do as crop, take only part of image\n            $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\");\n            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);\n            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);\n            $this->image = $img;\n            $this->width = $this->crop['width'];\n            $this->height = $this->crop['height'];\n        }\n\n        if (!$this->upscale) {\n            // Consider rewriting the no-upscale code to fit within this if-statement,\n            // likely to be more readable code.\n            // The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch\n        }\n\n        if ($this->cropToFit) {\n\n            // Resize by crop to fit\n            $this->log(\"Resizing using strategy - Crop to fit\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                $posX = 0;\n                $posY = 0;\n                $cropX = 0;\n                $cropY = 0;\n\n                if ($this->newWidth > $this->width) {\n                    $posX = round(($this->newWidth - $this->width) / 2);\n                }\n                if ($this->newWidth < $this->width) {\n                    $cropX = round(($this->width/2) - ($this->newWidth/2));\n                }\n\n                if ($this->newHeight > $this->height) {\n                    $posY = round(($this->newHeight - $this->height) / 2);\n                }\n                if ($this->newHeight < $this->height) {\n                    $cropY = round(($this->height/2) - ($this->newHeight/2));\n                }\n                $this->log(\" cwidth: $this->cropWidth\");\n                $this->log(\" cheight: $this->cropHeight\");\n                $this->log(\" nwidth: $this->newWidth\");\n                $this->log(\" nheight: $this->newHeight\");\n                $this->log(\" width: $this->width\");\n                $this->log(\" height: $this->height\");\n                $this->log(\" posX: $posX\");\n                $this->log(\" posY: $posY\");\n                $this->log(\" cropX: $cropX\");\n                $this->log(\" cropY: $cropY\");\n\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);\n            } else {\n                $cropX = round(($this->cropWidth/2) - ($this->newWidth/2));\n                $cropY = round(($this->cropHeight/2) - ($this->newHeight/2));\n                $imgPreCrop   = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif ($this->fillToFit) {\n\n            // Resize by fill to fit\n            $this->log(\"Resizing using strategy - Fill to fit\");\n\n            $posX = 0;\n            $posY = 0;\n\n            $ratioOrig = $this->width / $this->height;\n            $ratioNew  = $this->newWidth / $this->newHeight;\n\n            // Check ratio for landscape or portrait\n            if ($ratioOrig < $ratioNew) {\n                $posX = round(($this->newWidth - $this->fillWidth) / 2);\n            } else {\n                $posY = round(($this->newHeight - $this->fillHeight) / 2);\n            }\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth && $this->height < $this->newHeight)\n            ) {\n\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n                $posX = round(($this->newWidth - $this->width) / 2);\n                $posY = round(($this->newHeight - $this->height) / 2);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);\n\n            } else {\n                $imgPreFill   = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);\n                imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight);\n            }\n\n            $this->image = $imageResized;\n            $this->width = $this->newWidth;\n            $this->height = $this->newHeight;\n\n        } elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {\n\n            // Resize it\n            $this->log(\"Resizing, new height and/or width\");\n\n            if (!$this->upscale\n                && ($this->width < $this->newWidth || $this->height < $this->newHeight)\n            ) {\n                $this->log(\"Resizing - smaller image, do not upscale.\");\n\n                if (!$this->keepRatio) {\n                    $this->log(\"Resizing - stretch to fit selected.\");\n\n                    $posX = 0;\n                    $posY = 0;\n                    $cropX = 0;\n                    $cropY = 0;\n\n                    if ($this->newWidth > $this->width && $this->newHeight > $this->height) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                    } elseif ($this->newWidth > $this->width) {\n                        $posX = round(($this->newWidth - $this->width) / 2);\n                        $cropY = round(($this->height - $this->newHeight) / 2);\n                    } elseif ($this->newHeight > $this->height) {\n                        $posY = round(($this->newHeight - $this->height) / 2);\n                        $cropX = round(($this->width - $this->newWidth) / 2);\n                    }\n\n                    $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                    imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);\n                    $this->image = $imageResized;\n                    $this->width = $this->newWidth;\n                    $this->height = $this->newHeight;\n                }\n            } else {\n                $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);\n                $this->imageCopyResampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);\n                $this->image = $imageResized;\n                $this->width = $this->newWidth;\n                $this->height = $this->newHeight;\n            }\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Postprocess image after rezising image.\n     *\n     * @return $this\n     */\n    public function postResize()\n    {\n        $this->log(\"### Post-process after resizing\");\n\n        // Rotate image\n        if ($this->rotateAfter) {\n            $this->log(\"Rotating image.\");\n            $this->rotate($this->rotateAfter, $this->bgColor);\n        }\n\n        // Apply filters\n        if (isset($this->filters) && is_array($this->filters)) {\n\n            foreach ($this->filters as $filter) {\n                $this->log(\"Applying filter {$filter['type']}.\");\n\n                switch ($filter['argc']) {\n\n                    case 0:\n                        imagefilter($this->image, $filter['type']);\n                        break;\n\n                    case 1:\n                        imagefilter($this->image, $filter['type'], $filter['arg1']);\n                        break;\n\n                    case 2:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']);\n                        break;\n\n                    case 3:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']);\n                        break;\n\n                    case 4:\n                        imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']);\n                        break;\n                }\n            }\n        }\n\n        // Convert to palette image\n        if ($this->palette) {\n            $this->log(\"Converting to palette image.\");\n            $this->trueColorToPalette();\n        }\n\n        // Blur the image\n        if ($this->blur) {\n            $this->log(\"Blur.\");\n            $this->blurImage();\n        }\n\n        // Emboss the image\n        if ($this->emboss) {\n            $this->log(\"Emboss.\");\n            $this->embossImage();\n        }\n\n        // Sharpen the image\n        if ($this->sharpen) {\n            $this->log(\"Sharpen.\");\n            $this->sharpenImage();\n        }\n\n        // Custom convolution\n        if ($this->convolve) {\n            //$this->log(\"Convolve: \" . $this->convolve);\n            $this->imageConvolution();\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using angle.\n     *\n     * @param float $angle        to rotate image.\n     * @param int   $anglebgColor to fill image with if needed.\n     *\n     * @return $this\n     */\n    public function rotate($angle, $bgColor)\n    {\n        $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\");\n\n        $color = $this->getBackgroundColor();\n        $this->image = imagerotate($this->image, $angle, $color);\n\n        $this->width  = imagesx($this->image);\n        $this->height = imagesy($this->image);\n\n        $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height);\n\n        return $this;\n    }\n\n\n\n    /**\n     * Rotate image using information in EXIF.\n     *\n     * @return $this\n     */\n    public function rotateExif()\n    {\n        if (!in_array($this->fileType, array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) {\n            $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\");\n            return $this;\n        }\n\n        $exif = exif_read_data($this->pathToImage);\n\n        if (!empty($exif['Orientation'])) {\n            switch ($exif['Orientation']) {\n                case 3:\n                    $this->log(\"Autorotate 180.\");\n                    $this->rotate(180, $this->bgColor);\n                    break;\n\n                case 6:\n                    $this->log(\"Autorotate -90.\");\n                    $this->rotate(-90, $this->bgColor);\n                    break;\n\n                case 8:\n                    $this->log(\"Autorotate 90.\");\n                    $this->rotate(90, $this->bgColor);\n                    break;\n\n                default:\n                    $this->log(\"Autorotate ignored, unknown value as orientation.\");\n            }\n        } else {\n            $this->log(\"Autorotate ignored, no orientation in EXIF.\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert true color image to palette image, keeping alpha.\n     * http://stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library\n     *\n     * @return void\n     */\n    public function trueColorToPalette()\n    {\n        $img = imagecreatetruecolor($this->width, $this->height);\n        $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);\n        imagecolortransparent($img, $bga);\n        imagefill($img, 0, 0, $bga);\n        imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);\n        imagetruecolortopalette($img, false, 255);\n        imagesavealpha($img, true);\n\n        if (imageistruecolor($this->image)) {\n            $this->log(\"Matching colors with true color image.\");\n            imagecolormatch($this->image, $img);\n        }\n\n        $this->image = $img;\n    }\n\n\n\n    /**\n     * Sharpen image using image convolution.\n     *\n     * @return $this\n     */\n    public function sharpenImage()\n    {\n        $this->imageConvolution('sharpen');\n        return $this;\n    }\n\n\n\n    /**\n     * Emboss image using image convolution.\n     *\n     * @return $this\n     */\n    public function embossImage()\n    {\n        $this->imageConvolution('emboss');\n        return $this;\n    }\n\n\n\n    /**\n     * Blur image using image convolution.\n     *\n     * @return $this\n     */\n    public function blurImage()\n    {\n        $this->imageConvolution('blur');\n        return $this;\n    }\n\n\n\n    /**\n     * Create convolve expression and return arguments for image convolution.\n     *\n     * @param string $expression constant string which evaluates to a list of\n     *                           11 numbers separated by komma or such a list.\n     *\n     * @return array as $matrix (3x3), $divisor and $offset\n     */\n    public function createConvolveArguments($expression)\n    {\n        // Check of matching constant\n        if (isset($this->convolves[$expression])) {\n            $expression = $this->convolves[$expression];\n        }\n\n        $part = explode(',', $expression);\n        $this->log(\"Creating convolution expressen: $expression\");\n\n        // Expect list of 11 numbers, split by , and build up arguments\n        if (count($part) != 11) {\n            throw new Exception(\n                \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\"\n            );\n        }\n\n        array_walk($part, function ($item, $key) {\n            if (!is_numeric($item)) {\n                throw new Exception(\"Argument to convolve expression should be float but is not.\");\n            }\n        });\n\n        return array(\n            array(\n                array($part[0], $part[1], $part[2]),\n                array($part[3], $part[4], $part[5]),\n                array($part[6], $part[7], $part[8]),\n            ),\n            $part[9],\n            $part[10],\n        );\n    }\n\n\n\n    /**\n     * Add custom expressions (or overwrite existing) for image convolution.\n     *\n     * @param array $options Key value array with strings to be converted\n     *                       to convolution expressions.\n     *\n     * @return $this\n     */\n    public function addConvolveExpressions($options)\n    {\n        $this->convolves = array_merge($this->convolves, $options);\n        return $this;\n    }\n\n\n\n    /**\n     * Image convolution.\n     *\n     * @param string $options A string with 11 float separated by comma.\n     *\n     * @return $this\n     */\n    public function imageConvolution($options = null)\n    {\n        // Use incoming options or use $this.\n        $options = $options ? $options : $this->convolve;\n\n        // Treat incoming as string, split by +\n        $this->log(\"Convolution with '$options'\");\n        $options = explode(\":\", $options);\n\n        // Check each option if it matches constant value\n        foreach ($options as $option) {\n            list($matrix, $divisor, $offset) = $this->createConvolveArguments($option);\n            imageconvolution($this->image, $matrix, $divisor, $offset);\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set default background color between 000000-FFFFFF or if using\n     * alpha 00000000-FFFFFF7F.\n     *\n     * @param string $color as hex value.\n     *\n     * @return $this\n    */\n    public function setDefaultBackgroundColor($color)\n    {\n        $this->log(\"Setting default background color to '$color'.\");\n\n        if (!(strlen($color) == 6 || strlen($color) == 8)) {\n            throw new Exception(\n                \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $red    = hexdec(substr($color, 0, 2));\n        $green  = hexdec(substr($color, 2, 2));\n        $blue   = hexdec(substr($color, 4, 2));\n\n        $alpha = (strlen($color) == 8)\n            ? hexdec(substr($color, 6, 2))\n            : null;\n\n        if (($red < 0 || $red > 255)\n            || ($green < 0 || $green > 255)\n            || ($blue < 0 || $blue > 255)\n            || ($alpha < 0 || $alpha > 127)\n        ) {\n            throw new Exception(\n                \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\"\n            );\n        }\n\n        $this->bgColor = strtolower($color);\n        $this->bgColorDefault = array(\n            'red'   => $red,\n            'green' => $green,\n            'blue'  => $blue,\n            'alpha' => $alpha\n        );\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the background color.\n     *\n     * @param resource $img the image to work with or null if using $this->image.\n     *\n     * @return color value or null if no background color is set.\n    */\n    private function getBackgroundColor($img = null)\n    {\n        $img = isset($img) ? $img : $this->image;\n\n        if ($this->bgColorDefault) {\n\n            $red   = $this->bgColorDefault['red'];\n            $green = $this->bgColorDefault['green'];\n            $blue  = $this->bgColorDefault['blue'];\n            $alpha = $this->bgColorDefault['alpha'];\n\n            if ($alpha) {\n                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);\n            } else {\n                $color = imagecolorallocate($img, $red, $green, $blue);\n            }\n\n            return $color;\n\n        } else {\n            return 0;\n        }\n    }\n\n\n\n    /**\n     * Create a image and keep transparency for png and gifs.\n     *\n     * @param int $width of the new image.\n     * @param int $height of the new image.\n     *\n     * @return image resource.\n    */\n    private function createImageKeepTransparency($width, $height)\n    {\n        $this->log(\"Creating a new working image width={$width}px, height={$height}px.\");\n        $img = imagecreatetruecolor($width, $height);\n        imagealphablending($img, false);\n        imagesavealpha($img, true);\n\n        $index = $this->image\n            ? imagecolortransparent($this->image)\n            : -1;\n\n        if ($index != -1) {\n\n            imagealphablending($img, true);\n            $transparent = imagecolorsforindex($this->image, $index);\n            $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']);\n            imagefill($img, 0, 0, $color);\n            $index = imagecolortransparent($img, $color);\n            $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\");\n\n        } elseif ($this->bgColorDefault) {\n\n            $color = $this->getBackgroundColor($img);\n            imagefill($img, 0, 0, $color);\n            $this->Log(\"Filling image with background color.\");\n        }\n\n        return $img;\n    }\n\n\n\n    /**\n     * Set optimizing  and post-processing options.\n     *\n     * @param array $options with config for postprocessing with external tools.\n     *\n     * @return $this\n     */\n    public function setPostProcessingOptions($options)\n    {\n        if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) {\n            $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd'];\n        } else {\n            $this->jpegOptimizeCmd = null;\n        }\n\n        if (array_key_exists(\"png_lossy\", $options)\n            && $options['png_lossy'] !== false) {\n            $this->pngLossy = $options['png_lossy'];\n            $this->pngLossyCmd = $options['png_lossy_cmd'];\n        } else {\n            $this->pngLossyCmd = null;\n        }\n\n        if (isset($options['png_filter']) && $options['png_filter']) {\n            $this->pngFilterCmd = $options['png_filter_cmd'];\n        } else {\n            $this->pngFilterCmd = null;\n        }\n\n        if (isset($options['png_deflate']) && $options['png_deflate']) {\n            $this->pngDeflateCmd = $options['png_deflate_cmd'];\n        } else {\n            $this->pngDeflateCmd = null;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Find out the type (file extension) for the image to be saved.\n     *\n     * @return string as image extension.\n     */\n    protected function getTargetImageExtension()\n    {\n        // switch on mimetype\n        if (isset($this->extension)) {\n            return strtolower($this->extension);\n        } elseif ($this->fileType === IMG_WEBP) {\n            return \"webp\";\n        }\n\n        return substr(image_type_to_extension($this->fileType), 1);\n    }\n\n\n\n    /**\n     * Save image.\n     *\n     * @param string  $src       as target filename.\n     * @param string  $base      as base directory where to store images.\n     * @param boolean $overwrite or not, default to always overwrite file.\n     *\n     * @return $this or false if no folder is set.\n     */\n    public function save($src = null, $base = null, $overwrite = true)\n    {\n        if (isset($src)) {\n            $this->setTarget($src, $base);\n        }\n\n        if ($overwrite === false && is_file($this->cacheFileName)) {\n            $this->Log(\"Not overwriting file since its already exists and \\$overwrite if false.\");\n            return;\n        }\n\n        if (!defined(\"WINDOWS2WSL\")) {\n            is_writable($this->saveFolder)\n            or $this->raiseError('Target directory is not writable.');\n        }\n\n        $type = $this->getTargetImageExtension();\n        $this->Log(\"Saving image as \" . $type);\n        switch($type) {\n\n            case 'jpeg':\n            case 'jpg':\n                // Set as interlaced progressive JPEG\n                if ($this->interlace) {\n                    $this->Log(\"Set JPEG image to be interlaced.\");\n                    $res = imageinterlace($this->image, true);\n                }\n\n                $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\");\n                imagejpeg($this->image, $this->cacheFileName, $this->quality);\n\n                // Use JPEG optimize if defined\n                if ($this->jpegOptimizeCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->log($cmd);\n                    $this->log($res);\n                }\n                break;\n\n            case 'gif':\n                $this->Log(\"Saving image as GIF to cache.\");\n                imagegif($this->image, $this->cacheFileName);\n                break;\n\n            case 'webp':\n                $this->Log(\"Saving image as WEBP to cache using quality = {$this->quality}.\");\n                imagewebp($this->image, $this->cacheFileName, $this->quality);\n                break;\n\n            case 'png':\n            default:\n                $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\");\n\n                // Turn off alpha blending and set alpha flag\n                imagealphablending($this->image, false);\n                imagesavealpha($this->image, true);\n                imagepng($this->image, $this->cacheFileName, $this->compress);\n\n                // Use external program to process lossy PNG, if defined\n                $lossyEnabled = $this->pngLossy === true;\n                $lossySoftEnabled = $this->pngLossy === null;\n                $lossyActiveEnabled = $this->lossy === true;\n                if ($lossyEnabled || ($lossySoftEnabled && $lossyActiveEnabled)) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->log(\"Lossy enabled: $lossyEnabled\");\n                        $this->log(\"Lossy soft enabled: $lossySoftEnabled\");\n                        $this->Log(\"Filesize before lossy optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngLossyCmd . \" $this->cacheFileName $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to filter PNG, if defined\n                if ($this->pngFilterCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngFilterCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n\n                // Use external program to deflate PNG, if defined\n                if ($this->pngDeflateCmd) {\n                    if ($this->verbose) {\n                        clearstatcache();\n                        $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\");\n                    }\n                    $res = array();\n                    $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\";\n                    exec($cmd, $res);\n                    $this->Log($cmd);\n                    $this->Log($res);\n                }\n                break;\n        }\n\n        if ($this->verbose) {\n            clearstatcache();\n            $this->log(\"Saved image to cache.\");\n            $this->log(\" Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\");\n            $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false'));\n            $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image));\n            $this->log(\" Number of colors in image = \" . $this->ColorsTotal($this->image));\n            $index = imagecolortransparent($this->image);\n            $this->log(\" Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Convert image from one colorpsace/color profile to sRGB without\n     * color profile.\n     *\n     * @param string  $src      of image.\n     * @param string  $dir      as base directory where images are.\n     * @param string  $cache    as base directory where to store images.\n     * @param string  $iccFile  filename of colorprofile.\n     * @param boolean $useCache or not, default to always use cache.\n     *\n     * @return string | boolean false if no conversion else the converted\n     *                          filename.\n     */\n    public function convert2sRGBColorSpace($src, $dir, $cache, $iccFile, $useCache = true)\n    {\n        if ($this->verbose) {\n            $this->log(\"# Converting image to sRGB colorspace.\");\n        }\n\n        if (!class_exists(\"Imagick\")) {\n            $this->log(\" Ignoring since Imagemagick is not installed.\");\n            return false;\n        }\n\n        // Prepare\n        $this->setSaveFolder($cache)\n             ->setSource($src, $dir)\n             ->generateFilename(null, false, 'srgb_');\n\n        // Check if the cached version is accurate.\n        if ($useCache && is_readable($this->cacheFileName)) {\n            $fileTime  = filemtime($this->pathToImage);\n            $cacheTime = filemtime($this->cacheFileName);\n\n            if ($fileTime <= $cacheTime) {\n                $this->log(\" Using cached version: \" . $this->cacheFileName);\n                return $this->cacheFileName;\n            }\n        }\n\n        // Only covert if cachedir is writable\n        if (is_writable($this->saveFolder)) {\n            // Load file and check if conversion is needed\n            $image      = new Imagick($this->pathToImage);\n            $colorspace = $image->getImageColorspace();\n            $this->log(\" Current colorspace: \" . $colorspace);\n\n            $profiles      = $image->getImageProfiles('*', false);\n            $hasICCProfile = (array_search('icc', $profiles) !== false);\n            $this->log(\" Has ICC color profile: \" . ($hasICCProfile ? \"YES\" : \"NO\"));\n\n            if ($colorspace != Imagick::COLORSPACE_SRGB || $hasICCProfile) {\n                $this->log(\" Converting to sRGB.\");\n\n                $sRGBicc = file_get_contents($iccFile);\n                $image->profileImage('icc', $sRGBicc);\n\n                $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);\n                $image->writeImage($this->cacheFileName);\n                return $this->cacheFileName;\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Create a hard link, as an alias, to the cached file.\n     *\n     * @param string $alias where to store the link,\n     *                      filename without extension.\n     *\n     * @return $this\n     */\n    public function linkToCacheFile($alias)\n    {\n        if ($alias === null) {\n            $this->log(\"Ignore creating alias.\");\n            return $this;\n        }\n\n        if (is_readable($alias)) {\n            unlink($alias);\n        }\n\n        $res = link($this->cacheFileName, $alias);\n\n        if ($res) {\n            $this->log(\"Created an alias as: $alias\");\n        } else {\n            $this->log(\"Failed to create the alias: $alias\");\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Add HTTP header for output together with image.\n     *\n     * @param string $type  the header type such as \"Cache-Control\"\n     * @param string $value the value to use\n     *\n     * @return void\n     */\n    public function addHTTPHeader($type, $value)\n    {\n        $this->HTTPHeader[$type] = $value;\n    }\n\n\n\n    /**\n     * Output image to browser using caching.\n     *\n     * @param string $file   to read and output, default is to\n     *                       use $this->cacheFileName\n     * @param string $format set to json to output file as json\n     *                       object with details\n     *\n     * @return void\n     */\n    public function output($file = null, $format = null)\n    {\n        if (is_null($file)) {\n            $file = $this->cacheFileName;\n        }\n\n        if (is_null($format)) {\n            $format = $this->outputFormat;\n        }\n\n        $this->log(\"### Output\");\n        $this->log(\"Output format is: $format\");\n\n        if (!$this->verbose && $format == 'json') {\n            header('Content-type: application/json');\n            echo $this->json($file);\n            exit;\n        } elseif ($format == 'ascii') {\n            header('Content-type: text/plain');\n            echo $this->ascii($file);\n            exit;\n        }\n\n        $this->log(\"Outputting image: $file\");\n\n        // Get image modification time\n        clearstatcache();\n        $lastModified = filemtime($file);\n        $lastModifiedFormat = \"D, d M Y H:i:s\";\n        $gmdate = gmdate($lastModifiedFormat, $lastModified);\n\n        if (!$this->verbose) {\n            $header = \"Last-Modified: $gmdate GMT\";\n            header($header);\n            $this->fastTrackCache->addHeader($header);\n            $this->fastTrackCache->setLastModified($lastModified);\n        }\n\n        foreach ($this->HTTPHeader as $key => $val) {\n            $header = \"$key: $val\";\n            header($header);\n            $this->fastTrackCache->addHeader($header);\n        }\n\n        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])\n            && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {\n\n            if ($this->verbose) {\n                $this->log(\"304 not modified\");\n                $this->verboseOutput();\n                exit;\n            }\n\n            header(\"HTTP/1.0 304 Not Modified\");\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 304\");\n            }\n\n        } else {\n\n            $this->loadImageDetails($file);\n            $mime = $this->getMimeType();\n            $size = filesize($file);\n\n            if ($this->verbose) {\n                $this->log(\"Last-Modified: \" . $gmdate . \" GMT\");\n                $this->log(\"Content-type: \" . $mime);\n                $this->log(\"Content-length: \" . $size);\n                $this->verboseOutput();\n\n                if (is_null($this->verboseFileName)) {\n                    exit;\n                }\n            }\n\n            $header = \"Content-type: $mime\";\n            header($header);\n            $this->fastTrackCache->addHeaderOnOutput($header);\n\n            $header = \"Content-length: $size\";\n            header($header);\n            $this->fastTrackCache->addHeaderOnOutput($header);\n\n            $this->fastTrackCache->setSource($file);\n            $this->fastTrackCache->writeToCache();\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 200\");\n            }\n            readfile($file);\n        }\n\n        exit;\n    }\n\n\n\n    /**\n     * Create a JSON object from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string json-encoded representation of the image.\n     */\n    public function json($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $details = array();\n\n        clearstatcache();\n\n        $details['src']       = $this->imageSrc;\n        $lastModified         = filemtime($this->pathToImage);\n        $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $details['cache']       = basename($this->cacheFileName ?? \"\");\n        $lastModified           = filemtime($this->cacheFileName ?? \"\");\n        $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified);\n\n        $this->load($file);\n\n        $details['filename']    = basename($file ?? \"\");\n        $details['mimeType']    = $this->getMimeType($this->fileType);\n        $details['width']       = $this->width;\n        $details['height']      = $this->height;\n        $details['aspectRatio'] = round($this->width / $this->height, 3);\n        $details['size']        = filesize($file ?? \"\");\n        $details['colors'] = $this->colorsTotal($this->image);\n        $details['includedFiles'] = count(get_included_files());\n        $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . \" MB\" ;\n        $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . \" MB\";\n        $details['memoryLimit'] = ini_get('memory_limit');\n\n        if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {\n            $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . \"s\";\n        }\n\n        if ($details['mimeType'] == 'image/png') {\n            $details['pngType'] = $this->getPngTypeAsString(null, $file);\n        }\n\n        $options = null;\n        if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) {\n            $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;\n        }\n\n        return json_encode($details, $options);\n    }\n\n\n\n    /**\n     * Set options for creating ascii version of image.\n     *\n     * @param array $options empty to use default or set options to change.\n     *\n     * @return void.\n     */\n    public function setAsciiOptions($options = array())\n    {\n        $this->asciiOptions = $options;\n    }\n\n\n\n    /**\n     * Create an ASCII version from the image details.\n     *\n     * @param string $file the file to output.\n     *\n     * @return string ASCII representation of the image.\n     */\n    public function ascii($file = null)\n    {\n        $file = $file ? $file : $this->cacheFileName;\n\n        $asciiArt = new CAsciiArt();\n        $asciiArt->setOptions($this->asciiOptions);\n        return $asciiArt->createFromFile($file);\n    }\n\n\n\n    /**\n     * Log an event if verbose mode.\n     *\n     * @param string $message to log.\n     *\n     * @return this\n     */\n    public function log($message)\n    {\n        if ($this->verbose) {\n            $this->log[] = $message;\n        }\n\n        return $this;\n    }\n\n\n\n    /**\n     * Do verbose output to a file.\n     *\n     * @param string $fileName where to write the verbose output.\n     *\n     * @return void\n     */\n    public function setVerboseToFile($fileName)\n    {\n        $this->log(\"Setting verbose output to file.\");\n        $this->verboseFileName = $fileName;\n    }\n\n\n\n    /**\n     * Do verbose output and print out the log and the actual images.\n     *\n     * @return void\n     */\n    private function verboseOutput()\n    {\n        $log = null;\n        $this->log(\"### Summary of verbose log\");\n        $this->log(\"As JSON: \\n\" . $this->json());\n        $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\");\n        $this->log(\"Memory limit: \" . ini_get('memory_limit'));\n\n        $included = get_included_files();\n        $this->log(\"Included files: \" . count($included));\n\n        foreach ($this->log as $val) {\n            if (is_array($val)) {\n                foreach ($val as $val1) {\n                    $log .= htmlentities($val1) . '<br/>';\n                }\n            } else {\n                $log .= htmlentities($val) . '<br/>';\n            }\n        }\n\n        if (!is_null($this->verboseFileName)) {\n            file_put_contents(\n                $this->verboseFileName,\n                str_replace(\"<br/>\", \"\\n\", $log)\n            );\n        } else {\n            echo <<<EOD\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n        }\n    }\n\n\n\n    /**\n     * Raise error, enables to implement a selection of error methods.\n     *\n     * @param string $message the error message to display.\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function raiseError($message)\n    {\n        throw new Exception($message);\n    }\n}\n\n\n\n/**\n * Deal with the cache directory and cached items.\n *\n */\nclass CCache\n{\n    /**\n     * Path to the cache directory.\n     */\n    private $path;\n\n\n\n    /**\n     * Set the path to the cache dir which must exist.\n     *\n     * @param string path to the cache dir.\n     *\n     * @throws Exception when $path is not a directory.\n     *\n     * @return $this\n     */\n    public function setDir($path)\n    {\n        if (!is_dir($path)) {\n            throw new Exception(\"Cachedir is not a directory.\");\n        }\n\n        $this->path = $path;\n\n        return $this;\n    }\n\n\n\n    /**\n     * Get the path to the cache subdir and try to create it if its not there.\n     *\n     * @param string $subdir name of subdir\n     * @param array  $create default is to try to create the subdir\n     *\n     * @return string | boolean as real path to the subdir or\n     *                          false if it does not exists\n     */\n    public function getPathToSubdir($subdir, $create = true)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        if (is_dir($path)) {\n            return $path;\n        }\n\n        if ($create && defined('WINDOWS2WSL')) {\n            // Special case to solve Windows 2 WSL integration\n            $path = $this->path . \"/\" . $subdir;\n\n            if (mkdir($path)) {\n                return realpath($path);\n            }\n        }\n\n        if ($create && is_writable($this->path)) {\n            $path = $this->path . \"/\" . $subdir;\n\n            if (mkdir($path)) {\n                return realpath($path);\n            }\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Get status of the cache subdir.\n     *\n     * @param string $subdir name of subdir\n     *\n     * @return string with status\n     */\n    public function getStatusOfSubdir($subdir)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        $exists = is_dir($path);\n        $res  = $exists ? \"exists\" : \"does not exist\";\n        \n        if ($exists) {\n            $res .= is_writable($path) ? \", writable\" : \", not writable\";\n        }\n\n        return $res;\n    }\n\n\n\n    /**\n     * Remove the cache subdir.\n     *\n     * @param string $subdir name of subdir\n     *\n     * @return null | boolean true if success else false, null if no operation\n     */\n    public function removeSubdir($subdir)\n    {\n        $path = realpath($this->path . \"/\" . $subdir);\n\n        if (is_dir($path)) {\n            return rmdir($path);\n        }\n\n        return null;\n    }\n}\n\n\n\n/**\n * Enable a fast track cache with a json representation of the image delivery.\n *\n */\nclass CFastTrackCache\n{\n    /**\n     * Cache is disabled to start with.\n     */\n    private $enabled = false;\n\n\n\n    /**\n     * Path to the cache directory.\n     */\n    private $path;\n\n\n\n    /**\n     * Filename of current cache item.\n     */\n    private $filename;\n\n\n\n    /**\n     * Container with items to store as cached item.\n     */\n    private $container;\n\n\n\n    /**\n     * Enable or disable cache.\n     *\n     * @param boolean $enable set to true to enable, false to disable\n     *\n     * @return $this\n     */\n    public function enable($enabled)\n    {\n        $this->enabled = $enabled;\n        return $this;\n    }\n\n\n\n    /**\n     * Set the path to the cache dir which must exist.\n     *\n     * @param string $path to the cache dir.\n     *\n     * @throws Exception when $path is not a directory.\n     *\n     * @return $this\n     */\n    public function setCacheDir($path)\n    {\n        if (!is_dir($path)) {\n            throw new Exception(\"Cachedir is not a directory.\");\n        }\n\n        $this->path = rtrim($path, \"/\");\n\n        return $this;\n    }\n\n\n\n    /**\n     * Set the filename to store in cache, use the querystring to create that\n     * filename.\n     *\n     * @param array $clear items to clear in $_GET when creating the filename.\n     *\n     * @return string as filename created.\n     */\n    public function setFilename($clear)\n    {\n        $query = $_GET;\n\n        // Remove parts from querystring that should not be part of filename\n        foreach ($clear as $value) {\n            unset($query[$value]);\n        }\n\n        arsort($query);\n        $queryAsString = http_build_query($query);\n\n        $this->filename = md5($queryAsString);\n\n        if (CIMAGE_DEBUG) {\n            $this->container[\"query-string\"] = $queryAsString;\n        }\n\n        return $this->filename;\n    }\n\n\n\n    /**\n     * Add header items.\n     *\n     * @param string $header add this as header.\n     *\n     * @return $this\n     */\n    public function addHeader($header)\n    {\n        $this->container[\"header\"][] = $header;\n        return $this;\n    }\n\n\n\n    /**\n     * Add header items on output, these are not output when 304.\n     *\n     * @param string $header add this as header.\n     *\n     * @return $this\n     */\n    public function addHeaderOnOutput($header)\n    {\n        $this->container[\"header-output\"][] = $header;\n        return $this;\n    }\n\n\n\n    /**\n     * Set path to source image to.\n     *\n     * @param string $source path to source image file.\n     *\n     * @return $this\n     */\n    public function setSource($source)\n    {\n        $this->container[\"source\"] = $source;\n        return $this;\n    }\n\n\n\n    /**\n     * Set last modified of source image, use to check for 304.\n     *\n     * @param string $lastModified\n     *\n     * @return $this\n     */\n    public function setLastModified($lastModified)\n    {\n        $this->container[\"last-modified\"] = $lastModified;\n        return $this;\n    }\n\n\n\n    /**\n     * Get filename of cached item.\n     *\n     * @return string as filename.\n     */\n    public function getFilename()\n    {\n        return $this->path . \"/\" . $this->filename;\n    }\n\n\n\n    /**\n     * Write current item to cache.\n     *\n     * @return boolean if cache file was written.\n     */\n    public function writeToCache()\n    {\n        if (!$this->enabled) {\n            return false;\n        }\n\n        if (is_dir($this->path) && is_writable($this->path)) {\n            $filename = $this->getFilename();\n            return file_put_contents($filename, json_encode($this->container)) !== false;\n        }\n\n        return false;\n    }\n\n\n\n    /**\n     * Output current item from cache, if available.\n     *\n     * @return void\n     */\n    public function output()\n    {\n        $filename = $this->getFilename();\n        if (!is_readable($filename)) {\n            return;\n        }\n\n        $item = json_decode(file_get_contents($filename), true);\n\n        if (!is_readable($item[\"source\"])) {\n            return;\n        }\n\n        foreach ($item[\"header\"] as $value) {\n            header($value);\n        }\n\n        if (isset($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"])\n            && strtotime($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"]) == $item[\"last-modified\"]) {\n            header(\"HTTP/1.0 304 Not Modified\");\n            if (CIMAGE_DEBUG) {\n                trace(__CLASS__ . \" 304\");\n            }\n            exit;\n        }\n\n        foreach ($item[\"header-output\"] as $value) {\n            header($value);\n        }\n\n        if (CIMAGE_DEBUG) {\n            trace(__CLASS__ . \" 200\");\n        }\n        readfile($item[\"source\"]);\n        exit;\n    }\n}\n\n\n\n/**\n * Resize and crop images on the fly, store generated images in a cache.\n *\n * @author  Mikael Roos mos@dbwebb.se\n * @example http://dbwebb.se/opensource/cimage\n * @link    https://github.com/mosbth/cimage\n *\n */\n\n/**\n * Custom exception handler.\n */\nset_exception_handler(function ($exception) {\n    errorPage(\n        \"<p><b>img.php: Uncaught exception:</b> <p>\"\n        . $exception->getMessage()\n        . \"</p><pre>\"\n        . $exception->getTraceAsString()\n        . \"</pre>\",\n        500\n    );\n});\n\n\n\n/**\n * Get configuration options from file, if the file exists, else use $config\n * if its defined or create an empty $config.\n */\n$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';\n\nif (is_file($configFile)) {\n    $config = require $configFile;\n} elseif (!isset($config)) {\n    $config = array();\n}\n\n// Make CIMAGE_DEBUG false by default, if not already defined\nif (!defined(\"CIMAGE_DEBUG\")) {\n    define(\"CIMAGE_DEBUG\", false);\n}\n\n\n\n/**\n * Setup the autoloader, but not when using a bundle.\n */\nif (!defined(\"CIMAGE_BUNDLE\")) {\n    if (!isset($config[\"autoloader\"])) {\n        die(\"CImage: Missing autoloader.\");\n    }\n\n    require $config[\"autoloader\"];\n}\n\n\n\n/**\n* verbose, v - do a verbose dump of what happens\n* vf - do verbose dump to file\n*/\n$verbose = getDefined(array('verbose', 'v'), true, false);\n$verboseFile = getDefined('vf', true, false);\nverbose(\"img.php version = \" . CIMAGE_VERSION);\n\n\n\n/**\n* status - do a verbose dump of the configuration\n*/\n$status = getDefined('status', true, false);\n\n\n\n/**\n * Set mode as strict, production or development.\n * Default is production environment.\n */\n$mode = getConfig('mode', 'production');\n\n// Settings for any mode\nset_time_limit(20);\nini_set('gd.jpeg_ignore_warning', 1);\n\nif (!extension_loaded('gd')) {\n    errorPage(\"Extension gd is not loaded.\", 500);\n}\n\n// Specific settings for each mode\nif ($mode == 'strict') {\n\n    error_reporting(0);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n\n} elseif ($mode == 'production') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 0);\n    ini_set('log_errors', 1);\n    $verbose = false;\n    $status = false;\n    $verboseFile = false;\n\n} elseif ($mode == 'development') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n    $verboseFile = false;\n\n} elseif ($mode == 'test') {\n\n    error_reporting(-1);\n    ini_set('display_errors', 1);\n    ini_set('log_errors', 0);\n\n} else {\n    errorPage(\"Unknown mode: $mode\", 500);\n}\n\nverbose(\"mode = $mode\");\nverbose(\"error log = \" . ini_get('error_log'));\n\n\n\n/**\n * Set default timezone if not set or if its set in the config-file.\n */\n$defaultTimezone = getConfig('default_timezone', null);\n\nif ($defaultTimezone) {\n    date_default_timezone_set($defaultTimezone);\n} elseif (!ini_get('default_timezone')) {\n    date_default_timezone_set('UTC');\n}\n\n\n\n/**\n * Check if passwords are configured, used and match.\n * Options decide themself if they require passwords to be used.\n */\n$pwdConfig   = getConfig('password', false);\n$pwdAlways   = getConfig('password_always', false);\n$pwdType     = getConfig('password_type', 'text');\n$pwd         = get(array('password', 'pwd'), null);\n\n// Check if passwords match, if configured to use passwords\n$passwordMatch = null;\nif ($pwd) {\n    switch ($pwdType) {\n        case 'md5':\n            $passwordMatch = ($pwdConfig === md5($pwd));\n            break;\n        case 'hash':\n            $passwordMatch = password_verify($pwd, $pwdConfig);\n            break;\n        case 'text':\n            $passwordMatch = ($pwdConfig === $pwd);\n            break;\n        default:\n            $passwordMatch = false;\n    }\n}\n\nif ($pwdAlways && $passwordMatch !== true) {\n    errorPage(\"Password required and does not match or exists.\", 403);\n}\n\nverbose(\"password match = $passwordMatch\");\n\n\n\n/**\n * Prevent hotlinking, leeching, of images by controlling who access them\n * from where.\n *\n */\n$allowHotlinking = getConfig('allow_hotlinking', true);\n$hotlinkingWhitelist = getConfig('hotlinking_whitelist', array());\n\n$serverName  = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;\n$referer     = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;\n$refererHost = parse_url($referer ?? \"\", PHP_URL_HOST);\n\nif (!$allowHotlinking) {\n    if ($passwordMatch) {\n        ; // Always allow when password match\n        verbose(\"Hotlinking since passwordmatch\");\n    } elseif ($passwordMatch === false) {\n        errorPage(\"Hotlinking/leeching not allowed when password missmatch.\", 403);\n    } elseif (!$referer) {\n        errorPage(\"Hotlinking/leeching not allowed and referer is missing.\", 403);\n    } elseif (strcmp($serverName, $refererHost) == 0) {\n        ; // Allow when serverName matches refererHost\n        verbose(\"Hotlinking disallowed but serverName matches refererHost.\");\n    } elseif (!empty($hotlinkingWhitelist)) {\n        $whitelist = new CWhitelist();\n        $allowedByWhitelist = $whitelist->check($refererHost, $hotlinkingWhitelist);\n\n        if ($allowedByWhitelist) {\n            verbose(\"Hotlinking/leeching allowed by whitelist.\");\n        } else {\n            errorPage(\"Hotlinking/leeching not allowed by whitelist. Referer: $referer.\", 403);\n        }\n\n    } else {\n        errorPage(\"Hotlinking/leeching not allowed.\", 403);\n    }\n}\n\nverbose(\"allow_hotlinking = $allowHotlinking\");\nverbose(\"referer = $referer\");\nverbose(\"referer host = $refererHost\");\n\n\n\n/**\n * Create the class for the image.\n */\n$CImage = getConfig('CImage', 'CImage');\n$img = new $CImage();\n$img->setVerbose($verbose || $verboseFile);\n\n\n\n/**\n * Get the cachepath from config.\n */\n$CCache = getConfig('CCache', 'CCache');\n$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');\n$cache = new $CCache();\n$cache->setDir($cachePath);\n\n\n\n/**\n * no-cache, nc - skip the cached version and process and create a new version in cache.\n */\n$useCache = getDefined(array('no-cache', 'nc'), false, true);\n\nverbose(\"use cache = $useCache\");\n\n\n\n/**\n * Prepare fast track cache for swriting cache items.\n */\n$fastTrackCache = \"fasttrack\";\n$allowFastTrackCache = getConfig('fast_track_allow', false);\n\n$CFastTrackCache = getConfig('CFastTrackCache', 'CFastTrackCache');\n$ftc = new $CFastTrackCache();\n$ftc->setCacheDir($cache->getPathToSubdir($fastTrackCache))\n    ->enable($allowFastTrackCache)\n    ->setFilename(array('no-cache', 'nc'));\n$img->injectDependency(\"fastTrackCache\", $ftc);\n\n\n\n/**\n *  Load and output images from fast track cache, if items are available\n * in cache.\n */\nif ($useCache && $allowFastTrackCache) {\n    if (CIMAGE_DEBUG) {\n        trace(\"img.php fast track cache enabled and used\");\n    }\n    $ftc->output();\n}\n\n\n\n/**\n * Allow or disallow remote download of images from other servers.\n * Passwords apply if used.\n *\n */\n$allowRemote = getConfig('remote_allow', false);\n\nif ($allowRemote && $passwordMatch !== false) {\n    $cacheRemote = $cache->getPathToSubdir(\"remote\");\n\n    $pattern = getConfig('remote_pattern', null);\n    $img->setRemoteDownload($allowRemote, $cacheRemote, $pattern);\n\n    $whitelist = getConfig('remote_whitelist', null);\n    $img->setRemoteHostWhitelist($whitelist);\n}\n\n\n\n/**\n * shortcut, sc - extend arguments with a constant value, defined\n * in config-file.\n */\n$shortcut       = get(array('shortcut', 'sc'), null);\n$shortcutConfig = getConfig('shortcut', array(\n    'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\",\n));\n\nverbose(\"shortcut = $shortcut\");\n\nif (isset($shortcut)\n    && isset($shortcutConfig[$shortcut])) {\n\n    parse_str($shortcutConfig[$shortcut], $get);\n    verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\");\n    $_GET = array_merge($_GET, $get);\n}\n\n\n\n/**\n * src - the source image file.\n */\n$srcImage = urldecode(get('src', \"\"))\n    or errorPage('Must set src-attribute.', 404);\n\n// Get settings for src-alt as backup image\n$srcAltImage = urldecode(get('src-alt', \"\"));\n$srcAltConfig = getConfig('src_alt', null);\nif (empty($srcAltImage)) {\n    $srcAltImage = $srcAltConfig;\n}\n\n// Check for valid/invalid characters\n$imagePath           = getConfig('image_path', __DIR__ . '/img/');\n$imagePathConstraint = getConfig('image_path_constraint', true);\n$validFilename       = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \\.:]+$#');\n\n// Source is remote\n$remoteSource = false;\n\n// Dummy image feature\n$dummyEnabled  = getConfig('dummy_enabled', true);\n$dummyFilename = getConfig('dummy_filename', 'dummy');\n$dummyImage = false;\n\npreg_match($validFilename, $srcImage)\n    or errorPage('Source filename contains invalid characters.', 404);\n\nif ($dummyEnabled && $srcImage === $dummyFilename) {\n\n    // Prepare to create a dummy image and use it as the source image.\n    $dummyImage = true;\n\n} elseif ($allowRemote && $img->isRemoteSource($srcImage)) {\n\n    // If source is a remote file, ignore local file checks.\n    $remoteSource = true;\n\n} else {\n\n    // Check if file exists on disk or try using src-alt\n    $pathToImage = realpath($imagePath . $srcImage);\n\n    if (!is_file($pathToImage) && !empty($srcAltImage)) {\n        // Try using the src-alt instead\n        $srcImage = $srcAltImage;\n        $pathToImage = realpath($imagePath . $srcImage);\n\n        preg_match($validFilename, $srcImage)\n            or errorPage('Source (alt) filename contains invalid characters.', 404);\n\n        if ($dummyEnabled && $srcImage === $dummyFilename) {\n            // Check if src-alt is the dummy image\n            $dummyImage = true;\n        }\n    }\n\n    if (!$dummyImage) {\n        is_file($pathToImage)\n            or errorPage(\n                'Source image is not a valid file, check the filename and that a\n                matching file exists on the filesystem.',\n                404\n            );\n    }\n}\n\nif ($imagePathConstraint && !$dummyImage && !$remoteSource) {\n    // Check that the image is a file below the directory 'image_path'.\n    $imageDir = realpath($imagePath);\n\n    substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0\n        or errorPage(\n            'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.',\n            404\n        );\n}\n\nverbose(\"src = $srcImage\");\n\n\n\n/**\n * Manage size constants from config file, use constants to replace values\n * for width and height.\n */\n$sizeConstant = getConfig('size_constant', function () {\n\n    // Set sizes to map constant to value, easier to use with width or height\n    $sizes = array(\n        'w1' => 613,\n        'w2' => 630,\n    );\n\n    // Add grid column width, useful for use as predefined size for width (or height).\n    $gridColumnWidth = 30;\n    $gridGutterWidth = 10;\n    $gridColumns     = 24;\n\n    for ($i = 1; $i <= $gridColumns; $i++) {\n        $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;\n    }\n\n    return $sizes;\n});\n\n$sizes = call_user_func($sizeConstant);\n\n\n\n/**\n * width, w - set target width, affecting the resulting image width, height and resize options\n */\n$newWidth     = get(array('width', 'w'));\n$maxWidth     = getConfig('max_width', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newWidth])) {\n    $newWidth = $sizes[$newWidth];\n}\n\n// Support width as % of original width\nif ($newWidth && $newWidth[strlen($newWidth)-1] == '%') {\n    is_numeric(substr($newWidth, 0, -1))\n        or errorPage('Width % not numeric.', 404);\n} else {\n    is_null($newWidth)\n        or ($newWidth > 10 && $newWidth <= $maxWidth)\n        or errorPage('Width out of range.', 404);\n}\n\nverbose(\"new width = $newWidth\");\n\n\n\n/**\n * height, h - set target height, affecting the resulting image width, height and resize options\n */\n$newHeight = get(array('height', 'h'));\n$maxHeight = getConfig('max_height', 2000);\n\n// Check to replace predefined size\nif (isset($sizes[$newHeight])) {\n    $newHeight = $sizes[$newHeight];\n}\n\n// height\nif ($newHeight && $newHeight[strlen($newHeight)-1] == '%') {\n    is_numeric(substr($newHeight, 0, -1))\n        or errorPage('Height % out of range.', 404);\n} else {\n    is_null($newHeight)\n        or ($newHeight > 10 && $newHeight <= $maxHeight)\n        or errorPage('Height out of range.', 404);\n}\n\nverbose(\"new height = $newHeight\");\n\n\n\n/**\n * aspect-ratio, ar - affecting the resulting image width, height and resize options\n */\n$aspectRatio         = get(array('aspect-ratio', 'ar'));\n$aspectRatioConstant = getConfig('aspect_ratio_constant', function () {\n    return array(\n        '3:1'    => 3/1,\n        '3:2'    => 3/2,\n        '4:3'    => 4/3,\n        '8:5'    => 8/5,\n        '16:10'  => 16/10,\n        '16:9'   => 16/9,\n        'golden' => 1.618,\n    );\n});\n\n// Check to replace predefined aspect ratio\n$aspectRatios = call_user_func($aspectRatioConstant);\n$negateAspectRatio = ($aspectRatio && $aspectRatio[0] == '!') ? true : false;\n$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;\n\nif (isset($aspectRatios[$aspectRatio])) {\n    $aspectRatio = $aspectRatios[$aspectRatio];\n}\n\nif ($negateAspectRatio) {\n    $aspectRatio = 1 / $aspectRatio;\n}\n\nis_null($aspectRatio)\n    or is_numeric($aspectRatio)\n    or errorPage('Aspect ratio out of range', 404);\n\nverbose(\"aspect ratio = $aspectRatio\");\n\n\n\n/**\n * crop-to-fit, cf - affecting the resulting image width, height and resize options\n */\n$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);\n\nverbose(\"crop to fit = $cropToFit\");\n\n\n\n/**\n * Set default background color from config file.\n */\n$backgroundColor = getConfig('background_color', null);\n\nif ($backgroundColor) {\n    $img->setDefaultBackgroundColor($backgroundColor);\n    verbose(\"Using default background_color = $backgroundColor\");\n}\n\n\n\n/**\n * bgColor - Default background color to use\n */\n$bgColor = get(array('bgColor', 'bg-color', 'bgc'), null);\n\nverbose(\"bgColor = $bgColor\");\n\n\n\n/**\n * Do or do not resample image when resizing.\n */\n$resizeStrategy = getDefined(array('no-resample'), true, false);\n\nif ($resizeStrategy) {\n    $img->setCopyResizeStrategy($img::RESIZE);\n    verbose(\"Setting = Resize instead of resample\");\n}\n\n\n\n\n/**\n * fill-to-fit, ff - affecting the resulting image width, height and resize options\n */\n$fillToFit = get(array('fill-to-fit', 'ff'), null);\n\nverbose(\"fill-to-fit = $fillToFit\");\n\nif ($fillToFit !== null) {\n\n    if (!empty($fillToFit)) {\n        $bgColor   = $fillToFit;\n        verbose(\"fillToFit changed bgColor to = $bgColor\");\n    }\n\n    $fillToFit = true;\n    verbose(\"fill-to-fit (fixed) = $fillToFit\");\n}\n\n\n\n/**\n * no-ratio, nr, stretch - affecting the resulting image width, height and resize options\n */\n$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);\n\nverbose(\"keep ratio = $keepRatio\");\n\n\n\n/**\n * crop, c - affecting the resulting image width, height and resize options\n */\n$crop = get(array('crop', 'c'));\n\nverbose(\"crop = $crop\");\n\n\n\n/**\n * area, a - affecting the resulting image width, height and resize options\n */\n$area = get(array('area', 'a'));\n\nverbose(\"area = $area\");\n\n\n\n/**\n * skip-original, so - skip the original image and always process a new image\n */\n$useOriginal = getDefined(array('skip-original', 'so'), false, true);\n$useOriginalDefault = getConfig('skip_original', false);\n\nif ($useOriginalDefault === true) {\n    verbose(\"skip original is default ON\");\n    $useOriginal = false;\n}\n\nverbose(\"use original = $useOriginal\");\n\n\n\n/**\n * quality, q - set level of quality for jpeg images\n */\n$quality = get(array('quality', 'q'));\n$qualityDefault = getConfig('jpg_quality', null);\n\nis_null($quality)\n    or ($quality > 0 and $quality <= 100)\n    or errorPage('Quality out of range', 404);\n\nif (is_null($quality) && !is_null($qualityDefault)) {\n    $quality = $qualityDefault;\n}\n\nverbose(\"quality = $quality\");\n\n\n\n/**\n * compress, co - what strategy to use when compressing png images\n */\n$compress = get(array('compress', 'co'));\n$compressDefault = getConfig('png_compression', null);\n\nis_null($compress)\n    or ($compress > 0 and $compress <= 9)\n    or errorPage('Compress out of range', 404);\n\nif (is_null($compress) && !is_null($compressDefault)) {\n    $compress = $compressDefault;\n}\n\nverbose(\"compress = $compress\");\n\n\n\n/**\n * save-as, sa - what type of image to save\n */\n$saveAs = get(array('save-as', 'sa'));\n\nverbose(\"save as = $saveAs\");\n\n\n\n/**\n * scale, s - Processing option, scale up or down the image prior actual resize\n */\n$scale = get(array('scale', 's'));\n\nis_null($scale)\n    or ($scale >= 0 and $scale <= 400)\n    or errorPage('Scale out of range', 404);\n\nverbose(\"scale = $scale\");\n\n\n\n/**\n * palette, p - Processing option, create a palette version of the image\n */\n$palette = getDefined(array('palette', 'p'), true, false);\n\nverbose(\"palette = $palette\");\n\n\n\n/**\n * sharpen - Processing option, post filter for sharpen effect\n */\n$sharpen = getDefined('sharpen', true, null);\n\nverbose(\"sharpen = $sharpen\");\n\n\n\n/**\n * emboss - Processing option, post filter for emboss effect\n */\n$emboss = getDefined('emboss', true, null);\n\nverbose(\"emboss = $emboss\");\n\n\n\n/**\n * blur - Processing option, post filter for blur effect\n */\n$blur = getDefined('blur', true, null);\n\nverbose(\"blur = $blur\");\n\n\n\n/**\n * rotateBefore - Rotate the image with an angle, before processing\n */\n$rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));\n\nis_null($rotateBefore)\n    or ($rotateBefore >= -360 and $rotateBefore <= 360)\n    or errorPage('RotateBefore out of range', 404);\n\nverbose(\"rotateBefore = $rotateBefore\");\n\n\n\n/**\n * rotateAfter - Rotate the image with an angle, before processing\n */\n$rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));\n\nis_null($rotateAfter)\n    or ($rotateAfter >= -360 and $rotateAfter <= 360)\n    or errorPage('RotateBefore out of range', 404);\n\nverbose(\"rotateAfter = $rotateAfter\");\n\n\n\n/**\n * autoRotate - Auto rotate based on EXIF information\n */\n$autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false);\n\nverbose(\"autoRotate = $autoRotate\");\n\n\n\n/**\n * filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()\n */\n$filters = array();\n$filter = get(array('filter', 'f'));\nif ($filter) {\n    $filters[] = $filter;\n}\n\nfor ($i = 0; $i < 10; $i++) {\n    $filter = get(array(\"filter{$i}\", \"f{$i}\"));\n    if ($filter) {\n        $filters[] = $filter;\n    }\n}\n\nverbose(\"filters = \" . print_r($filters, 1));\n\n\n\n/**\n* json -  output the image as a JSON object with details on the image.\n* ascii - output the image as ASCII art.\n */\n$outputFormat = getDefined('json', 'json', null);\n$outputFormat = getDefined('ascii', 'ascii', $outputFormat);\n\nverbose(\"outputformat = $outputFormat\");\n\nif ($outputFormat == 'ascii') {\n    $defaultOptions = getConfig(\n        'ascii-options',\n        array(\n            \"characterSet\" => 'two',\n            \"scale\" => 14,\n            \"luminanceStrategy\" => 3,\n            \"customCharacterSet\" => null,\n        )\n    );\n    $options = get('ascii');\n    $options = explode(',', $options);\n\n    if (isset($options[0]) && !empty($options[0])) {\n        $defaultOptions['characterSet'] = $options[0];\n    }\n\n    if (isset($options[1]) && !empty($options[1])) {\n        $defaultOptions['scale'] = $options[1];\n    }\n\n    if (isset($options[2]) && !empty($options[2])) {\n        $defaultOptions['luminanceStrategy'] = $options[2];\n    }\n\n    if (count($options) > 3) {\n        // Last option is custom character string\n        unset($options[0]);\n        unset($options[1]);\n        unset($options[2]);\n        $characterString = implode($options);\n        $defaultOptions['customCharacterSet'] = $characterString;\n    }\n\n    $img->setAsciiOptions($defaultOptions);\n}\n\n\n\n\n/**\n * dpr - change to get larger image to easier support larger dpr, such as retina.\n */\n$dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1);\n\nverbose(\"dpr = $dpr\");\n\n\n\n/**\n * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php\n */\n$convolve = get('convolve', null);\n$convolutionConstant = getConfig('convolution_constant', array());\n\n// Check if the convolve is matching an existing constant\nif ($convolve && isset($convolutionConstant)) {\n    $img->addConvolveExpressions($convolutionConstant);\n    verbose(\"convolve constant = \" . print_r($convolutionConstant, 1));\n}\n\nverbose(\"convolve = \" . print_r($convolve, 1));\n\n\n\n/**\n * no-upscale, nu - Do not upscale smaller image to larger dimension.\n */\n$upscale = getDefined(array('no-upscale', 'nu'), false, true);\n\nverbose(\"upscale = $upscale\");\n\n\n\n/**\n * Get details for post processing\n */\n$postProcessing = getConfig('postprocessing', array(\n    'png_lossy'        => false,\n    'png_lossy_cmd'    => '/usr/local/bin/pngquant --force --output',\n\n    'png_filter'        => false,\n    'png_filter_cmd'    => '/usr/local/bin/optipng -q',\n\n    'png_deflate'       => false,\n    'png_deflate_cmd'   => '/usr/local/bin/pngout -q',\n\n    'jpeg_optimize'     => false,\n    'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',\n));\n\n\n\n/**\n * lossy - Do lossy postprocessing, if available.\n */\n$lossy = getDefined(array('lossy'), true, null);\n\nverbose(\"lossy = $lossy\");\n\n\n\n/**\n * alias - Save resulting image to another alias name.\n * Password always apply, must be defined.\n */\n$alias          = get('alias', null);\n$aliasPath      = getConfig('alias_path', null);\n$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');\n$aliasTarget    = null;\n\nif ($alias && $aliasPath && $passwordMatch) {\n\n    $aliasTarget = $aliasPath . $alias;\n    $useCache    = false;\n\n    is_writable($aliasPath)\n        or errorPage(\"Directory for alias is not writable.\", 403);\n\n    preg_match($validAliasname, $alias)\n        or errorPage('Filename for alias contains invalid characters. Do not add extension.', 404);\n\n} elseif ($alias) {\n    errorPage('Alias is not enabled in the config file or password not matching.', 403);\n}\n\nverbose(\"alias = $alias\");\n\n\n\n/**\n * Add cache control HTTP header.\n */\n$cacheControl = getConfig('cache_control', null);\n\nif ($cacheControl) {\n    verbose(\"cacheControl = $cacheControl\");\n    $img->addHTTPHeader(\"Cache-Control\", $cacheControl);\n}\n\n\n\n/**\n * interlace - Enable configuration for interlaced progressive JPEG images.\n */\n$interlaceConfig  = getConfig('interlace', null);\n$interlaceValue   = getValue('interlace', null);\n$interlaceDefined = getDefined('interlace', true, null);\n$interlace = $interlaceValue ?? $interlaceDefined ?? $interlaceConfig;\nverbose(\"interlace (configfile) = \", $interlaceConfig);\nverbose(\"interlace = \", $interlace);\n\n\n\n/**\n * Prepare a dummy image and use it as source image.\n */\nif ($dummyImage === true) {\n    $dummyDir = $cache->getPathToSubdir(\"dummy\");\n\n    $img->setSaveFolder($dummyDir)\n        ->setSource($dummyFilename, $dummyDir)\n        ->setOptions(\n            array(\n                'newWidth'  => $newWidth,\n                'newHeight' => $newHeight,\n                'bgColor'   => $bgColor,\n            )\n        )\n        ->setJpegQuality($quality)\n        ->setPngCompression($compress)\n        ->createDummyImage()\n        ->generateFilename(null, false)\n        ->save(null, null, false);\n\n    $srcImage = $img->getTarget();\n    $imagePath = null;\n\n    verbose(\"src (updated) = $srcImage\");\n}\n\n\n\n/**\n * Prepare a sRGB version of the image and use it as source image.\n */\n$srgbDefault = getConfig('srgb_default', false);\n$srgbColorProfile = getConfig('srgb_colorprofile', __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc');\n$srgb = getDefined('srgb', true, null);\n\nif ($srgb || $srgbDefault) {\n\n    $filename = $img->convert2sRGBColorSpace(\n        $srcImage,\n        $imagePath,\n        $cache->getPathToSubdir(\"srgb\"),\n        $srgbColorProfile,\n        $useCache\n    );\n\n    if ($filename) {\n        $srcImage = $img->getTarget();\n        $imagePath = null;\n        verbose(\"srgb conversion and saved to cache = $srcImage\");\n    } else {\n        verbose(\"srgb not op\");\n    }\n}\n\n\n\n/**\n * Display status\n */\nif ($status) {\n    $text  = \"img.php version = \" . CIMAGE_VERSION . \"\\n\";\n    $text .= \"PHP version = \" . PHP_VERSION . \"\\n\";\n    $text .= \"Running on: \" . $_SERVER['SERVER_SOFTWARE'] . \"\\n\";\n    $text .= \"Allow remote images = $allowRemote\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"\");\n    $text .= \"Cache $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"remote\");\n    $text .= \"Cache remote $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"dummy\");\n    $text .= \"Cache dummy $res\\n\";\n\n    $res = $cache->getStatusOfSubdir(\"srgb\");\n    $text .= \"Cache srgb $res\\n\";\n\n    $res = $cache->getStatusOfSubdir($fastTrackCache);\n    $text .= \"Cache fasttrack $res\\n\";\n\n    $text .= \"Alias path writable = \" . is_writable($aliasPath) . \"\\n\";\n\n    $no = extension_loaded('exif') ? null : 'NOT';\n    $text .= \"Extension exif is $no loaded.<br>\";\n\n    $no = extension_loaded('curl') ? null : 'NOT';\n    $text .= \"Extension curl is $no loaded.<br>\";\n\n    $no = extension_loaded('imagick') ? null : 'NOT';\n    $text .= \"Extension imagick is $no loaded.<br>\";\n\n    $no = extension_loaded('gd') ? null : 'NOT';\n    $text .= \"Extension gd is $no loaded.<br>\";\n\n    $text .= checkExternalCommand(\"PNG LOSSY\", $postProcessing[\"png_lossy\"], $postProcessing[\"png_lossy_cmd\"]);\n    $text .= checkExternalCommand(\"PNG FILTER\", $postProcessing[\"png_filter\"], $postProcessing[\"png_filter_cmd\"]);\n    $text .= checkExternalCommand(\"PNG DEFLATE\", $postProcessing[\"png_deflate\"], $postProcessing[\"png_deflate_cmd\"]);\n    $text .= checkExternalCommand(\"JPEG OPTIMIZE\", $postProcessing[\"jpeg_optimize\"], $postProcessing[\"jpeg_optimize_cmd\"]);\n\n    if (!$no) {\n        $text .= print_r(gd_info(), 1);\n    }\n\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage status</title>\n<pre>$text</pre>\nEOD;\n    exit;\n}\n\n\n\n/**\n * Log verbose details to file\n */\nif ($verboseFile) {\n    $img->setVerboseToFile(\"$cachePath/log.txt\");\n}\n\n\n\n/**\n * Hook after img.php configuration and before processing with CImage\n */\n$hookBeforeCImage = getConfig('hook_before_CImage', null);\n\nif (is_callable($hookBeforeCImage)) {\n    verbose(\"hookBeforeCImage activated\");\n\n    $allConfig = $hookBeforeCImage($img, array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n            'interlace' => $interlace,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n\n            // Other\n            'postProcessing' => $postProcessing,\n            'lossy' => $lossy,\n    ));\n    verbose(print_r($allConfig, 1));\n    extract($allConfig);\n}\n\n\n\n/**\n * Display image if verbose mode\n */\nif ($verbose) {\n    $query = array();\n    parse_str($_SERVER['QUERY_STRING'], $query);\n    unset($query['verbose']);\n    unset($query['v']);\n    unset($query['nocache']);\n    unset($query['nc']);\n    unset($query['json']);\n    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));\n    $url2 = '?' . urldecode(http_build_query($query));\n    echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\nmime type: \" + data.mimeType + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio + ( data.pngType ? \"\\\\npng-type: \" + data.pngType : '');\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n}\n\n\n\n/**\n * Load, process and output the image\n */\n$img->log(\"PHP version: \" . phpversion())\n    ->log(\"Incoming arguments: \" . print_r(verbose(), 1))\n    ->setSaveFolder($cachePath)\n    ->useCache($useCache)\n    ->setSource($srcImage, $imagePath)\n    ->setOptions(\n        array(\n            // Options for calculate dimensions\n            'newWidth'  => $newWidth,\n            'newHeight' => $newHeight,\n            'aspectRatio' => $aspectRatio,\n            'keepRatio' => $keepRatio,\n            'cropToFit' => $cropToFit,\n            'fillToFit' => $fillToFit,\n            'crop'      => $crop,\n            'area'      => $area,\n            'upscale'   => $upscale,\n\n            // Pre-processing, before resizing is done\n            'scale'        => $scale,\n            'rotateBefore' => $rotateBefore,\n            'autoRotate'   => $autoRotate,\n\n            // General processing options\n            'bgColor'    => $bgColor,\n\n            // Post-processing, after resizing is done\n            'palette'   => $palette,\n            'filters'   => $filters,\n            'sharpen'   => $sharpen,\n            'emboss'    => $emboss,\n            'blur'      => $blur,\n            'convolve'  => $convolve,\n            'rotateAfter' => $rotateAfter,\n            'interlace' => $interlace,\n\n            // Output format\n            'outputFormat' => $outputFormat,\n            'dpr'          => $dpr,\n\n            // Postprocessing using external tools\n            'lossy' => $lossy,\n        )\n    )\n    ->loadImageDetails()\n    ->initDimensions()\n    ->calculateNewWidthAndHeight()\n    ->setSaveAsExtension($saveAs)\n    ->setJpegQuality($quality)\n    ->setPngCompression($compress)\n    ->useOriginalIfPossible($useOriginal)\n    ->generateFilename($cachePath)\n    ->useCacheIfPossible($useCache)\n    ->load()\n    ->preResize()\n    ->resize()\n    ->postResize()\n    ->setPostProcessingOptions($postProcessing)\n    ->save()\n    ->linkToCacheFile($aliasTarget)\n    ->output();\n\n\n\n"
  },
  {
    "path": "webroot/imgs.php",
    "content": "<?php\n define(\"CIMAGE_BUNDLE\", true); $config = array( 'mode' => 'strict', ); define(\"CIMAGE_VERSION\", \"v0.8.6 (2023-10-27)\"); define(\"CIMAGE_USER_AGENT\", \"CImage/\" . CIMAGE_VERSION); if (!defined(\"IMG_WEBP\")) { define(\"IMG_WEBP\", -1); } function trace($msg) { $file = CIMAGE_DEBUG_FILE; if (!is_writable($file)) { return; } $timer = number_format((microtime(true) - $_SERVER[\"REQUEST_TIME_FLOAT\"]), 6); $details = \"{$timer}ms\"; $details .= \":\" . round(memory_get_peak_usage()/1024/1024, 3) . \"MB\"; $details .= \":\" . count(get_included_files()); file_put_contents($file, \"$details:$msg\\n\", FILE_APPEND); } function errorPage($msg, $type = 500) { global $mode; switch ($type) { case 403: $header = \"403 Forbidden\"; break; case 404: $header = \"404 Not Found\"; break; default: $header = \"500 Internal Server Error\"; } if ($mode == \"strict\") { $header = \"404 Not Found\"; } header(\"HTTP/1.0 $header\"); if ($mode == \"development\") { die(\"[img.php] $msg\"); } error_log(\"[img.php] $msg\"); die(\"HTTP/1.0 $header\"); } function get($key, $default = null) { if (is_array($key)) { foreach ($key as $val) { if (isset($_GET[$val])) { return $_GET[$val]; } } } elseif (isset($_GET[$key])) { return $_GET[$key]; } return $default; } function getDefined($key, $defined, $undefined) { return get($key) === null ? $undefined : $defined; } function getValue($key, $undefined) { $val = get($key); if (is_null($val) || $val === \"\") { return $undefined; } return $val; } function getConfig($key, $default) { global $config; return isset($config[$key]) ? $config[$key] : $default; } function verbose($msg = null, $arg = \"\") { global $verbose, $verboseFile; static $log = array(); if (!($verbose || $verboseFile)) { return; } if (is_null($msg)) { return $log; } if (is_null($arg)) { $arg = \"null\"; } elseif ($arg === false) { $arg = \"false\"; } elseif ($arg === true) { $arg = \"true\"; } $log[] = $msg . $arg; } function checkExternalCommand($what, $enabled, $commandString) { $no = $enabled ? null : 'NOT'; $text = \"Post processing $what is $no enabled.<br>\"; list($command) = explode(\" \", $commandString); $no = is_executable($command) ? null : 'NOT'; $text .= \"The command for $what is $no an executable.<br>\"; return $text; } class CHttpGet { private $request = array(); private $response = array(); public function __construct() { $this->request['header'] = array(); } public function buildUrl($baseUrl, $merge) { $parts = parse_url($baseUrl); $parts = array_merge($parts, $merge); $url = $parts['scheme']; $url .= \"://\"; $url .= $parts['host']; $url .= isset($parts['port']) ? \":\" . $parts['port'] : \"\" ; $url .= $parts['path']; return $url; } public function setUrl($url) { $parts = parse_url($url); $path = \"\"; if (isset($parts['path'])) { $pathParts = explode('/', $parts['path']); unset($pathParts[0]); foreach ($pathParts as $value) { $path .= \"/\" . rawurlencode($value); } } $url = $this->buildUrl($url, array(\"path\" => $path)); $this->request['url'] = $url; return $this; } public function setHeader($field, $value) { $this->request['header'][] = \"$field: $value\"; return $this; } public function parseHeader() { $rawHeaders = rtrim($this->response['headerRaw'], \"\\r\\n\"); $headerGroups = explode(\"\\r\\n\\r\\n\", $rawHeaders); $header = explode(\"\\r\\n\", end($headerGroups)); $output = array(); if ('HTTP' === substr($header[0], 0, 4)) { list($output['version'], $output['status']) = explode(' ', $header[0]); unset($header[0]); } foreach ($header as $entry) { $pos = strpos($entry, ':'); $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1)); } $this->response['header'] = $output; return $this; } public function doGet($debug = false) { $options = array( CURLOPT_URL => $this->request['url'], CURLOPT_HEADER => 1, CURLOPT_HTTPHEADER => $this->request['header'], CURLOPT_AUTOREFERER => true, CURLOPT_RETURNTRANSFER => true, CURLINFO_HEADER_OUT => $debug, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 2, ); $ch = curl_init(); curl_setopt_array($ch, $options); $response = curl_exec($ch); if (!$response) { throw new Exception(\"Failed retrieving url, details follows: \" . curl_error($ch)); } $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $this->response['headerRaw'] = substr($response, 0, $headerSize); $this->response['body'] = substr($response, $headerSize); $this->parseHeader(); if ($debug) { $info = curl_getinfo($ch); echo \"Request header<br><pre>\", var_dump($info['request_header']), \"</pre>\"; echo \"Response header (raw)<br><pre>\", var_dump($this->response['headerRaw']), \"</pre>\"; echo \"Response header (parsed)<br><pre>\", var_dump($this->response['header']), \"</pre>\"; } curl_close($ch); return true; } public function getStatus() { return isset($this->response['header']['status']) ? (int) $this->response['header']['status'] : null; } public function getLastModified() { return isset($this->response['header']['Last-Modified']) ? strtotime($this->response['header']['Last-Modified']) : null; } public function getContentType() { $type = isset($this->response['header']['Content-Type']) ? $this->response['header']['Content-Type'] : ''; return preg_match('#[a-z]+/[a-z]+#', $type) ? $type : null; } public function getDate($default = false) { return isset($this->response['header']['Date']) ? strtotime($this->response['header']['Date']) : $default; } public function getMaxAge($default = false) { $cacheControl = isset($this->response['header']['Cache-Control']) ? $this->response['header']['Cache-Control'] : null; $maxAge = null; if ($cacheControl) { $part = explode('=', $cacheControl); $maxAge = ($part[0] == \"max-age\") ? (int) $part[1] : null; } if ($maxAge) { return $maxAge; } $expire = isset($this->response['header']['Expires']) ? strtotime($this->response['header']['Expires']) : null; return $expire ? $expire : $default; } public function getBody() { return $this->response['body']; } } class CRemoteImage { private $saveFolder = null; private $useCache = true; private $http; private $status; private $defaultMaxAge = 604800; private $url; private $fileName; private $fileJson; private $cache; public function getStatus() { return $this->status; } public function getDetails() { return $this->cache; } public function setCache($path) { $this->saveFolder = rtrim($path, \"/\") . \"/\"; return $this; } public function isCacheWritable() { if (!is_writable($this->saveFolder)) { throw new Exception(\"Cache folder is not writable for downloaded files.\"); } return $this; } public function useCache($use = true) { $this->useCache = $use; return $this; } public function setHeaderFields() { $cimageVersion = \"CImage\"; if (defined(\"CIMAGE_USER_AGENT\")) { $cimageVersion = CIMAGE_USER_AGENT; } $this->http->setHeader(\"User-Agent\", \"$cimageVersion (PHP/\". phpversion() . \" cURL)\"); $this->http->setHeader(\"Accept\", \"image/jpeg,image/png,image/gif\"); if ($this->useCache) { $this->http->setHeader(\"Cache-Control\", \"max-age=0\"); } else { $this->http->setHeader(\"Cache-Control\", \"no-cache\"); $this->http->setHeader(\"Pragma\", \"no-cache\"); } } public function save() { $this->cache = array(); $date = $this->http->getDate(time()); $maxAge = $this->http->getMaxAge($this->defaultMaxAge); $lastModified = $this->http->getLastModified(); $type = $this->http->getContentType(); $this->cache['Date'] = gmdate(\"D, d M Y H:i:s T\", $date); $this->cache['Max-Age'] = $maxAge; $this->cache['Content-Type'] = $type; $this->cache['Url'] = $this->url; if ($lastModified) { $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified); } $body = $this->http->getBody(); $img = imagecreatefromstring($body); if ($img !== false) { file_put_contents($this->fileName, $body); file_put_contents($this->fileJson, json_encode($this->cache)); return $this->fileName; } return false; } public function updateCacheDetails() { $date = $this->http->getDate(time()); $maxAge = $this->http->getMaxAge($this->defaultMaxAge); $lastModified = $this->http->getLastModified(); $this->cache['Date'] = gmdate(\"D, d M Y H:i:s T\", $date); $this->cache['Max-Age'] = $maxAge; if ($lastModified) { $this->cache['Last-Modified'] = gmdate(\"D, d M Y H:i:s T\", $lastModified); } file_put_contents($this->fileJson, json_encode($this->cache)); return $this->fileName; } public function download($url) { $this->http = new CHttpGet(); $this->url = $url; $this->loadCacheDetails(); if ($this->useCache) { $src = $this->getCachedSource(); if ($src) { $this->status = 1; return $src; } } $this->setHeaderFields(); $this->http->setUrl($this->url); $this->http->doGet(); $this->status = $this->http->getStatus(); if ($this->status === 200) { $this->isCacheWritable(); return $this->save(); } elseif ($this->status === 304) { $this->isCacheWritable(); return $this->updateCacheDetails(); } throw new Exception(\"Unknown statuscode when downloading remote image: \" . $this->status); } public function loadCacheDetails() { $cacheFile = md5($this->url); $this->fileName = $this->saveFolder . $cacheFile; $this->fileJson = $this->fileName . \".json\"; if (is_readable($this->fileJson)) { $this->cache = json_decode(file_get_contents($this->fileJson), true); } } public function getCachedSource() { $imageExists = is_readable($this->fileName); $date = strtotime($this->cache['Date']); $maxAge = $this->cache['Max-Age']; $now = time(); if ($imageExists && $date + $maxAge > $now) { return $this->fileName; } if ($imageExists && isset($this->cache['Last-Modified'])) { $this->http->setHeader(\"If-Modified-Since\", $this->cache['Last-Modified']); } return false; } } class CWhitelist { private $whitelist = array(); public function set($whitelist = array()) { if (!is_array($whitelist)) { throw new Exception(\"Whitelist is not of a supported format.\"); } $this->whitelist = $whitelist; return $this; } public function check($item, $whitelist = null) { if ($whitelist !== null) { $this->set($whitelist); } if (empty($item) or empty($this->whitelist)) { return false; } foreach ($this->whitelist as $regexp) { if (preg_match(\"#$regexp#\", $item)) { return true; } } return false; } } class CAsciiArt { private $characterSet = array( 'one' => \"#0XT|:,.' \", 'two' => \"@%#*+=-:. \", 'three' => \"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\\\"^`'. \" ); private $characters = null; private $charCount = null; private $scale = null; private $luminanceStrategy = null; public function __construct() { $this->setOptions(); } public function addCharacterSet($key, $value) { $this->characterSet[$key] = $value; return $this; } public function setOptions($options = array()) { $default = array( \"characterSet\" => 'two', \"scale\" => 14, \"luminanceStrategy\" => 3, \"customCharacterSet\" => null, ); $default = array_merge($default, $options); if (!is_null($default['customCharacterSet'])) { $this->addCharacterSet('custom', $default['customCharacterSet']); $default['characterSet'] = 'custom'; } $this->scale = $default['scale']; $this->characters = $this->characterSet[$default['characterSet']]; $this->charCount = strlen($this->characters); $this->luminanceStrategy = $default['luminanceStrategy']; return $this; } public function createFromFile($filename) { $img = imagecreatefromstring(file_get_contents($filename)); list($width, $height) = getimagesize($filename); $ascii = null; $incY = $this->scale; $incX = $this->scale / 2; for ($y = 0; $y < $height - 1; $y += $incY) { for ($x = 0; $x < $width - 1; $x += $incX) { $toX = min($x + $this->scale / 2, $width - 1); $toY = min($y + $this->scale, $height - 1); $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY); $ascii .= $this->luminance2character($luminance); } $ascii .= PHP_EOL; } return $ascii; } public function luminanceAreaAverage($img, $x1, $y1, $x2, $y2) { $numPixels = ($x2 - $x1 + 1) * ($y2 - $y1 + 1); $luminance = 0; for ($x = $x1; $x <= $x2; $x++) { for ($y = $y1; $y <= $y2; $y++) { $rgb = imagecolorat($img, $x, $y); $red = (($rgb >> 16) & 0xFF); $green = (($rgb >> 8) & 0xFF); $blue = ($rgb & 0xFF); $luminance += $this->getLuminance($red, $green, $blue); } } return $luminance / $numPixels; } public function getLuminance($red, $green, $blue) { switch ($this->luminanceStrategy) { case 1: $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255; break; case 2: $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255; break; case 3: $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255; break; case 0: default: $luminance = ($red + $green + $blue) / (255 * 3); } return $luminance; } public function luminance2character($luminance) { $position = (int) round($luminance * ($this->charCount - 1)); $char = $this->characters[$position]; return $char; } } #[AllowDynamicProperties] class CImage { const PNG_GREYSCALE = 0; const PNG_RGB = 2; const PNG_RGB_PALETTE = 3; const PNG_GREYSCALE_ALPHA = 4; const PNG_RGB_ALPHA = 6; const JPEG_QUALITY_DEFAULT = 60; private $quality; private $useQuality = false; const PNG_COMPRESSION_DEFAULT = -1; private $compress; private $useCompress = false; private $HTTPHeader = array(); private $bgColorDefault = array( 'red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => null, ); private $bgColor; private $saveFolder; private $image; private $imageSrc; private $pathToImage; private $fileType; private $extension; private $outputFormat = null; private $lossy = null; private $verbose = false; private $log = array(); private $palette; private $cacheFileName; private $saveAs; private $pngLossy; private $pngLossyCmd; private $pngFilter; private $pngFilterCmd; private $pngDeflate; private $pngDeflateCmd; private $jpegOptimize; private $jpegOptimizeCmd; private $width; private $height; private $newWidth; private $newWidthOrig; private $newHeight; private $newHeightOrig; private $dpr = 1; const UPSCALE_DEFAULT = true; private $upscale = self::UPSCALE_DEFAULT; public $crop; public $cropOrig; private $convolve; private $convolves = array( 'lighten' => '0,0,0, 0,12,0, 0,0,0, 9, 0', 'darken' => '0,0,0, 0,6,0, 0,0,0, 9, 0', 'sharpen' => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0', 'sharpen-alt' => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0', 'emboss' => '1,1,-1, 1,3,-1, 1,-1,-1, 3, 0', 'emboss-alt' => '-2,-1,0, -1,1,1, 0,1,2, 1, 0', 'blur' => '1,1,1, 1,15,1, 1,1,1, 23, 0', 'gblur' => '1,2,1, 2,4,2, 1,2,1, 16, 0', 'edge' => '-1,-1,-1, -1,8,-1, -1,-1,-1, 9, 0', 'edge-alt' => '0,1,0, 1,-4,1, 0,1,0, 1, 0', 'draw' => '0,-1,0, -1,5,-1, 0,-1,0, 0, 0', 'mean' => '1,1,1, 1,1,1, 1,1,1, 9, 0', 'motion' => '1,0,0, 0,1,0, 0,0,1, 3, 0', ); private $fillToFit; private $scale; private $rotateBefore; private $rotateAfter; private $autoRotate; private $sharpen; private $emboss; private $blur; private $offset; private $fillWidth; private $fillHeight; private $allowRemote = false; private $remoteCache; private $remotePattern = '#^https?://#'; private $useCache = true; private $fastTrackCache = null; private $remoteHostWhitelist = null; private $verboseFileName = null; private $asciiOptions = array(); private $interlace = false; const RESIZE = 1; const RESAMPLE = 2; private $copyStrategy = NULL; public $keepRatio; public $cropToFit; private $cropWidth; private $cropHeight; public $crop_x; public $crop_y; public $filters; private $attr; public function __construct($imageSrc = null, $imageFolder = null, $saveFolder = null, $saveName = null) { $this->setSource($imageSrc, $imageFolder); $this->setTarget($saveFolder, $saveName); } public function injectDependency($property, $object) { if (!property_exists($this, $property)) { $this->raiseError(\"Injecting unknown property.\"); } $this->$property = $object; return $this; } public function setVerbose($mode = true) { $this->verbose = $mode; return $this; } public function setSaveFolder($path) { $this->saveFolder = $path; return $this; } public function useCache($use = true) { $this->useCache = $use; return $this; } public function createDummyImage($width = null, $height = null) { $this->newWidth = $this->newWidth ?: $width ?: 100; $this->newHeight = $this->newHeight ?: $height ?: 100; $this->image = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); return $this; } public function setRemoteDownload($allow, $cache, $pattern = null) { $this->allowRemote = $allow; $this->remoteCache = $cache; $this->remotePattern = is_null($pattern) ? $this->remotePattern : $pattern; $this->log( \"Set remote download to: \" . ($this->allowRemote ? \"true\" : \"false\") . \" using pattern \" . $this->remotePattern ); return $this; } public function isRemoteSource($src) { $remote = preg_match($this->remotePattern, $src); $this->log(\"Detected remote image: \" . ($remote ? \"true\" : \"false\")); return !!$remote; } public function setRemoteHostWhitelist($whitelist = null) { $this->remoteHostWhitelist = $whitelist; $this->log( \"Setting remote host whitelist to: \" . (is_null($whitelist) ? \"null\" : print_r($whitelist, 1)) ); return $this; } public function isRemoteSourceOnWhitelist($src) { if (is_null($this->remoteHostWhitelist)) { $this->log(\"Remote host on whitelist not configured - allowing.\"); return true; } $whitelist = new CWhitelist(); $hostname = parse_url($src, PHP_URL_HOST); $allow = $whitelist->check($hostname, $this->remoteHostWhitelist); $this->log( \"Remote host is on whitelist: \" . ($allow ? \"true\" : \"false\") ); return $allow; } private function checkFileExtension($extension) { $valid = array('jpg', 'jpeg', 'png', 'gif', 'webp'); in_array(strtolower($extension), $valid) or $this->raiseError('Not a valid file extension.'); return $this; } private function normalizeFileExtension($extension = \"\") { $extension = strtolower($extension ? $extension : $this->extension ?? \"\"); if ($extension == 'jpeg') { $extension = 'jpg'; } return $extension; } public function downloadRemoteSource($src) { if (!$this->isRemoteSourceOnWhitelist($src)) { throw new Exception(\"Hostname is not on whitelist for remote sources.\"); } $remote = new CRemoteImage(); if (!is_writable($this->remoteCache)) { $this->log(\"The remote cache is not writable.\"); } $remote->setCache($this->remoteCache); $remote->useCache($this->useCache); $src = $remote->download($src); $this->log(\"Remote HTTP status: \" . $remote->getStatus()); $this->log(\"Remote item is in local cache: $src\"); $this->log(\"Remote details on cache:\" . print_r($remote->getDetails(), true)); return $src; } public function setSource($src, $dir = null) { if (!isset($src)) { $this->imageSrc = null; $this->pathToImage = null; return $this; } if ($this->allowRemote && $this->isRemoteSource($src)) { $src = $this->downloadRemoteSource($src); $dir = null; } if (!isset($dir)) { $dir = dirname($src); $src = basename($src); } $this->imageSrc = ltrim($src, '/'); $imageFolder = rtrim($dir, '/'); $this->pathToImage = $imageFolder . '/' . $this->imageSrc; return $this; } public function setTarget($src = null, $dir = null) { if (!isset($src)) { $this->cacheFileName = null; return $this; } if (isset($dir)) { $this->saveFolder = rtrim($dir, '/'); } $this->cacheFileName = $this->saveFolder . '/' . $src; $this->cacheFileName = preg_replace('/^a-zA-Z0-9\\.-_/', '', $this->cacheFileName); $this->log(\"The cache file name is: \" . $this->cacheFileName); return $this; } public function getTarget() { return $this->cacheFileName; } public function setOptions($args) { $this->log(\"Set new options for processing image.\"); $defaults = array( 'newWidth' => null, 'newHeight' => null, 'aspectRatio' => null, 'keepRatio' => true, 'cropToFit' => false, 'fillToFit' => null, 'crop' => null, 'area' => null, 'upscale' => self::UPSCALE_DEFAULT, 'useCache' => true, 'useOriginal' => true, 'scale' => null, 'rotateBefore' => null, 'autoRotate' => false, 'bgColor' => null, 'palette' => null, 'filters' => null, 'sharpen' => null, 'emboss' => null, 'blur' => null, 'convolve' => null, 'rotateAfter' => null, 'interlace' => null, 'outputFormat' => null, 'dpr' => 1, 'lossy' => null, ); if (isset($args['crop']) && !is_array($args['crop'])) { $pices = explode(',', $args['crop']); $args['crop'] = array( 'width' => $pices[0], 'height' => $pices[1], 'start_x' => $pices[2], 'start_y' => $pices[3], ); } if (isset($args['area']) && !is_array($args['area'])) { $pices = explode(',', $args['area']); $args['area'] = array( 'top' => $pices[0], 'right' => $pices[1], 'bottom' => $pices[2], 'left' => $pices[3], ); } if (isset($args['filters']) && is_array($args['filters'])) { foreach ($args['filters'] as $key => $filterStr) { $parts = explode(',', $filterStr); $filter = $this->mapFilter($parts[0]); $filter['str'] = $filterStr; for ($i=1; $i<=$filter['argc']; $i++) { if (isset($parts[$i])) { $filter[\"arg{$i}\"] = $parts[$i]; } else { throw new Exception( 'Missing arg to filter, review how many arguments are needed at\n                            http://php.net/manual/en/function.imagefilter.php' ); } } $args['filters'][$key] = $filter; } } $args = array_merge($defaults, $args); foreach ($defaults as $key => $val) { $this->{$key} = $args[$key]; } if ($this->bgColor) { $this->setDefaultBackgroundColor($this->bgColor); } $this->newWidthOrig = $this->newWidth; $this->newHeightOrig = $this->newHeight; $this->cropOrig = $this->crop; return $this; } private function mapFilter($name) { $map = array( 'negate' => array('id'=>0, 'argc'=>0, 'type'=>IMG_FILTER_NEGATE), 'grayscale' => array('id'=>1, 'argc'=>0, 'type'=>IMG_FILTER_GRAYSCALE), 'brightness' => array('id'=>2, 'argc'=>1, 'type'=>IMG_FILTER_BRIGHTNESS), 'contrast' => array('id'=>3, 'argc'=>1, 'type'=>IMG_FILTER_CONTRAST), 'colorize' => array('id'=>4, 'argc'=>4, 'type'=>IMG_FILTER_COLORIZE), 'edgedetect' => array('id'=>5, 'argc'=>0, 'type'=>IMG_FILTER_EDGEDETECT), 'emboss' => array('id'=>6, 'argc'=>0, 'type'=>IMG_FILTER_EMBOSS), 'gaussian_blur' => array('id'=>7, 'argc'=>0, 'type'=>IMG_FILTER_GAUSSIAN_BLUR), 'selective_blur' => array('id'=>8, 'argc'=>0, 'type'=>IMG_FILTER_SELECTIVE_BLUR), 'mean_removal' => array('id'=>9, 'argc'=>0, 'type'=>IMG_FILTER_MEAN_REMOVAL), 'smooth' => array('id'=>10, 'argc'=>1, 'type'=>IMG_FILTER_SMOOTH), 'pixelate' => array('id'=>11, 'argc'=>2, 'type'=>IMG_FILTER_PIXELATE), ); if (isset($map[$name])) { return $map[$name]; } else { throw new Exception('No such filter.'); } } public function loadImageDetails($file = null) { $file = $file ? $file : $this->pathToImage; if (!defined('WINDOWS2WSL')) { is_readable($file) or $this->raiseError('Image file does not exist.'); } $info = list($this->width, $this->height, $this->fileType) = getimagesize($file); if (empty($info)) { $this->fileType = false; if (function_exists(\"exif_imagetype\")) { $this->fileType = exif_imagetype($file); if ($this->fileType === false) { if (function_exists(\"imagecreatefromwebp\")) { $webp = imagecreatefromwebp($file); if ($webp !== false) { $this->width = imagesx($webp); $this->height = imagesy($webp); $this->fileType = IMG_WEBP; } } } } } if (!$this->fileType) { throw new Exception(\"Loading image details, the file doesn't seem to be a valid image.\"); } if ($this->verbose) { $this->log(\"Loading image details for: {$file}\"); $this->log(\" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType}).\"); $this->log(\" Image filesize: \" . filesize($file) . \" bytes.\"); $this->log(\" Image mimetype: \" . $this->getMimeType()); } return $this; } protected function getMimeType() { if ($this->fileType === IMG_WEBP) { return \"image/webp\"; } return image_type_to_mime_type($this->fileType); } public function initDimensions() { $this->log(\"Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\"); if ($this->newWidth && $this->newWidth[strlen($this->newWidth)-1] == '%') { $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100; $this->log(\"Setting new width based on % to {$this->newWidth}\"); } if ($this->newHeight && $this->newHeight[strlen($this->newHeight)-1] == '%') { $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100; $this->log(\"Setting new height based on % to {$this->newHeight}\"); } is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range'); if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) { if ($this->aspectRatio >= 1) { $this->newWidth = $this->width; $this->newHeight = $this->width / $this->aspectRatio; $this->log(\"Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}\"); } else { $this->newHeight = $this->height; $this->newWidth = $this->height * $this->aspectRatio; $this->log(\"Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}\"); } } elseif ($this->aspectRatio && is_null($this->newWidth)) { $this->newWidth = $this->newHeight * $this->aspectRatio; $this->log(\"Setting new width based on aspect ratio to {$this->newWidth}\"); } elseif ($this->aspectRatio && is_null($this->newHeight)) { $this->newHeight = $this->newWidth / $this->aspectRatio; $this->log(\"Setting new height based on aspect ratio to {$this->newHeight}\"); } if ($this->dpr != 1) { if (!is_null($this->newWidth)) { $this->newWidth = round($this->newWidth * $this->dpr); $this->log(\"Setting new width based on dpr={$this->dpr} - w={$this->newWidth}\"); } if (!is_null($this->newHeight)) { $this->newHeight = round($this->newHeight * $this->dpr); $this->log(\"Setting new height based on dpr={$this->dpr} - h={$this->newHeight}\"); } } is_null($this->newWidth) or is_numeric($this->newWidth) or $this->raiseError('Width not numeric'); is_null($this->newHeight) or is_numeric($this->newHeight) or $this->raiseError('Height not numeric'); $this->log(\"Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\"); return $this; } public function calculateNewWidthAndHeight() { $this->log(\"Calculate new width and height.\"); $this->log(\"Original width x height is {$this->width} x {$this->height}.\"); $this->log(\"Target dimension (before calculating) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.\"); if (isset($this->area)) { $this->offset['top'] = round($this->area['top'] / 100 * $this->height); $this->offset['right'] = round($this->area['right'] / 100 * $this->width); $this->offset['bottom'] = round($this->area['bottom'] / 100 * $this->height); $this->offset['left'] = round($this->area['left'] / 100 * $this->width); $this->offset['width'] = $this->width - $this->offset['left'] - $this->offset['right']; $this->offset['height'] = $this->height - $this->offset['top'] - $this->offset['bottom']; $this->width = $this->offset['width']; $this->height = $this->offset['height']; $this->log(\"The offset for the area to use is top {$this->area['top']}%, right {$this->area['right']}%, bottom {$this->area['bottom']}%, left {$this->area['left']}%.\"); $this->log(\"The offset for the area to use is top {$this->offset['top']}px, right {$this->offset['right']}px, bottom {$this->offset['bottom']}px, left {$this->offset['left']}px, width {$this->offset['width']}px, height {$this->offset['height']}px.\"); } $width = $this->width; $height = $this->height; if ($this->crop) { $width = $this->crop['width'] = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width']; $height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height']; if ($this->crop['start_x'] == 'left') { $this->crop['start_x'] = 0; } elseif ($this->crop['start_x'] == 'right') { $this->crop['start_x'] = $this->width - $width; } elseif ($this->crop['start_x'] == 'center') { $this->crop['start_x'] = round($this->width / 2) - round($width / 2); } if ($this->crop['start_y'] == 'top') { $this->crop['start_y'] = 0; } elseif ($this->crop['start_y'] == 'bottom') { $this->crop['start_y'] = $this->height - $height; } elseif ($this->crop['start_y'] == 'center') { $this->crop['start_y'] = round($this->height / 2) - round($height / 2); } $this->log(\"Crop area is width {$width}px, height {$height}px, start_x {$this->crop['start_x']}px, start_y {$this->crop['start_y']}px.\"); } if ($this->keepRatio) { $this->log(\"Keep aspect ratio.\"); if (($this->cropToFit || $this->fillToFit) && isset($this->newWidth) && isset($this->newHeight)) { $this->log(\"Use newWidth and newHeigh as width/height, image should fit in box.\"); } elseif (isset($this->newWidth) && isset($this->newHeight)) { $ratioWidth = $width / $this->newWidth; $ratioHeight = $height / $this->newHeight; $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight; $this->newWidth = round($width / $ratio); $this->newHeight = round($height / $ratio); $this->log(\"New width and height was set.\"); } elseif (isset($this->newWidth)) { $factor = (float)$this->newWidth / (float)$width; $this->newHeight = round($factor * $height); $this->log(\"New width was set.\"); } elseif (isset($this->newHeight)) { $factor = (float)$this->newHeight / (float)$height; $this->newWidth = round($factor * $width); $this->log(\"New height was set.\"); } else { $this->newWidth = $width; $this->newHeight = $height; } if ($this->cropToFit || $this->fillToFit) { $ratioWidth = $width / $this->newWidth; $ratioHeight = $height / $this->newHeight; if ($this->cropToFit) { $this->log(\"Crop to fit.\"); $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight; $this->cropWidth = round($width / $ratio); $this->cropHeight = round($height / $ratio); $this->log(\"Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).\"); } elseif ($this->fillToFit) { $this->log(\"Fill to fit.\"); $ratio = ($ratioWidth < $ratioHeight) ? $ratioHeight : $ratioWidth; $this->fillWidth = round($width / $ratio); $this->fillHeight = round($height / $ratio); $this->log(\"Fill width, height, ratio: $this->fillWidth x $this->fillHeight ($ratio).\"); } } } if ($this->crop) { $this->log(\"Crop.\"); $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->crop['width']); $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->crop['height']); } $this->newWidth = round(isset($this->newWidth) ? $this->newWidth : $this->width); $this->newHeight = round(isset($this->newHeight) ? $this->newHeight : $this->height); $this->log(\"Calculated new width x height as {$this->newWidth} x {$this->newHeight}.\"); return $this; } public function reCalculateDimensions() { $this->log(\"Re-calculate image dimensions, newWidth x newHeigh was: \" . $this->newWidth . \" x \" . $this->newHeight); $this->newWidth = $this->newWidthOrig; $this->newHeight = $this->newHeightOrig; $this->crop = $this->cropOrig; $this->initDimensions() ->calculateNewWidthAndHeight(); return $this; } public function setSaveAsExtension($saveAs = null) { if (isset($saveAs)) { $saveAs = strtolower($saveAs); $this->checkFileExtension($saveAs); $this->saveAs = $saveAs; $this->extension = $saveAs; } $this->log(\"Prepare to save image as: \" . $this->extension); return $this; } public function setJpegQuality($quality = null) { if ($quality) { $this->useQuality = true; } $this->quality = isset($quality) ? $quality : self::JPEG_QUALITY_DEFAULT; (is_numeric($this->quality) and $this->quality > 0 and $this->quality <= 100) or $this->raiseError('Quality not in range.'); $this->log(\"Setting JPEG quality to {$this->quality}.\"); return $this; } public function setPngCompression($compress = null) { if ($compress) { $this->useCompress = true; } $this->compress = isset($compress) ? $compress : self::PNG_COMPRESSION_DEFAULT; (is_numeric($this->compress) and $this->compress >= -1 and $this->compress <= 9) or $this->raiseError('Quality not in range.'); $this->log(\"Setting PNG compression level to {$this->compress}.\"); return $this; } public function useOriginalIfPossible($useOrig = true) { if ($useOrig && ($this->newWidth == $this->width) && ($this->newHeight == $this->height) && !$this->area && !$this->crop && !$this->cropToFit && !$this->fillToFit && !$this->filters && !$this->sharpen && !$this->emboss && !$this->blur && !$this->convolve && !$this->palette && !$this->useQuality && !$this->useCompress && !$this->saveAs && !$this->rotateBefore && !$this->rotateAfter && !$this->autoRotate && !$this->bgColor && ($this->upscale === self::UPSCALE_DEFAULT) && !$this->lossy ) { $this->log(\"Using original image.\"); $this->output($this->pathToImage); } return $this; } public function generateFilename($base = null, $useSubdir = true, $prefix = null) { $filename = basename($this->pathToImage); $cropToFit = $this->cropToFit ? '_cf' : null; $fillToFit = $this->fillToFit ? '_ff' : null; $crop_x = $this->crop_x ? \"_x{$this->crop_x}\" : null; $crop_y = $this->crop_y ? \"_y{$this->crop_y}\" : null; $scale = $this->scale ? \"_s{$this->scale}\" : null; $bgColor = $this->bgColor ? \"_bgc{$this->bgColor}\" : null; $quality = $this->quality ? \"_q{$this->quality}\" : null; $compress = $this->compress ? \"_co{$this->compress}\" : null; $rotateBefore = $this->rotateBefore ? \"_rb{$this->rotateBefore}\" : null; $rotateAfter = $this->rotateAfter ? \"_ra{$this->rotateAfter}\" : null; $lossy = $this->lossy ? \"_l\" : null; $interlace = $this->interlace ? \"_i\" : null; $saveAs = $this->normalizeFileExtension(); $saveAs = $saveAs ? \"_$saveAs\" : null; $copyStrat = null; if ($this->copyStrategy === self::RESIZE) { $copyStrat = \"_rs\"; } $width = $this->newWidth ? '_' . $this->newWidth : null; $height = $this->newHeight ? '_' . $this->newHeight : null; $offset = isset($this->offset) ? '_o' . $this->offset['top'] . '-' . $this->offset['right'] . '-' . $this->offset['bottom'] . '-' . $this->offset['left'] : null; $crop = $this->crop ? '_c' . $this->crop['width'] . '-' . $this->crop['height'] . '-' . $this->crop['start_x'] . '-' . $this->crop['start_y'] : null; $filters = null; if (isset($this->filters)) { foreach ($this->filters as $filter) { if (is_array($filter)) { $filters .= \"_f{$filter['id']}\"; for ($i=1; $i<=$filter['argc']; $i++) { $filters .= \"-\".$filter[\"arg{$i}\"]; } } } } $sharpen = $this->sharpen ? 's' : null; $emboss = $this->emboss ? 'e' : null; $blur = $this->blur ? 'b' : null; $palette = $this->palette ? 'p' : null; $autoRotate = $this->autoRotate ? 'ar' : null; $optimize = $this->jpegOptimize ? 'o' : null; $optimize .= $this->pngFilter ? 'f' : null; $optimize .= $this->pngDeflate ? 'd' : null; $convolve = null; if ($this->convolve) { $convolve = '_conv' . preg_replace('/[^a-zA-Z0-9]/', '', $this->convolve); } $upscale = null; if ($this->upscale !== self::UPSCALE_DEFAULT) { $upscale = '_nu'; } $subdir = null; if ($useSubdir === true) { $subdir = str_replace('/', '-', dirname($this->imageSrc)); $subdir = ($subdir == '.') ? '_.' : $subdir; $subdir .= '_'; } $file = $prefix . $subdir . $filename . $width . $height . $offset . $crop . $cropToFit . $fillToFit . $crop_x . $crop_y . $upscale . $quality . $filters . $sharpen . $emboss . $blur . $palette . $optimize . $compress . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor . $convolve . $copyStrat . $lossy . $interlace . $saveAs; return $this->setTarget($file, $base); } public function useCacheIfPossible($useCache = true) { if ($useCache && is_readable($this->cacheFileName)) { $fileTime = filemtime($this->pathToImage); $cacheTime = filemtime($this->cacheFileName); if ($fileTime <= $cacheTime) { if ($this->useCache) { if ($this->verbose) { $this->log(\"Use cached file.\"); $this->log(\"Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\"); } $this->output($this->cacheFileName, $this->outputFormat); } else { $this->log(\"Cache is valid but ignoring it by intention.\"); } } else { $this->log(\"Original file is modified, ignoring cache.\"); } } else { $this->log(\"Cachefile does not exists or ignoring it.\"); } return $this; } public function load($src = null, $dir = null) { if (isset($src)) { $this->setSource($src, $dir); } $this->loadImageDetails(); if ($this->fileType === IMG_WEBP) { $this->image = imagecreatefromwebp($this->pathToImage); } else { $imageAsString = file_get_contents($this->pathToImage); $this->image = imagecreatefromstring($imageAsString); } if ($this->image === false) { throw new Exception(\"Could not load image.\"); } if ($this->verbose) { $this->log(\"### Image successfully loaded from file.\"); $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false')); $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image)); $this->log(\" Number of colors in image = \" . $this->colorsTotal($this->image)); $index = imagecolortransparent($this->image); $this->log(\" Detected transparent color = \" . ($index >= 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\"); } return $this; } public function getPngType($filename = null) { $filename = $filename ? $filename : $this->pathToImage; $pngType = ord(file_get_contents($filename, false, null, 25, 1)); if ($this->verbose) { $this->log(\"Checking png type of: \" . $filename); $this->log($this->getPngTypeAsString($pngType)); } return $pngType; } private function getPngTypeAsString($pngType = null, $filename = null) { if ($filename || !$pngType) { $pngType = $this->getPngType($filename); } $index = imagecolortransparent($this->image); $transparent = null; if ($index != -1) { $transparent = \" (transparent)\"; } switch ($pngType) { case self::PNG_GREYSCALE: $text = \"PNG is type 0, Greyscale$transparent\"; break; case self::PNG_RGB: $text = \"PNG is type 2, RGB$transparent\"; break; case self::PNG_RGB_PALETTE: $text = \"PNG is type 3, RGB with palette$transparent\"; break; case self::PNG_GREYSCALE_ALPHA: $text = \"PNG is type 4, Greyscale with alpha channel\"; break; case self::PNG_RGB_ALPHA: $text = \"PNG is type 6, RGB with alpha channel (PNG 32-bit)\"; break; default: $text = \"PNG is UNKNOWN type, is it really a PNG image?\"; } return $text; } private function colorsTotal($im) { if (imageistruecolor($im)) { $this->log(\"Colors as true color.\"); $h = imagesy($im); $w = imagesx($im); $c = array(); for ($x=0; $x < $w; $x++) { for ($y=0; $y < $h; $y++) { @$c['c'.imagecolorat($im, $x, $y)]++; } } return count($c); } else { $this->log(\"Colors as palette.\"); return imagecolorstotal($im); } } public function preResize() { $this->log(\"### Pre-process before resizing\"); if ($this->rotateBefore) { $this->log(\"Rotating image.\"); $this->rotate($this->rotateBefore, $this->bgColor) ->reCalculateDimensions(); } if ($this->autoRotate) { $this->log(\"Auto rotating image.\"); $this->rotateExif() ->reCalculateDimensions(); } if (isset($this->scale)) { $this->log(\"Scale by {$this->scale}%\"); $newWidth = $this->width * $this->scale / 100; $newHeight = $this->height * $this->scale / 100; $img = $this->CreateImageKeepTransparency($newWidth, $newHeight); imagecopyresampled($img, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height); $this->image = $img; $this->width = $newWidth; $this->height = $newHeight; } return $this; } public function setCopyResizeStrategy($strategy) { $this->copyStrategy = $strategy; return $this; } public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) { if($this->copyStrategy == self::RESIZE) { $this->log(\"Copy by resize\"); imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); } else { $this->log(\"Copy by resample\"); imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); } } public function resize() { $this->log(\"### Starting to Resize()\"); $this->log(\"Upscale = '$this->upscale'\"); if (isset($this->offset)) { $this->log(\"Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}\"); $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']); imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']); $this->image = $img; $this->width = $this->offset['width']; $this->height = $this->offset['height']; } if ($this->crop) { $this->log(\"Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}\"); $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']); imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']); $this->image = $img; $this->width = $this->crop['width']; $this->height = $this->crop['height']; } if (!$this->upscale) { } if ($this->cropToFit) { $this->log(\"Resizing using strategy - Crop to fit\"); if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight)) { $this->log(\"Resizing - smaller image, do not upscale.\"); $posX = 0; $posY = 0; $cropX = 0; $cropY = 0; if ($this->newWidth > $this->width) { $posX = round(($this->newWidth - $this->width) / 2); } if ($this->newWidth < $this->width) { $cropX = round(($this->width/2) - ($this->newWidth/2)); } if ($this->newHeight > $this->height) { $posY = round(($this->newHeight - $this->height) / 2); } if ($this->newHeight < $this->height) { $cropY = round(($this->height/2) - ($this->newHeight/2)); } $this->log(\" cwidth: $this->cropWidth\"); $this->log(\" cheight: $this->cropHeight\"); $this->log(\" nwidth: $this->newWidth\"); $this->log(\" nheight: $this->newHeight\"); $this->log(\" width: $this->width\"); $this->log(\" height: $this->height\"); $this->log(\" posX: $posX\"); $this->log(\" posY: $posY\"); $this->log(\" cropX: $cropX\"); $this->log(\" cropY: $cropY\"); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height); } else { $cropX = round(($this->cropWidth/2) - ($this->newWidth/2)); $cropY = round(($this->cropHeight/2) - ($this->newHeight/2)); $imgPreCrop = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $this->imageCopyResampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height); imagecopy($imageResized, $imgPreCrop, 0, 0, $cropX, $cropY, $this->newWidth, $this->newHeight); } $this->image = $imageResized; $this->width = $this->newWidth; $this->height = $this->newHeight; } elseif ($this->fillToFit) { $this->log(\"Resizing using strategy - Fill to fit\"); $posX = 0; $posY = 0; $ratioOrig = $this->width / $this->height; $ratioNew = $this->newWidth / $this->newHeight; if ($ratioOrig < $ratioNew) { $posX = round(($this->newWidth - $this->fillWidth) / 2); } else { $posY = round(($this->newHeight - $this->fillHeight) / 2); } if (!$this->upscale && ($this->width < $this->newWidth && $this->height < $this->newHeight) ) { $this->log(\"Resizing - smaller image, do not upscale.\"); $posX = round(($this->newWidth - $this->width) / 2); $posY = round(($this->newHeight - $this->height) / 2); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height); } else { $imgPreFill = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $this->imageCopyResampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height); imagecopy($imageResized, $imgPreFill, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight); } $this->image = $imageResized; $this->width = $this->newWidth; $this->height = $this->newHeight; } elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) { $this->log(\"Resizing, new height and/or width\"); if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight) ) { $this->log(\"Resizing - smaller image, do not upscale.\"); if (!$this->keepRatio) { $this->log(\"Resizing - stretch to fit selected.\"); $posX = 0; $posY = 0; $cropX = 0; $cropY = 0; if ($this->newWidth > $this->width && $this->newHeight > $this->height) { $posX = round(($this->newWidth - $this->width) / 2); $posY = round(($this->newHeight - $this->height) / 2); } elseif ($this->newWidth > $this->width) { $posX = round(($this->newWidth - $this->width) / 2); $cropY = round(($this->height - $this->newHeight) / 2); } elseif ($this->newHeight > $this->height) { $posY = round(($this->newHeight - $this->height) / 2); $cropX = round(($this->width - $this->newWidth) / 2); } $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height); $this->image = $imageResized; $this->width = $this->newWidth; $this->height = $this->newHeight; } } else { $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $this->imageCopyResampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height); $this->image = $imageResized; $this->width = $this->newWidth; $this->height = $this->newHeight; } } return $this; } public function postResize() { $this->log(\"### Post-process after resizing\"); if ($this->rotateAfter) { $this->log(\"Rotating image.\"); $this->rotate($this->rotateAfter, $this->bgColor); } if (isset($this->filters) && is_array($this->filters)) { foreach ($this->filters as $filter) { $this->log(\"Applying filter {$filter['type']}.\"); switch ($filter['argc']) { case 0: imagefilter($this->image, $filter['type']); break; case 1: imagefilter($this->image, $filter['type'], $filter['arg1']); break; case 2: imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2']); break; case 3: imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3']); break; case 4: imagefilter($this->image, $filter['type'], $filter['arg1'], $filter['arg2'], $filter['arg3'], $filter['arg4']); break; } } } if ($this->palette) { $this->log(\"Converting to palette image.\"); $this->trueColorToPalette(); } if ($this->blur) { $this->log(\"Blur.\"); $this->blurImage(); } if ($this->emboss) { $this->log(\"Emboss.\"); $this->embossImage(); } if ($this->sharpen) { $this->log(\"Sharpen.\"); $this->sharpenImage(); } if ($this->convolve) { $this->imageConvolution(); } return $this; } public function rotate($angle, $bgColor) { $this->log(\"Rotate image \" . $angle . \" degrees with filler color.\"); $color = $this->getBackgroundColor(); $this->image = imagerotate($this->image, $angle, $color); $this->width = imagesx($this->image); $this->height = imagesy($this->image); $this->log(\"New image dimension width x height: \" . $this->width . \" x \" . $this->height); return $this; } public function rotateExif() { if (!in_array($this->fileType, array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) { $this->log(\"Autorotate ignored, EXIF not supported by this filetype.\"); return $this; } $exif = exif_read_data($this->pathToImage); if (!empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 3: $this->log(\"Autorotate 180.\"); $this->rotate(180, $this->bgColor); break; case 6: $this->log(\"Autorotate -90.\"); $this->rotate(-90, $this->bgColor); break; case 8: $this->log(\"Autorotate 90.\"); $this->rotate(90, $this->bgColor); break; default: $this->log(\"Autorotate ignored, unknown value as orientation.\"); } } else { $this->log(\"Autorotate ignored, no orientation in EXIF.\"); } return $this; } public function trueColorToPalette() { $img = imagecreatetruecolor($this->width, $this->height); $bga = imagecolorallocatealpha($img, 0, 0, 0, 127); imagecolortransparent($img, $bga); imagefill($img, 0, 0, $bga); imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height); imagetruecolortopalette($img, false, 255); imagesavealpha($img, true); if (imageistruecolor($this->image)) { $this->log(\"Matching colors with true color image.\"); imagecolormatch($this->image, $img); } $this->image = $img; } public function sharpenImage() { $this->imageConvolution('sharpen'); return $this; } public function embossImage() { $this->imageConvolution('emboss'); return $this; } public function blurImage() { $this->imageConvolution('blur'); return $this; } public function createConvolveArguments($expression) { if (isset($this->convolves[$expression])) { $expression = $this->convolves[$expression]; } $part = explode(',', $expression); $this->log(\"Creating convolution expressen: $expression\"); if (count($part) != 11) { throw new Exception( \"Missmatch in argument convolve. Expected comma-separated string with\n                11 float values. Got $expression.\" ); } array_walk($part, function ($item, $key) { if (!is_numeric($item)) { throw new Exception(\"Argument to convolve expression should be float but is not.\"); } }); return array( array( array($part[0], $part[1], $part[2]), array($part[3], $part[4], $part[5]), array($part[6], $part[7], $part[8]), ), $part[9], $part[10], ); } public function addConvolveExpressions($options) { $this->convolves = array_merge($this->convolves, $options); return $this; } public function imageConvolution($options = null) { $options = $options ? $options : $this->convolve; $this->log(\"Convolution with '$options'\"); $options = explode(\":\", $options); foreach ($options as $option) { list($matrix, $divisor, $offset) = $this->createConvolveArguments($option); imageconvolution($this->image, $matrix, $divisor, $offset); } return $this; } public function setDefaultBackgroundColor($color) { $this->log(\"Setting default background color to '$color'.\"); if (!(strlen($color) == 6 || strlen($color) == 8)) { throw new Exception( \"Background color needs a hex value of 6 or 8\n                digits. 000000-FFFFFF or 00000000-FFFFFF7F.\n                Current value was: '$color'.\" ); } $red = hexdec(substr($color, 0, 2)); $green = hexdec(substr($color, 2, 2)); $blue = hexdec(substr($color, 4, 2)); $alpha = (strlen($color) == 8) ? hexdec(substr($color, 6, 2)) : null; if (($red < 0 || $red > 255) || ($green < 0 || $green > 255) || ($blue < 0 || $blue > 255) || ($alpha < 0 || $alpha > 127) ) { throw new Exception( \"Background color out of range. Red, green blue\n                should be 00-FF and alpha should be 00-7F.\n                Current value was: '$color'.\" ); } $this->bgColor = strtolower($color); $this->bgColorDefault = array( 'red' => $red, 'green' => $green, 'blue' => $blue, 'alpha' => $alpha ); return $this; } private function getBackgroundColor($img = null) { $img = isset($img) ? $img : $this->image; if ($this->bgColorDefault) { $red = $this->bgColorDefault['red']; $green = $this->bgColorDefault['green']; $blue = $this->bgColorDefault['blue']; $alpha = $this->bgColorDefault['alpha']; if ($alpha) { $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha); } else { $color = imagecolorallocate($img, $red, $green, $blue); } return $color; } else { return 0; } } private function createImageKeepTransparency($width, $height) { $this->log(\"Creating a new working image width={$width}px, height={$height}px.\"); $img = imagecreatetruecolor($width, $height); imagealphablending($img, false); imagesavealpha($img, true); $index = $this->image ? imagecolortransparent($this->image) : -1; if ($index != -1) { imagealphablending($img, true); $transparent = imagecolorsforindex($this->image, $index); $color = imagecolorallocatealpha($img, $transparent['red'], $transparent['green'], $transparent['blue'], $transparent['alpha']); imagefill($img, 0, 0, $color); $index = imagecolortransparent($img, $color); $this->Log(\"Detected transparent color = \" . implode(\", \", $transparent) . \" at index = $index\"); } elseif ($this->bgColorDefault) { $color = $this->getBackgroundColor($img); imagefill($img, 0, 0, $color); $this->Log(\"Filling image with background color.\"); } return $img; } public function setPostProcessingOptions($options) { if (isset($options['jpeg_optimize']) && $options['jpeg_optimize']) { $this->jpegOptimizeCmd = $options['jpeg_optimize_cmd']; } else { $this->jpegOptimizeCmd = null; } if (array_key_exists(\"png_lossy\", $options) && $options['png_lossy'] !== false) { $this->pngLossy = $options['png_lossy']; $this->pngLossyCmd = $options['png_lossy_cmd']; } else { $this->pngLossyCmd = null; } if (isset($options['png_filter']) && $options['png_filter']) { $this->pngFilterCmd = $options['png_filter_cmd']; } else { $this->pngFilterCmd = null; } if (isset($options['png_deflate']) && $options['png_deflate']) { $this->pngDeflateCmd = $options['png_deflate_cmd']; } else { $this->pngDeflateCmd = null; } return $this; } protected function getTargetImageExtension() { if (isset($this->extension)) { return strtolower($this->extension); } elseif ($this->fileType === IMG_WEBP) { return \"webp\"; } return substr(image_type_to_extension($this->fileType), 1); } public function save($src = null, $base = null, $overwrite = true) { if (isset($src)) { $this->setTarget($src, $base); } if ($overwrite === false && is_file($this->cacheFileName)) { $this->Log(\"Not overwriting file since its already exists and \\$overwrite if false.\"); return; } if (!defined(\"WINDOWS2WSL\")) { is_writable($this->saveFolder) or $this->raiseError('Target directory is not writable.'); } $type = $this->getTargetImageExtension(); $this->Log(\"Saving image as \" . $type); switch($type) { case 'jpeg': case 'jpg': if ($this->interlace) { $this->Log(\"Set JPEG image to be interlaced.\"); $res = imageinterlace($this->image, true); } $this->Log(\"Saving image as JPEG to cache using quality = {$this->quality}.\"); imagejpeg($this->image, $this->cacheFileName, $this->quality); if ($this->jpegOptimizeCmd) { if ($this->verbose) { clearstatcache(); $this->log(\"Filesize before optimize: \" . filesize($this->cacheFileName) . \" bytes.\"); } $res = array(); $cmd = $this->jpegOptimizeCmd . \" -outfile $this->cacheFileName $this->cacheFileName\"; exec($cmd, $res); $this->log($cmd); $this->log($res); } break; case 'gif': $this->Log(\"Saving image as GIF to cache.\"); imagegif($this->image, $this->cacheFileName); break; case 'webp': $this->Log(\"Saving image as WEBP to cache using quality = {$this->quality}.\"); imagewebp($this->image, $this->cacheFileName, $this->quality); break; case 'png': default: $this->Log(\"Saving image as PNG to cache using compression = {$this->compress}.\"); imagealphablending($this->image, false); imagesavealpha($this->image, true); imagepng($this->image, $this->cacheFileName, $this->compress); $lossyEnabled = $this->pngLossy === true; $lossySoftEnabled = $this->pngLossy === null; $lossyActiveEnabled = $this->lossy === true; if ($lossyEnabled || ($lossySoftEnabled && $lossyActiveEnabled)) { if ($this->verbose) { clearstatcache(); $this->log(\"Lossy enabled: $lossyEnabled\"); $this->log(\"Lossy soft enabled: $lossySoftEnabled\"); $this->Log(\"Filesize before lossy optimize: \" . filesize($this->cacheFileName) . \" bytes.\"); } $res = array(); $cmd = $this->pngLossyCmd . \" $this->cacheFileName $this->cacheFileName\"; exec($cmd, $res); $this->Log($cmd); $this->Log($res); } if ($this->pngFilterCmd) { if ($this->verbose) { clearstatcache(); $this->Log(\"Filesize before filter optimize: \" . filesize($this->cacheFileName) . \" bytes.\"); } $res = array(); $cmd = $this->pngFilterCmd . \" $this->cacheFileName\"; exec($cmd, $res); $this->Log($cmd); $this->Log($res); } if ($this->pngDeflateCmd) { if ($this->verbose) { clearstatcache(); $this->Log(\"Filesize before deflate optimize: \" . filesize($this->cacheFileName) . \" bytes.\"); } $res = array(); $cmd = $this->pngDeflateCmd . \" $this->cacheFileName\"; exec($cmd, $res); $this->Log($cmd); $this->Log($res); } break; } if ($this->verbose) { clearstatcache(); $this->log(\"Saved image to cache.\"); $this->log(\" Cached image filesize: \" . filesize($this->cacheFileName) . \" bytes.\"); $this->log(\" imageistruecolor() : \" . (imageistruecolor($this->image) ? 'true' : 'false')); $this->log(\" imagecolorstotal() : \" . imagecolorstotal($this->image)); $this->log(\" Number of colors in image = \" . $this->ColorsTotal($this->image)); $index = imagecolortransparent($this->image); $this->log(\" Detected transparent color = \" . ($index > 0 ? implode(\", \", imagecolorsforindex($this->image, $index)) : \"NONE\") . \" at index = $index\"); } return $this; } public function convert2sRGBColorSpace($src, $dir, $cache, $iccFile, $useCache = true) { if ($this->verbose) { $this->log(\"# Converting image to sRGB colorspace.\"); } if (!class_exists(\"Imagick\")) { $this->log(\" Ignoring since Imagemagick is not installed.\"); return false; } $this->setSaveFolder($cache) ->setSource($src, $dir) ->generateFilename(null, false, 'srgb_'); if ($useCache && is_readable($this->cacheFileName)) { $fileTime = filemtime($this->pathToImage); $cacheTime = filemtime($this->cacheFileName); if ($fileTime <= $cacheTime) { $this->log(\" Using cached version: \" . $this->cacheFileName); return $this->cacheFileName; } } if (is_writable($this->saveFolder)) { $image = new Imagick($this->pathToImage); $colorspace = $image->getImageColorspace(); $this->log(\" Current colorspace: \" . $colorspace); $profiles = $image->getImageProfiles('*', false); $hasICCProfile = (array_search('icc', $profiles) !== false); $this->log(\" Has ICC color profile: \" . ($hasICCProfile ? \"YES\" : \"NO\")); if ($colorspace != Imagick::COLORSPACE_SRGB || $hasICCProfile) { $this->log(\" Converting to sRGB.\"); $sRGBicc = file_get_contents($iccFile); $image->profileImage('icc', $sRGBicc); $image->transformImageColorspace(Imagick::COLORSPACE_SRGB); $image->writeImage($this->cacheFileName); return $this->cacheFileName; } } return false; } public function linkToCacheFile($alias) { if ($alias === null) { $this->log(\"Ignore creating alias.\"); return $this; } if (is_readable($alias)) { unlink($alias); } $res = link($this->cacheFileName, $alias); if ($res) { $this->log(\"Created an alias as: $alias\"); } else { $this->log(\"Failed to create the alias: $alias\"); } return $this; } public function addHTTPHeader($type, $value) { $this->HTTPHeader[$type] = $value; } public function output($file = null, $format = null) { if (is_null($file)) { $file = $this->cacheFileName; } if (is_null($format)) { $format = $this->outputFormat; } $this->log(\"### Output\"); $this->log(\"Output format is: $format\"); if (!$this->verbose && $format == 'json') { header('Content-type: application/json'); echo $this->json($file); exit; } elseif ($format == 'ascii') { header('Content-type: text/plain'); echo $this->ascii($file); exit; } $this->log(\"Outputting image: $file\"); clearstatcache(); $lastModified = filemtime($file); $lastModifiedFormat = \"D, d M Y H:i:s\"; $gmdate = gmdate($lastModifiedFormat, $lastModified); if (!$this->verbose) { $header = \"Last-Modified: $gmdate GMT\"; header($header); $this->fastTrackCache->addHeader($header); $this->fastTrackCache->setLastModified($lastModified); } foreach ($this->HTTPHeader as $key => $val) { $header = \"$key: $val\"; header($header); $this->fastTrackCache->addHeader($header); } if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) { if ($this->verbose) { $this->log(\"304 not modified\"); $this->verboseOutput(); exit; } header(\"HTTP/1.0 304 Not Modified\"); if (CIMAGE_DEBUG) { trace(__CLASS__ . \" 304\"); } } else { $this->loadImageDetails($file); $mime = $this->getMimeType(); $size = filesize($file); if ($this->verbose) { $this->log(\"Last-Modified: \" . $gmdate . \" GMT\"); $this->log(\"Content-type: \" . $mime); $this->log(\"Content-length: \" . $size); $this->verboseOutput(); if (is_null($this->verboseFileName)) { exit; } } $header = \"Content-type: $mime\"; header($header); $this->fastTrackCache->addHeaderOnOutput($header); $header = \"Content-length: $size\"; header($header); $this->fastTrackCache->addHeaderOnOutput($header); $this->fastTrackCache->setSource($file); $this->fastTrackCache->writeToCache(); if (CIMAGE_DEBUG) { trace(__CLASS__ . \" 200\"); } readfile($file); } exit; } public function json($file = null) { $file = $file ? $file : $this->cacheFileName; $details = array(); clearstatcache(); $details['src'] = $this->imageSrc; $lastModified = filemtime($this->pathToImage); $details['srcGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified); $details['cache'] = basename($this->cacheFileName ?? \"\"); $lastModified = filemtime($this->cacheFileName ?? \"\"); $details['cacheGmdate'] = gmdate(\"D, d M Y H:i:s\", $lastModified); $this->load($file); $details['filename'] = basename($file ?? \"\"); $details['mimeType'] = $this->getMimeType($this->fileType); $details['width'] = $this->width; $details['height'] = $this->height; $details['aspectRatio'] = round($this->width / $this->height, 3); $details['size'] = filesize($file ?? \"\"); $details['colors'] = $this->colorsTotal($this->image); $details['includedFiles'] = count(get_included_files()); $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . \" MB\" ; $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . \" MB\"; $details['memoryLimit'] = ini_get('memory_limit'); if (isset($_SERVER['REQUEST_TIME_FLOAT'])) { $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . \"s\"; } if ($details['mimeType'] == 'image/png') { $details['pngType'] = $this->getPngTypeAsString(null, $file); } $options = null; if (defined(\"JSON_PRETTY_PRINT\") && defined(\"JSON_UNESCAPED_SLASHES\")) { $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES; } return json_encode($details, $options); } public function setAsciiOptions($options = array()) { $this->asciiOptions = $options; } public function ascii($file = null) { $file = $file ? $file : $this->cacheFileName; $asciiArt = new CAsciiArt(); $asciiArt->setOptions($this->asciiOptions); return $asciiArt->createFromFile($file); } public function log($message) { if ($this->verbose) { $this->log[] = $message; } return $this; } public function setVerboseToFile($fileName) { $this->log(\"Setting verbose output to file.\"); $this->verboseFileName = $fileName; } private function verboseOutput() { $log = null; $this->log(\"### Summary of verbose log\"); $this->log(\"As JSON: \\n\" . $this->json()); $this->log(\"Memory peak: \" . round(memory_get_peak_usage() /1024/1024) . \"M\"); $this->log(\"Memory limit: \" . ini_get('memory_limit')); $included = get_included_files(); $this->log(\"Included files: \" . count($included)); foreach ($this->log as $val) { if (is_array($val)) { foreach ($val as $val1) { $log .= htmlentities($val1) . '<br/>'; } } else { $log .= htmlentities($val) . '<br/>'; } } if (!is_null($this->verboseFileName)) { file_put_contents( $this->verboseFileName, str_replace(\"<br/>\", \"\\n\", $log) ); } else { echo <<<EOD\n<h1>CImage Verbose Output</h1>\n<pre>{$log}</pre>\nEOD;\n} } private function raiseError($message) { throw new Exception($message); } } class CCache { private $path; public function setDir($path) { if (!is_dir($path)) { throw new Exception(\"Cachedir is not a directory.\"); } $this->path = $path; return $this; } public function getPathToSubdir($subdir, $create = true) { $path = realpath($this->path . \"/\" . $subdir); if (is_dir($path)) { return $path; } if ($create && defined('WINDOWS2WSL')) { $path = $this->path . \"/\" . $subdir; if (mkdir($path)) { return realpath($path); } } if ($create && is_writable($this->path)) { $path = $this->path . \"/\" . $subdir; if (mkdir($path)) { return realpath($path); } } return false; } public function getStatusOfSubdir($subdir) { $path = realpath($this->path . \"/\" . $subdir); $exists = is_dir($path); $res = $exists ? \"exists\" : \"does not exist\"; if ($exists) { $res .= is_writable($path) ? \", writable\" : \", not writable\"; } return $res; } public function removeSubdir($subdir) { $path = realpath($this->path . \"/\" . $subdir); if (is_dir($path)) { return rmdir($path); } return null; } } class CFastTrackCache { private $enabled = false; private $path; private $filename; private $container; public function enable($enabled) { $this->enabled = $enabled; return $this; } public function setCacheDir($path) { if (!is_dir($path)) { throw new Exception(\"Cachedir is not a directory.\"); } $this->path = rtrim($path, \"/\"); return $this; } public function setFilename($clear) { $query = $_GET; foreach ($clear as $value) { unset($query[$value]); } arsort($query); $queryAsString = http_build_query($query); $this->filename = md5($queryAsString); if (CIMAGE_DEBUG) { $this->container[\"query-string\"] = $queryAsString; } return $this->filename; } public function addHeader($header) { $this->container[\"header\"][] = $header; return $this; } public function addHeaderOnOutput($header) { $this->container[\"header-output\"][] = $header; return $this; } public function setSource($source) { $this->container[\"source\"] = $source; return $this; } public function setLastModified($lastModified) { $this->container[\"last-modified\"] = $lastModified; return $this; } public function getFilename() { return $this->path . \"/\" . $this->filename; } public function writeToCache() { if (!$this->enabled) { return false; } if (is_dir($this->path) && is_writable($this->path)) { $filename = $this->getFilename(); return file_put_contents($filename, json_encode($this->container)) !== false; } return false; } public function output() { $filename = $this->getFilename(); if (!is_readable($filename)) { return; } $item = json_decode(file_get_contents($filename), true); if (!is_readable($item[\"source\"])) { return; } foreach ($item[\"header\"] as $value) { header($value); } if (isset($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"]) && strtotime($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"]) == $item[\"last-modified\"]) { header(\"HTTP/1.0 304 Not Modified\"); if (CIMAGE_DEBUG) { trace(__CLASS__ . \" 304\"); } exit; } foreach ($item[\"header-output\"] as $value) { header($value); } if (CIMAGE_DEBUG) { trace(__CLASS__ . \" 200\"); } readfile($item[\"source\"]); exit; } } set_exception_handler(function ($exception) { errorPage( \"<p><b>img.php: Uncaught exception:</b> <p>\" . $exception->getMessage() . \"</p><pre>\" . $exception->getTraceAsString() . \"</pre>\", 500 ); }); $configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php'; if (is_file($configFile)) { $config = require $configFile; } elseif (!isset($config)) { $config = array(); } if (!defined(\"CIMAGE_DEBUG\")) { define(\"CIMAGE_DEBUG\", false); } if (!defined(\"CIMAGE_BUNDLE\")) { if (!isset($config[\"autoloader\"])) { die(\"CImage: Missing autoloader.\"); } require $config[\"autoloader\"]; } $verbose = getDefined(array('verbose', 'v'), true, false); $verboseFile = getDefined('vf', true, false); verbose(\"img.php version = \" . CIMAGE_VERSION); $status = getDefined('status', true, false); $mode = getConfig('mode', 'production'); set_time_limit(20); ini_set('gd.jpeg_ignore_warning', 1); if (!extension_loaded('gd')) { errorPage(\"Extension gd is not loaded.\", 500); } if ($mode == 'strict') { error_reporting(0); ini_set('display_errors', 0); ini_set('log_errors', 1); $verbose = false; $status = false; $verboseFile = false; } elseif ($mode == 'production') { error_reporting(-1); ini_set('display_errors', 0); ini_set('log_errors', 1); $verbose = false; $status = false; $verboseFile = false; } elseif ($mode == 'development') { error_reporting(-1); ini_set('display_errors', 1); ini_set('log_errors', 0); $verboseFile = false; } elseif ($mode == 'test') { error_reporting(-1); ini_set('display_errors', 1); ini_set('log_errors', 0); } else { errorPage(\"Unknown mode: $mode\", 500); } verbose(\"mode = $mode\"); verbose(\"error log = \" . ini_get('error_log')); $defaultTimezone = getConfig('default_timezone', null); if ($defaultTimezone) { date_default_timezone_set($defaultTimezone); } elseif (!ini_get('default_timezone')) { date_default_timezone_set('UTC'); } $pwdConfig = getConfig('password', false); $pwdAlways = getConfig('password_always', false); $pwdType = getConfig('password_type', 'text'); $pwd = get(array('password', 'pwd'), null); $passwordMatch = null; if ($pwd) { switch ($pwdType) { case 'md5': $passwordMatch = ($pwdConfig === md5($pwd)); break; case 'hash': $passwordMatch = password_verify($pwd, $pwdConfig); break; case 'text': $passwordMatch = ($pwdConfig === $pwd); break; default: $passwordMatch = false; } } if ($pwdAlways && $passwordMatch !== true) { errorPage(\"Password required and does not match or exists.\", 403); } verbose(\"password match = $passwordMatch\"); $allowHotlinking = getConfig('allow_hotlinking', true); $hotlinkingWhitelist = getConfig('hotlinking_whitelist', array()); $serverName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $refererHost = parse_url($referer ?? \"\", PHP_URL_HOST); if (!$allowHotlinking) { if ($passwordMatch) { ; verbose(\"Hotlinking since passwordmatch\"); } elseif ($passwordMatch === false) { errorPage(\"Hotlinking/leeching not allowed when password missmatch.\", 403); } elseif (!$referer) { errorPage(\"Hotlinking/leeching not allowed and referer is missing.\", 403); } elseif (strcmp($serverName, $refererHost) == 0) { ; verbose(\"Hotlinking disallowed but serverName matches refererHost.\"); } elseif (!empty($hotlinkingWhitelist)) { $whitelist = new CWhitelist(); $allowedByWhitelist = $whitelist->check($refererHost, $hotlinkingWhitelist); if ($allowedByWhitelist) { verbose(\"Hotlinking/leeching allowed by whitelist.\"); } else { errorPage(\"Hotlinking/leeching not allowed by whitelist. Referer: $referer.\", 403); } } else { errorPage(\"Hotlinking/leeching not allowed.\", 403); } } verbose(\"allow_hotlinking = $allowHotlinking\"); verbose(\"referer = $referer\"); verbose(\"referer host = $refererHost\"); $CImage = getConfig('CImage', 'CImage'); $img = new $CImage(); $img->setVerbose($verbose || $verboseFile); $CCache = getConfig('CCache', 'CCache'); $cachePath = getConfig('cache_path', __DIR__ . '/../cache/'); $cache = new $CCache(); $cache->setDir($cachePath); $useCache = getDefined(array('no-cache', 'nc'), false, true); verbose(\"use cache = $useCache\"); $fastTrackCache = \"fasttrack\"; $allowFastTrackCache = getConfig('fast_track_allow', false); $CFastTrackCache = getConfig('CFastTrackCache', 'CFastTrackCache'); $ftc = new $CFastTrackCache(); $ftc->setCacheDir($cache->getPathToSubdir($fastTrackCache)) ->enable($allowFastTrackCache) ->setFilename(array('no-cache', 'nc')); $img->injectDependency(\"fastTrackCache\", $ftc); if ($useCache && $allowFastTrackCache) { if (CIMAGE_DEBUG) { trace(\"img.php fast track cache enabled and used\"); } $ftc->output(); } $allowRemote = getConfig('remote_allow', false); if ($allowRemote && $passwordMatch !== false) { $cacheRemote = $cache->getPathToSubdir(\"remote\"); $pattern = getConfig('remote_pattern', null); $img->setRemoteDownload($allowRemote, $cacheRemote, $pattern); $whitelist = getConfig('remote_whitelist', null); $img->setRemoteHostWhitelist($whitelist); } $shortcut = get(array('shortcut', 'sc'), null); $shortcutConfig = getConfig('shortcut', array( 'sepia' => \"&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen\", )); verbose(\"shortcut = $shortcut\"); if (isset($shortcut) && isset($shortcutConfig[$shortcut])) { parse_str($shortcutConfig[$shortcut], $get); verbose(\"shortcut-constant = {$shortcutConfig[$shortcut]}\"); $_GET = array_merge($_GET, $get); } $srcImage = urldecode(get('src', \"\")) or errorPage('Must set src-attribute.', 404); $srcAltImage = urldecode(get('src-alt', \"\")); $srcAltConfig = getConfig('src_alt', null); if (empty($srcAltImage)) { $srcAltImage = $srcAltConfig; } $imagePath = getConfig('image_path', __DIR__ . '/img/'); $imagePathConstraint = getConfig('image_path_constraint', true); $validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \\.:]+$#'); $remoteSource = false; $dummyEnabled = getConfig('dummy_enabled', true); $dummyFilename = getConfig('dummy_filename', 'dummy'); $dummyImage = false; preg_match($validFilename, $srcImage) or errorPage('Source filename contains invalid characters.', 404); if ($dummyEnabled && $srcImage === $dummyFilename) { $dummyImage = true; } elseif ($allowRemote && $img->isRemoteSource($srcImage)) { $remoteSource = true; } else { $pathToImage = realpath($imagePath . $srcImage); if (!is_file($pathToImage) && !empty($srcAltImage)) { $srcImage = $srcAltImage; $pathToImage = realpath($imagePath . $srcImage); preg_match($validFilename, $srcImage) or errorPage('Source (alt) filename contains invalid characters.', 404); if ($dummyEnabled && $srcImage === $dummyFilename) { $dummyImage = true; } } if (!$dummyImage) { is_file($pathToImage) or errorPage( 'Source image is not a valid file, check the filename and that a\n                matching file exists on the filesystem.', 404 ); } } if ($imagePathConstraint && !$dummyImage && !$remoteSource) { $imageDir = realpath($imagePath); substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0 or errorPage( 'Security constraint: Source image is not below the directory \"image_path\"\n            as specified in the config file img_config.php.', 404 ); } verbose(\"src = $srcImage\"); $sizeConstant = getConfig('size_constant', function () { $sizes = array( 'w1' => 613, 'w2' => 630, ); $gridColumnWidth = 30; $gridGutterWidth = 10; $gridColumns = 24; for ($i = 1; $i <= $gridColumns; $i++) { $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth; } return $sizes; }); $sizes = call_user_func($sizeConstant); $newWidth = get(array('width', 'w')); $maxWidth = getConfig('max_width', 2000); if (isset($sizes[$newWidth])) { $newWidth = $sizes[$newWidth]; } if ($newWidth && $newWidth[strlen($newWidth)-1] == '%') { is_numeric(substr($newWidth, 0, -1)) or errorPage('Width % not numeric.', 404); } else { is_null($newWidth) or ($newWidth > 10 && $newWidth <= $maxWidth) or errorPage('Width out of range.', 404); } verbose(\"new width = $newWidth\"); $newHeight = get(array('height', 'h')); $maxHeight = getConfig('max_height', 2000); if (isset($sizes[$newHeight])) { $newHeight = $sizes[$newHeight]; } if ($newHeight && $newHeight[strlen($newHeight)-1] == '%') { is_numeric(substr($newHeight, 0, -1)) or errorPage('Height % out of range.', 404); } else { is_null($newHeight) or ($newHeight > 10 && $newHeight <= $maxHeight) or errorPage('Height out of range.', 404); } verbose(\"new height = $newHeight\"); $aspectRatio = get(array('aspect-ratio', 'ar')); $aspectRatioConstant = getConfig('aspect_ratio_constant', function () { return array( '3:1' => 3/1, '3:2' => 3/2, '4:3' => 4/3, '8:5' => 8/5, '16:10' => 16/10, '16:9' => 16/9, 'golden' => 1.618, ); }); $aspectRatios = call_user_func($aspectRatioConstant); $negateAspectRatio = ($aspectRatio && $aspectRatio[0] == '!') ? true : false; $aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio; if (isset($aspectRatios[$aspectRatio])) { $aspectRatio = $aspectRatios[$aspectRatio]; } if ($negateAspectRatio) { $aspectRatio = 1 / $aspectRatio; } is_null($aspectRatio) or is_numeric($aspectRatio) or errorPage('Aspect ratio out of range', 404); verbose(\"aspect ratio = $aspectRatio\"); $cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false); verbose(\"crop to fit = $cropToFit\"); $backgroundColor = getConfig('background_color', null); if ($backgroundColor) { $img->setDefaultBackgroundColor($backgroundColor); verbose(\"Using default background_color = $backgroundColor\"); } $bgColor = get(array('bgColor', 'bg-color', 'bgc'), null); verbose(\"bgColor = $bgColor\"); $resizeStrategy = getDefined(array('no-resample'), true, false); if ($resizeStrategy) { $img->setCopyResizeStrategy($img::RESIZE); verbose(\"Setting = Resize instead of resample\"); } $fillToFit = get(array('fill-to-fit', 'ff'), null); verbose(\"fill-to-fit = $fillToFit\"); if ($fillToFit !== null) { if (!empty($fillToFit)) { $bgColor = $fillToFit; verbose(\"fillToFit changed bgColor to = $bgColor\"); } $fillToFit = true; verbose(\"fill-to-fit (fixed) = $fillToFit\"); } $keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true); verbose(\"keep ratio = $keepRatio\"); $crop = get(array('crop', 'c')); verbose(\"crop = $crop\"); $area = get(array('area', 'a')); verbose(\"area = $area\"); $useOriginal = getDefined(array('skip-original', 'so'), false, true); $useOriginalDefault = getConfig('skip_original', false); if ($useOriginalDefault === true) { verbose(\"skip original is default ON\"); $useOriginal = false; } verbose(\"use original = $useOriginal\"); $quality = get(array('quality', 'q')); $qualityDefault = getConfig('jpg_quality', null); is_null($quality) or ($quality > 0 and $quality <= 100) or errorPage('Quality out of range', 404); if (is_null($quality) && !is_null($qualityDefault)) { $quality = $qualityDefault; } verbose(\"quality = $quality\"); $compress = get(array('compress', 'co')); $compressDefault = getConfig('png_compression', null); is_null($compress) or ($compress > 0 and $compress <= 9) or errorPage('Compress out of range', 404); if (is_null($compress) && !is_null($compressDefault)) { $compress = $compressDefault; } verbose(\"compress = $compress\"); $saveAs = get(array('save-as', 'sa')); verbose(\"save as = $saveAs\"); $scale = get(array('scale', 's')); is_null($scale) or ($scale >= 0 and $scale <= 400) or errorPage('Scale out of range', 404); verbose(\"scale = $scale\"); $palette = getDefined(array('palette', 'p'), true, false); verbose(\"palette = $palette\"); $sharpen = getDefined('sharpen', true, null); verbose(\"sharpen = $sharpen\"); $emboss = getDefined('emboss', true, null); verbose(\"emboss = $emboss\"); $blur = getDefined('blur', true, null); verbose(\"blur = $blur\"); $rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb')); is_null($rotateBefore) or ($rotateBefore >= -360 and $rotateBefore <= 360) or errorPage('RotateBefore out of range', 404); verbose(\"rotateBefore = $rotateBefore\"); $rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r')); is_null($rotateAfter) or ($rotateAfter >= -360 and $rotateAfter <= 360) or errorPage('RotateBefore out of range', 404); verbose(\"rotateAfter = $rotateAfter\"); $autoRotate = getDefined(array('autoRotate', 'auto-rotate', 'aro'), true, false); verbose(\"autoRotate = $autoRotate\"); $filters = array(); $filter = get(array('filter', 'f')); if ($filter) { $filters[] = $filter; } for ($i = 0; $i < 10; $i++) { $filter = get(array(\"filter{$i}\", \"f{$i}\")); if ($filter) { $filters[] = $filter; } } verbose(\"filters = \" . print_r($filters, 1)); $outputFormat = getDefined('json', 'json', null); $outputFormat = getDefined('ascii', 'ascii', $outputFormat); verbose(\"outputformat = $outputFormat\"); if ($outputFormat == 'ascii') { $defaultOptions = getConfig( 'ascii-options', array( \"characterSet\" => 'two', \"scale\" => 14, \"luminanceStrategy\" => 3, \"customCharacterSet\" => null, ) ); $options = get('ascii'); $options = explode(',', $options); if (isset($options[0]) && !empty($options[0])) { $defaultOptions['characterSet'] = $options[0]; } if (isset($options[1]) && !empty($options[1])) { $defaultOptions['scale'] = $options[1]; } if (isset($options[2]) && !empty($options[2])) { $defaultOptions['luminanceStrategy'] = $options[2]; } if (count($options) > 3) { unset($options[0]); unset($options[1]); unset($options[2]); $characterString = implode($options); $defaultOptions['customCharacterSet'] = $characterString; } $img->setAsciiOptions($defaultOptions); } $dpr = get(array('ppi', 'dpr', 'device-pixel-ratio'), 1); verbose(\"dpr = $dpr\"); $convolve = get('convolve', null); $convolutionConstant = getConfig('convolution_constant', array()); if ($convolve && isset($convolutionConstant)) { $img->addConvolveExpressions($convolutionConstant); verbose(\"convolve constant = \" . print_r($convolutionConstant, 1)); } verbose(\"convolve = \" . print_r($convolve, 1)); $upscale = getDefined(array('no-upscale', 'nu'), false, true); verbose(\"upscale = $upscale\"); $postProcessing = getConfig('postprocessing', array( 'png_lossy' => false, 'png_lossy_cmd' => '/usr/local/bin/pngquant --force --output', 'png_filter' => false, 'png_filter_cmd' => '/usr/local/bin/optipng -q', 'png_deflate' => false, 'png_deflate_cmd' => '/usr/local/bin/pngout -q', 'jpeg_optimize' => false, 'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize', )); $lossy = getDefined(array('lossy'), true, null); verbose(\"lossy = $lossy\"); $alias = get('alias', null); $aliasPath = getConfig('alias_path', null); $validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#'); $aliasTarget = null; if ($alias && $aliasPath && $passwordMatch) { $aliasTarget = $aliasPath . $alias; $useCache = false; is_writable($aliasPath) or errorPage(\"Directory for alias is not writable.\", 403); preg_match($validAliasname, $alias) or errorPage('Filename for alias contains invalid characters. Do not add extension.', 404); } elseif ($alias) { errorPage('Alias is not enabled in the config file or password not matching.', 403); } verbose(\"alias = $alias\"); $cacheControl = getConfig('cache_control', null); if ($cacheControl) { verbose(\"cacheControl = $cacheControl\"); $img->addHTTPHeader(\"Cache-Control\", $cacheControl); } $interlaceConfig = getConfig('interlace', null); $interlaceValue = getValue('interlace', null); $interlaceDefined = getDefined('interlace', true, null); $interlace = $interlaceValue ?? $interlaceDefined ?? $interlaceConfig; verbose(\"interlace (configfile) = \", $interlaceConfig); verbose(\"interlace = \", $interlace); if ($dummyImage === true) { $dummyDir = $cache->getPathToSubdir(\"dummy\"); $img->setSaveFolder($dummyDir) ->setSource($dummyFilename, $dummyDir) ->setOptions( array( 'newWidth' => $newWidth, 'newHeight' => $newHeight, 'bgColor' => $bgColor, ) ) ->setJpegQuality($quality) ->setPngCompression($compress) ->createDummyImage() ->generateFilename(null, false) ->save(null, null, false); $srcImage = $img->getTarget(); $imagePath = null; verbose(\"src (updated) = $srcImage\"); } $srgbDefault = getConfig('srgb_default', false); $srgbColorProfile = getConfig('srgb_colorprofile', __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'); $srgb = getDefined('srgb', true, null); if ($srgb || $srgbDefault) { $filename = $img->convert2sRGBColorSpace( $srcImage, $imagePath, $cache->getPathToSubdir(\"srgb\"), $srgbColorProfile, $useCache ); if ($filename) { $srcImage = $img->getTarget(); $imagePath = null; verbose(\"srgb conversion and saved to cache = $srcImage\"); } else { verbose(\"srgb not op\"); } } if ($status) { $text = \"img.php version = \" . CIMAGE_VERSION . \"\\n\"; $text .= \"PHP version = \" . PHP_VERSION . \"\\n\"; $text .= \"Running on: \" . $_SERVER['SERVER_SOFTWARE'] . \"\\n\"; $text .= \"Allow remote images = $allowRemote\\n\"; $res = $cache->getStatusOfSubdir(\"\"); $text .= \"Cache $res\\n\"; $res = $cache->getStatusOfSubdir(\"remote\"); $text .= \"Cache remote $res\\n\"; $res = $cache->getStatusOfSubdir(\"dummy\"); $text .= \"Cache dummy $res\\n\"; $res = $cache->getStatusOfSubdir(\"srgb\"); $text .= \"Cache srgb $res\\n\"; $res = $cache->getStatusOfSubdir($fastTrackCache); $text .= \"Cache fasttrack $res\\n\"; $text .= \"Alias path writable = \" . is_writable($aliasPath) . \"\\n\"; $no = extension_loaded('exif') ? null : 'NOT'; $text .= \"Extension exif is $no loaded.<br>\"; $no = extension_loaded('curl') ? null : 'NOT'; $text .= \"Extension curl is $no loaded.<br>\"; $no = extension_loaded('imagick') ? null : 'NOT'; $text .= \"Extension imagick is $no loaded.<br>\"; $no = extension_loaded('gd') ? null : 'NOT'; $text .= \"Extension gd is $no loaded.<br>\"; $text .= checkExternalCommand(\"PNG LOSSY\", $postProcessing[\"png_lossy\"], $postProcessing[\"png_lossy_cmd\"]); $text .= checkExternalCommand(\"PNG FILTER\", $postProcessing[\"png_filter\"], $postProcessing[\"png_filter_cmd\"]); $text .= checkExternalCommand(\"PNG DEFLATE\", $postProcessing[\"png_deflate\"], $postProcessing[\"png_deflate_cmd\"]); $text .= checkExternalCommand(\"JPEG OPTIMIZE\", $postProcessing[\"jpeg_optimize\"], $postProcessing[\"jpeg_optimize_cmd\"]); if (!$no) { $text .= print_r(gd_info(), 1); } echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage status</title>\n<pre>$text</pre>\nEOD;\nexit; } if ($verboseFile) { $img->setVerboseToFile(\"$cachePath/log.txt\"); } $hookBeforeCImage = getConfig('hook_before_CImage', null); if (is_callable($hookBeforeCImage)) { verbose(\"hookBeforeCImage activated\"); $allConfig = $hookBeforeCImage($img, array( 'newWidth' => $newWidth, 'newHeight' => $newHeight, 'aspectRatio' => $aspectRatio, 'keepRatio' => $keepRatio, 'cropToFit' => $cropToFit, 'fillToFit' => $fillToFit, 'crop' => $crop, 'area' => $area, 'upscale' => $upscale, 'scale' => $scale, 'rotateBefore' => $rotateBefore, 'autoRotate' => $autoRotate, 'bgColor' => $bgColor, 'palette' => $palette, 'filters' => $filters, 'sharpen' => $sharpen, 'emboss' => $emboss, 'blur' => $blur, 'convolve' => $convolve, 'rotateAfter' => $rotateAfter, 'interlace' => $interlace, 'outputFormat' => $outputFormat, 'dpr' => $dpr, 'postProcessing' => $postProcessing, 'lossy' => $lossy, )); verbose(print_r($allConfig, 1)); extract($allConfig); } if ($verbose) { $query = array(); parse_str($_SERVER['QUERY_STRING'], $query); unset($query['verbose']); unset($query['v']); unset($query['nocache']); unset($query['nc']); unset($query['json']); $url1 = '?' . htmlentities(urldecode(http_build_query($query))); $url2 = '?' . urldecode(http_build_query($query)); echo <<<EOD\n<!doctype html>\n<html lang=en>\n<meta charset=utf-8>\n<title>CImage verbose output</title>\n<style>body{background-color: #ddd}</style>\n<a href=$url1><code>$url1</code></a><br>\n<img src='{$url1}' />\n<pre id=\"json\"></pre>\n<script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\\\nmime type: \" + data.mimeType + \"\\\\ncolors: \" + data.colors + \"\\\\nsize: \" + data.size + \"\\\\nwidth: \" + data.width + \"\\\\nheigh: \" + data.height + \"\\\\naspect-ratio: \" + data.aspectRatio + ( data.pngType ? \"\\\\npng-type: \" + data.pngType : '');\n  });\n}\n</script>\n<script type=\"text/javascript\">window.getDetails(\"{$url2}&json\", \"json\")</script>\nEOD;\n} $img->log(\"PHP version: \" . phpversion()) ->log(\"Incoming arguments: \" . print_r(verbose(), 1)) ->setSaveFolder($cachePath) ->useCache($useCache) ->setSource($srcImage, $imagePath) ->setOptions( array( 'newWidth' => $newWidth, 'newHeight' => $newHeight, 'aspectRatio' => $aspectRatio, 'keepRatio' => $keepRatio, 'cropToFit' => $cropToFit, 'fillToFit' => $fillToFit, 'crop' => $crop, 'area' => $area, 'upscale' => $upscale, 'scale' => $scale, 'rotateBefore' => $rotateBefore, 'autoRotate' => $autoRotate, 'bgColor' => $bgColor, 'palette' => $palette, 'filters' => $filters, 'sharpen' => $sharpen, 'emboss' => $emboss, 'blur' => $blur, 'convolve' => $convolve, 'rotateAfter' => $rotateAfter, 'interlace' => $interlace, 'outputFormat' => $outputFormat, 'dpr' => $dpr, 'lossy' => $lossy, ) ) ->loadImageDetails() ->initDimensions() ->calculateNewWidthAndHeight() ->setSaveAsExtension($saveAs) ->setJpegQuality($quality) ->setPngCompression($compress) ->useOriginalIfPossible($useOriginal) ->generateFilename($cachePath) ->useCacheIfPossible($useCache) ->load() ->preResize() ->resize() ->postResize() ->setPostProcessingOptions($postProcessing) ->save() ->linkToCacheFile($aliasTarget) ->output(); "
  },
  {
    "path": "webroot/js/cimage.js",
    "content": "/**\n * JavaScript utilities for CImage and img.php.\n */\nwindow.CImage = (function() {\n    \"use strict\";\n\n\n    /**\n     * Waiting for ECMA 6...\n     */\n     var forEach = function(array, callback, scope) {\n      for (var i = 0; i < array.length; i++) {\n        callback.call(scope, i, array[i]);\n      }\n    };\n\n\n\n    /**\n     * Update the permalink.\n     */\n    function updatePermaLink() {\n        var link,\n            input1 = document.getElementById(\"input1\"),\n            input2 = document.getElementById(\"input2\"),\n            input3 = document.getElementById(\"input3\"),\n            input4 = document.getElementById(\"input4\"),\n            input5 = document.getElementById(\"input5\"),\n            input6 = document.getElementById(\"input6\"),\n            details = document.getElementById(\"viewDetails\"),\n            stack = document.getElementById(\"stack\"),\n            bg = document.getElementById(\"bg\"),\n            permalink = document.getElementById(\"permalink\");\n            \n        link  = \"?\";\n        link += \"input1=\" + encodeURIComponent(input1.value) + \"&\";\n        link += \"input2=\" + encodeURIComponent(input2.value) + \"&\";\n        link += \"input3=\" + encodeURIComponent(input3.value) + \"&\";\n        link += \"input4=\" + encodeURIComponent(input4.value) + \"&\";\n        link += \"input5=\" + encodeURIComponent(input5.value) + \"&\";\n        link += \"input6=\" + encodeURIComponent(input6.value) + \"&\";\n        link += \"json=\" + encodeURIComponent(details.checked) + \"&\";\n        link += \"stack=\" + encodeURIComponent(stack.checked) + \"&\";\n        link += \"bg=\" + encodeURIComponent(bg.checked);\n        permalink.href = link;\n    }\n\n\n\n    /**\n     * Init the compare page with details.\n     */\n    function compareLoadImage(event) {\n        var img, json, button, area, deck, id, permalink;\n\n        id = this.dataset.id;\n        img = document.getElementById(\"img\" + id);\n        json = document.getElementById(\"json\" + id);\n        button = document.getElementById(\"button\" + id);\n        area = document.getElementById(\"area\" + id);\n        deck = document.getElementById(\"deck\" + id);\n        \n        updatePermaLink();\n        \n        if (this.value == \"\") {\n            // Clear image if input is cleared\n            button.setAttribute(\"disabled\", \"disabled\");\n            area.classList.add(\"hidden\");\n            button.classList.remove(\"selected\");\n            return;\n        }\n\n        // Display image in its area\n        img.src = this.value;\n        area.classList.remove(\"hidden\");\n\n        $.getJSON(this.value + \"&json\", function(data) {\n            json.innerHTML = \"filename: \" + data.filename + \"\\ncolors: \" + data.colors + \"\\nsize: \" + data.size + \"\\nwidth: \" + data.width + \"\\nheigh: \" + data.height + \"\\naspect-ratio: \" + data.aspectRatio + \"\\npng-type: \" + data.pngType;\n        })\n            .fail(function() {\n                json.innerHTML = \"Details not available.\"\n                console.log( \"JSON error\" );\n            });\n\n        // Display image in overlay\n        button.removeAttribute(\"disabled\");\n        button.classList.add(\"selected\");\n\n\n    };\n\n\n\n    /**\n     * Init the compare page with details.\n     */\n    function compareInit(options) \n    {\n        var elements, id, onTop, myEvent,\n            input1 = document.getElementById(\"input1\"),\n            input2 = document.getElementById(\"input2\"),\n            input3 = document.getElementById(\"input3\"),\n            input4 = document.getElementById(\"input4\"),\n            input5 = document.getElementById(\"input5\"),\n            input6 = document.getElementById(\"input6\"),\n            details = document.getElementById(\"viewDetails\"),\n            stack = document.getElementById(\"stack\"),\n            bg = document.getElementById(\"bg\"),\n            buttons = document.getElementById(\"buttonWrap\");\n\n        input1.addEventListener(\"change\", compareLoadImage);\n        input2.addEventListener(\"change\", compareLoadImage);\n        input3.addEventListener(\"change\", compareLoadImage);\n        input4.addEventListener(\"change\", compareLoadImage);\n        input5.addEventListener(\"change\", compareLoadImage);\n        input6.addEventListener(\"change\", compareLoadImage);\n\n        // Toggle json\n        details.addEventListener(\"change\", function() {\n            var elements = document.querySelectorAll(\".json\");\n            \n            forEach(elements, function (index, element) {\n                element.classList.toggle(\"hidden\");\n            });\n\n            /* ECMA 6\n            for (var element of elements) {\n                element.classList.toggle(\"hidden\");\n            }\n            */\n            \n            updatePermaLink();\n            console.log(\"View JSON\");\n        });\n\n        // Show json as default\n        if (options.json === true) {\n            details.setAttribute(\"checked\", \"checked\");\n            myEvent = new CustomEvent(\"change\");\n            details.dispatchEvent(myEvent);\n        }\n\n        // Toggle background color\n        bg.addEventListener(\"change\", function() {\n            var elements = document.querySelectorAll(\".area\");\n\n            forEach(elements, function (index, element) {\n                element.classList.toggle(\"invert\");\n            });\n        });\n\n        // Check background\n        if (options.bg === true) {\n            bg.setAttribute(\"checked\", \"checked\");\n            bg.classList.toggle(\"invert\");\n            myEvent = new CustomEvent(\"change\");\n            bg.dispatchEvent(myEvent);\n        }\n\n        // Toggle stack\n        stack.addEventListener(\"change\", function() {\n            var element,\n                elements = document.querySelectorAll(\".area\");\n\n            buttons.classList.toggle(\"hidden\");\n\n            forEach(elements, function (index, element) {\n                element.classList.toggle(\"stack\");\n\n                if (!element.classList.contains('hidden')) {\n                    onTop = element;\n                }\n            });\n\n            /* ECMA 6\n            for (element of elements) {\n                element.classList.toggle(\"stack\");\n\n                if (!element.classList.contains('hidden')) {\n                    onTop = element;\n                }\n            }\n            */\n\n            onTop.classList.toggle(\"top\");\n            updatePermaLink();\n\n            console.log(\"Stacking\");\n        });\n\n        // Stack as default\n        if (options.stack === true) {\n            stack.setAttribute(\"checked\", \"checked\");\n            myEvent = new CustomEvent(\"change\");\n            stack.dispatchEvent(myEvent);\n        }\n\n        // Button clicks\n        elements = document.querySelectorAll(\".button\");\n\n        forEach(elements, function (index, element) {\n            element.addEventListener(\"click\", function() {\n                var id = this.dataset.id,\n                    area = document.getElementById(\"area\" + id);\n\n                area.classList.toggle(\"top\");\n                onTop.classList.toggle(\"top\");\n                onTop = area;\n                console.log(\"button\" + id);\n            });\n        });\n\n        /* ECMA 6\n        for (var element of elements) {\n            element.addEventListener(\"click\", function() {\n                var id = this.dataset.id,\n                    area = document.getElementById(\"area\" + id);\n                \n                area.classList.toggle(\"top\");\n                onTop.classList.toggle(\"top\");\n                onTop = area;\n                console.log(\"button\" + id);\n            });\n        }\n        */\n\n        input1.value = options.input1 || null;\n        input2.value = options.input2 || null;\n        input3.value = options.input3 || null;\n        input4.value = options.input4 || null;\n        input5.value = options.input5 || null;\n        input6.value = options.input6 || null;\n\n        compareLoadImage.call(input1);\n        compareLoadImage.call(input2);\n        compareLoadImage.call(input3);\n        compareLoadImage.call(input4);\n        compareLoadImage.call(input5);\n        compareLoadImage.call(input6);\n\n        console.log(options);\n    } \n\n\n    return {\n        \"compare\": compareInit\n    };\n\n}());\n"
  },
  {
    "path": "webroot/test/config.php",
    "content": "<?php\n// Use error reporting\nerror_reporting(-1);\nini_set('display_errors', 1);\n\n\n// The link to img.php\n$imgphp = \"../img.php?src=\";\n"
  },
  {
    "path": "webroot/test/template.php",
    "content": "<!doctype html>\n<head>\n  <meta charset='utf-8'/>\n  <title><?=$title?></title>\n  <style>\n  body {background-color: #ccc;}\n  </style>\n  <script src=\"https://code.jquery.com/jquery-2.1.1.min.js\"></script>\n\n<script type=\"text/javascript\">\nwindow.getDetails = function (url, id) {\n  $.getJSON(url, function(data) {\n    element = document.getElementById(id);\n    element.innerHTML = \"filename: \" + data.filename + \"\\nmime type: \" + data.mimeType + \"\\ncolors: \" + data.colors + \"\\nsize: \" + data.size + \"\\nwidth: \" + data.width + \"\\nheigh: \" + data.height + \"\\naspect-ratio: \" + data.aspectRatio;\n  });  \n}\n</script>\n\n</head>\n<body>\n<h1><?=$title?></h1>\n\n<?php if (isset($description)) : ?>\n<p><?=$description?></p>\n<?php endif; ?>\n\n<h2>Images used in test</h2>\n\n<p>The following images are used for this test.</p>\n\n<?php foreach($images as $image) : ?>\n  <p>\n    <code>\n      <a href=\"img/<?=$image?>\"><?=$image?></a> \n      <a href=\"<?=$imgphp . $image . '&json'?>\">(json)</a>\n      <a href=\"<?=$imgphp . $image . '&verbose'?>\">(verbose)</a>\n    </code>\n    <br>\n  <img src=\"<?=$imgphp . $image?>\"></p>\n  <p></p>\n\n<pre id=\"<?=$image?>\"></pre>\n<script type=\"text/javascript\">window.getDetails(\"<?=$imgphp . $image . '&json'?>\", \"<?=$image?>\")</script>\n\n<?php endforeach; ?>\n\n\n\n<h2>Testcases used for each image</h2>\n\n<p>The following testcases are used for each image.</p>\n\n<?php foreach($testcase as $tc) : ?>\n  <code><?=$tc?></code><br>\n<?php endforeach; ?>\n\n\n\n<h2>For each image, apply all testcases</h2>\n\n<?php \n$ch1 = 1;\nforeach($images as $image) :\n?>\n<h3><?=$ch1?>. Using source image <?=$image?></h3>\n\n<p>\n  <code>\n    <a href=\"img/<?=$image?>\"><?=$image?></a> \n    <a href=\"<?=$imgphp . $image . '&json'?>\">(json)</a>\n    <a href=\"<?=$imgphp . $image . '&verbose'?>\">(verbose)</a>\n  </code>\n  <br>\n  <img src=\"<?=$imgphp . $image?>\">\n</p>\n\n<pre id=\"<?=$ch1?>\"></pre>\n<script type=\"text/javascript\">window.getDetails(\"<?=$imgphp . $image . '&json'?>\", \"<?=$ch1?>\")</script>\n\n<?php \n$ch2 = 1;\nforeach($testcase as $tc) : \n$tcId = \"$ch1.$ch2\";\n?>\n<h4>Testcase <?=$tcId?>: <?=$tc?></h4>\n\n<p>\n  <code>\n    <a href=\"<?=$imgphp . $image . $tc?>\"><?=$image . $tc?></a> \n    <a href=\"<?=$imgphp . $image . $tc . '&json'?>\">(json)</a>\n    <a href=\"<?=$imgphp . $image . $tc . '&verbose'?>\">(verbose)</a>\n  </code>\n  <br>\n  <img src=\"<?=$imgphp . $image . $tc?>\">\n</p>\n\n<pre id=\"<?=$tcId?>\"></pre>\n<script type=\"text/javascript\">window.getDetails(\"<?=$imgphp . $image . $tc . '&json'?>\", \"<?=$tcId?>\")</script>\n\n<?php $ch2++; endforeach; ?>\n<?php $ch1++; endforeach; ?>\n"
  },
  {
    "path": "webroot/test/test.php",
    "content": "<!doctype html>\n<head>\n  <meta charset='utf-8'/>\n  <title>Testing img resizing using CImage.php</title>\n</head>\n<body>\n<h1>Testing <code>CImage.php</code> through <code>img.php</code></h1>\n\n<h2>Testcases</h2>\n\n<?php\n$testcase = array(\n  array('text'=>'Original image', 'query'=>''),\n  array('text'=>'Crop out a rectangle of 100x100, start by position 200x200.', 'query'=>'&crop=100,100,200,200'),\n  array('text'=>'Crop out a full width rectangle with height of 200, start by position 0x100.', 'query'=>'&crop=0,200,0,100'),\n  array('text'=>'Max width 200.', 'query'=>'&w=200'),\n  array('text'=>'Max height 200.', 'query'=>'&h=200'),\n  array('text'=>'Max width 200 and max height 200.', 'query'=>'&w=200&h=200'),\n  array('text'=>'No-ratio makes image fit in area of width 200 and height 200.', 'query'=>'&w=200&h=200&no-ratio'),\n  array('text'=>'Crop to fit in width 200 and height 200.', 'query'=>'&w=200&h=200&crop-to-fit'),\n  array('text'=>'Crop to fit in width 200 and height 100.', 'query'=>'&w=200&h=100&crop-to-fit'),\n  array('text'=>'Crop to fit in width 100 and height 200.', 'query'=>'&w=100&h=200&crop-to-fit'),\n  array('text'=>'Quality 70', 'query'=>'&w=200&h=200&quality=70'),\n  array('text'=>'Quality 40', 'query'=>'&w=200&h=200&quality=40'),\n  array('text'=>'Quality 10', 'query'=>'&w=200&h=200&quality=10'),\n  array('text'=>'Filter: Negate', 'query'=>'&w=200&h=200&f=negate'),\n  array('text'=>'Filter: Grayscale', 'query'=>'&w=200&h=200&f=grayscale'),\n  array('text'=>'Filter: Brightness 90', 'query'=>'&w=200&h=200&f=brightness,90'),\n  array('text'=>'Filter: Contrast 50', 'query'=>'&w=200&h=200&f=contrast,50'),\n  array('text'=>'Filter: Colorize 0,255,0,0', 'query'=>'&w=200&h=200&f=colorize,0,255,0,0'),\n  array('text'=>'Filter: Edge detect', 'query'=>'&w=200&h=200&f=edgedetect'),\n  array('text'=>'Filter: Emboss', 'query'=>'&w=200&h=200&f=emboss'),\n  array('text'=>'Filter: Gaussian blur', 'query'=>'&w=200&h=200&f=gaussian_blur'),\n  array('text'=>'Filter: Selective blur', 'query'=>'&w=200&h=200&f=selective_blur'),\n  array('text'=>'Filter: Mean removal', 'query'=>'&w=200&h=200&f=mean_removal'),\n  array('text'=>'Filter: Smooth 2', 'query'=>'&w=200&h=200&f=smooth,2'),\n  array('text'=>'Filter: Pixelate 10,10', 'query'=>'&w=200&h=200&f=pixelate,10,10'),\n  array('text'=>'Multiple filter: Negate, Grayscale and Pixelate 10,10', 'query'=>'&w=200&h=200&&f=negate&f0=grayscale&f1=pixelate,10,10'),\n  array('text'=>'Crop with width & height and crop-to-fit with quality and filter', 'query'=>'&crop=100,100,100,100&w=200&h=200&crop-to-fit&q=70&f0=grayscale'),\n);\n?>\n\n<h3>Test case with image <code>wider.jpg</code></h3>\n<table>\n<caption>Test case with image <code>wider.jpg</code></caption>\n<thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>\n<tbody>\n<?php\nforeach($testcase as $key => $val) {\n  $url = \"../img.php?src=wider.jpg{$val['query']}\";\n  echo \"<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>\".htmlentities($url).\"</a></code></td><td><img src='$url' /></td></tr>\";\n}\n?>\n</tbody>\n</table>\n\n<h3>Test case with image <code>higher.jpg</code></h3>\n<table>\n<caption>Test case with image <code>higher.jpg</code></caption>\n<thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>\n<tbody>\n<?php\nforeach($testcase as $key => $val) {\n  $url = \"../img.php?src=higher.jpg{$val['query']}\";\n  echo \"<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>\".htmlentities($url).\"</a></code></td><td><img src='$url' /></td></tr>\";\n}\n?>\n</tbody>\n</table>\n\n\n</body>\n</html>"
  },
  {
    "path": "webroot/test/test_issue101-dummy.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 100 - Dummy images\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Create dummy images.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'dummy',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&nc&so',\n    '&nc&width=300',\n    '&nc&height=300',\n    '&nc&width=300&height=300',\n    '&nc&bgc=006600',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue29.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing img for issue 29\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'issue29/400x265.jpg',\n    'issue29/400x268.jpg',\n    'issue29/400x300.jpg',\n    'issue29/465x304.jpg',\n    'issue29/640x273.jpg',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&w=300&cf&q=80&nc',\n    '&w=75&h=75&cf&q=80&nc',\n    '&w=75&h=75&q=80',\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue36_aro.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 36 - autoRotate\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'issue36/me-0.jpg',\n    'issue36/me-90.jpg',\n    'issue36/me-180.jpg',\n    'issue36/me-270.jpg',\n    'issue36/flower-0.jpg',\n    'issue36/flower-90.jpg',\n    'issue36/flower-180.jpg',\n    'issue36/flower-270.jpg',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&aro&nc',\n    '&aro&nc&w=200',\n    '&aro&nc&h=200',\n    '&aro&nc&w=200&h=200&cf',\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue36_rb-ra-180.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 180;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue36_rb-ra-270.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 270;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue36_rb-ra-45.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 45;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue36_rb-ra-90.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$angle = 90;\n\n$title = \"Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?>\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    \"&rb=$angle&nc\",\n    \"&rb=$angle&nc&w=200\",\n    \"&rb=$angle&nc&h=200\",\n    \"&rb=$angle&nc&w=200&h=200&cf\",\n    \"&ra=$angle&nc\",\n    \"&ra=$angle&nc&w=200\",\n    \"&ra=$angle&nc&h=200\",\n    \"&ra=$angle&nc&w=200&h=200&cf\",\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue38.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 38 - fill to fit, together with background colors\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"The issue was to implement fill-to-fit, but it needs some flexibility in how to choose the background color and it also affects rotation of the image (the background color does). So this testcase is both for fill-to-fit and for background color (thereby including a test using rotate).\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim04.png',\n    'apple_trans.gif',\n    'circle_trans.png',\n);\n\n\n\n// For each image, apply these testcases\n$cache =  \"&nc\"; // \"\"; // \"&nc\"\n$testcase = array(\n    \"$cache&w=300&h=300&fill-to-fit\",\n    \"$cache&w=200&h=400&fill-to-fit\",\n    \"$cache&w=300&h=300&fill-to-fit=ff0000\",\n    \"$cache&w=200&h=400&fill-to-fit=ff0000\",\n    \"$cache&w=300&h=300&fill-to-fit=ff00003f\",\n    \"$cache&w=200&h=400&fill-to-fit=ff00003f\",\n    \"$cache&w=200&h=400&fill-to-fit&bgc=ff0000\",\n    \"$cache&w=300&h=300&fill-to-fit&bgc=ff00003f\",\n    \"$cache&w=300&h=300&ra=45\",\n    \"$cache&w=300&h=300&ra=45&bgc=ff0000\",\n    \"$cache&w=300&h=300&ra=45&bgc=ff00003f\",\n);\n\n\n\n// Applu testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue40.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 40 - no ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Showing off how to resize image with and without ratio.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'issue40/source.jpg',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&nc&width=652&height=466',\n    '&nc&width=652&height=466&no-ratio',\n    '&nc&width=652&height=466&crop-to-fit',\n    '&nc&width=652&aspect-ratio=1.4',\n    '&nc&width=652&aspect-ratio=1.4&no-ratio',\n    '&nc&width=652&aspect-ratio=1.4&crop-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue49.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 49 - flexible convolution\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Creating shortcuts to custom convolutions by using configurable list of constant convolutions.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&nc&width=400&convolve=lighten',\n    '&nc&width=400&convolve=darken',\n    '&nc&width=400&convolve=sharpen',\n    '&nc&width=400&convolve=emboss',\n    '&nc&width=400&convolve=blur',\n    '&nc&width=400&convolve=blur:blur',\n    '&nc&width=400&convolve=blur:blur:blur:blur',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue52-cf.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 52 - Fill to fit fails with aspect ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that Fill To Fit resize strategy works with all variants of sizes.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = '&nc'; \n$testcase = array(\n    $nc . '&w=300&h=300&crop-to-fit',\n    $nc . '&w=300&ar=1.1&crop-to-fit',\n    $nc . '&w=300&ar=3&crop-to-fit',\n    $nc . '&h=300&ar=1.1&crop-to-fit',\n    $nc . '&h=300&ar=3&crop-to-fit',\n    $nc . '&w=50%&ar=1.1&crop-to-fit',\n    $nc . '&w=50%&ar=3&crop-to-fit',\n    $nc . '&h=50%&ar=1.1&crop-to-fit',\n    $nc . '&h=50%&ar=3&crop-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue52-stretch.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 52 - Fill to fit fails with aspect ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that Fill To Fit resize strategy works with all variants of sizes.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = '&nc'; \n$testcase = array(\n    $nc . '&w=300&h=300&stretch',\n    $nc . '&w=300&ar=1.1&stretch',\n    $nc . '&w=300&ar=3&stretch',\n    $nc . '&h=300&ar=1.1&stretch',\n    $nc . '&h=300&ar=3&stretch',\n    $nc . '&w=50%&ar=1.1&stretch',\n    $nc . '&w=50%&ar=3&stretch',\n    $nc . '&h=50%&ar=1.1&stretch',\n    $nc . '&h=50%&ar=3&stretch',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue52.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 52 - Fill to fit fails with aspect ratio\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that Fill To Fit resize strategy works with all variants of sizes.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = null; //&nc'; \n$testcase = array(\n    $nc . '&w=300&h=300&fill-to-fit',\n    $nc . '&w=300&ar=1.1&fill-to-fit',\n    $nc . '&w=300&ar=2&fill-to-fit',\n    $nc . '&h=300&ar=1.1&fill-to-fit',\n    $nc . '&h=300&ar=2.1&fill-to-fit',\n    $nc . '&w=50%&ar=1.1&fill-to-fit',\n    $nc . '&w=50%&ar=2&fill-to-fit',\n    $nc . '&h=50%&ar=1.1&fill-to-fit',\n    $nc . '&h=50%&ar=2&fill-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue58.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 58 - JSON reporting filesize\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Verify that JSON returns filesize of actual image.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim08.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&w=300',\n    '&w=300&h=300',\n    '&w=300&h=300&stretch',\n    '&w=300&h=300&crop-to-fit',\n    '&w=300&h=300&fill-to-fit',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue60.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 60  - skip original\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Always use the original if suitable, use skip-original to force using the cached version.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '',\n    '&so',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_issue85.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing issue 85 - Load images in a more generic manner\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Do not depend on file extension while loading images.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car-gif',\n    'car-jpg',\n    'car-png',\n);\n\n\n\n// For each image, apply these testcases \n$testcase = array(\n    '&nc&so',\n    '&nc&sa=gif',\n    '&nc&sa=jpg',\n    '&nc&sa=png',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_option-crop.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing option crop\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Cropping parts of image\";\n\n\n\n// Use these images in the test\n$images = array(\n    'kodim04.png',\n);\n\n\n\n// For each image, apply these testcases\n$nc = \"&nc\"; //null; //&nc'; \n$testcase = array(\n    $nc . '&w=300',\n    $nc . '&w=300&crop=0,0,0,0',\n    $nc . '&crop=300,200,0,0',\n    $nc . '&crop=300,200,left,top',\n    $nc . '&crop=300,200,right,top',\n    $nc . '&crop=300,200,right,bottom',\n    $nc . '&crop=300,200,left,bottom',\n    $nc . '&crop=300,200,center,center',\n    $nc . '&crop=200,220,190,300',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_option-no-upscale.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing option no-upscale\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"Do not upscale image when original image (slice) is smaller than target image.\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n    'apple.jpg',\n);\n\n\n\n// For each image, apply these testcases\n$nc = \"&bgc=660000\"; //null; //\"&nc\"; //null; //&nc'; \n$testcase = array(\n    $nc . '&w=600',\n    $nc . '&w=600&no-upscale',\n    $nc . '&h=400',\n    $nc . '&h=400&no-upscale',\n    $nc . '&w=600&h=400',\n    $nc . '&w=600&h=400&no-upscale',\n    $nc . '&w=700&h=400&stretch',\n    $nc . '&w=700&h=400&no-upscale&stretch',\n    $nc . '&w=700&h=200&stretch',\n    $nc . '&w=700&h=200&no-upscale&stretch',\n    $nc . '&w=250&h=400&stretch',\n    $nc . '&w=250&h=400&no-upscale&stretch',\n    $nc . '&w=700&h=400&crop-to-fit',\n    $nc . '&w=700&h=400&no-upscale&crop-to-fit',\n    $nc . '&w=700&h=200&crop-to-fit',\n    $nc . '&w=700&h=200&no-upscale&crop-to-fit',\n    $nc . '&w=250&h=400&crop-to-fit',\n    $nc . '&w=250&h=400&no-upscale&crop-to-fit',\n    $nc . '&w=600&h=500&fill-to-fit',\n    $nc . '&w=600&h=500&no-upscale&fill-to-fit',\n    $nc . '&w=250&h=400&fill-to-fit',\n    $nc . '&w=250&h=400&no-upscale&fill-to-fit',\n    $nc . '&w=700&h=400&fill-to-fit',\n    $nc . '&w=700&h=400&no-upscale&fill-to-fit',\n/*\n    $nc . '&w=600&ar=1.6',\n    $nc . '&w=600&ar=1.6&no-upscale',\n    $nc . '&h=400&ar=1.6',\n    $nc . '&h=400&ar=1.6&no-upscale',\n*/\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/test/test_option-save-as.php",
    "content": "<?php\n// Include config for all testcases\ninclude __DIR__ . \"/config.php\";\n\n\n\n// The title of the test case\n$title = \"Testing option save-as - save image to another format\";\n\n\n\n// Provide a short description of the testcase.\n$description = \"\";\n\n\n\n// Use these images in the test\n$images = array(\n    'car.png',\n    'car.gif',\n    'car.jpg',\n    'ball24.png',\n    'wider.jpg',\n);\n\n\n\n// For each image, apply these testcases\n$nc = \"&nc\"; //null; //&nc'; \n$testcase = array(\n    $nc . '&w=300',\n    $nc . '&w=300&sa=jpg',\n    $nc . '&w=300&sa=png',\n    $nc . '&w=300&sa=gif',\n    $nc . '&w=300&palette',\n    $nc . '&w=300&sa=png&palette',\n);\n\n\n\n// Apply testcases and present results\ninclude __DIR__ . \"/template.php\";\n"
  },
  {
    "path": "webroot/tests.php",
    "content": "<?php\n\n$links = [\n    \"img.php?src=car.png&v\",\n    \"img.php?src=car.png&w=700&v\",\n];\n\n?><!doctype html>\n<html>\n    <head>\n        <title>Links to use for testing</title>\n    </head>\n    <body>\n        <h1>Links useful for testing</h1>\n        <p>A collection of linkt to use to test various aspects of the cimage process.</p>\n        <ul>\n        <?php foreach ($links as $link) : ?>\n            <li><a href=\"<?= $link ?>\"><?= $link ?></a></li>\n        <?php endforeach; ?>\n        </ul>\n    </body>\n</html>"
  }
]