Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f250f7dff9 | ||
|
05c11ca9fc | ||
|
b069e322e9 | ||
|
6e0c775ede | ||
|
179469334a | ||
|
0b2723feee | ||
|
c009f423a2 | ||
|
79a7fd17d8 | ||
|
3271d165ff | ||
|
1dc04e7c53 | ||
|
376a40e538 | ||
|
29743b75ec | ||
|
902c0aaef8 | ||
|
6c487c6f34 | ||
|
a1d811a318 | ||
|
a205d65ad5 | ||
|
22f24cc75a | ||
|
28be266d15 | ||
|
044e3e3c66 | ||
|
c32ae6dace | ||
|
ef397f5c02 | ||
|
b871dd7f1c | ||
|
91ae49b3f3 | ||
|
8e1318c31e | ||
|
9c81286efa | ||
|
d7b34a6488 | ||
|
39cee7647e | ||
|
b3dd2a7623 | ||
|
3c22db4392 | ||
|
8aea13ba33 | ||
|
ccacc9e0c1 | ||
|
b93d1242db | ||
|
f9a4205579 | ||
|
0efcfd5bc7 | ||
|
7a98a44dd4 | ||
|
aedce7021f | ||
|
1f012ac19e | ||
|
a62425e759 | ||
|
3667082f15 | ||
|
80610b31b9 | ||
|
b639220d05 | ||
|
ee9fdb8474 | ||
|
db5ce71926 | ||
|
1bf57fe8ef | ||
|
8c89166967 | ||
|
ce8ec325d3 | ||
|
ca9b4a4ce6 | ||
|
7c0f37628f | ||
|
5fe8e399a1 | ||
|
9620c1eb75 | ||
|
f721ef4b35 | ||
|
37b39fbecf | ||
|
553d2f3db1 | ||
|
9e2bd27c6e |
10
.gitignore
vendored
@@ -4,3 +4,13 @@ cache/*
|
||||
# Test
|
||||
coverage/
|
||||
coverage.clover
|
||||
|
||||
# Composer
|
||||
composer.lock
|
||||
vendor
|
||||
|
||||
# Build and test
|
||||
build/
|
||||
|
||||
# Mac OS
|
||||
.DS_Store
|
||||
|
80
.travis.yml
@@ -1,13 +1,93 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
- nightly
|
||||
- "7.0"
|
||||
|
||||
|
||||
|
||||
sudo: false
|
||||
|
||||
|
||||
|
||||
git:
|
||||
submodules: false
|
||||
|
||||
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
#- php-codesniffer
|
||||
#- phpmd
|
||||
#- shellcheck
|
||||
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: nightly
|
||||
|
||||
|
||||
|
||||
before_script:
|
||||
|
||||
# Create a build directory for output
|
||||
# Store all files in your own bin
|
||||
#- install --directory build/bin
|
||||
#- export PATH=$PATH:$PWD/build/bin/
|
||||
|
||||
|
||||
# Install validation tools
|
||||
#- npm install -g htmlhint csslint jshint jscs jsonlint js-yaml html-minifier@0.8.0 clean-css uglify-js
|
||||
|
||||
# Install phpcs
|
||||
#- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
|
||||
#- install --mode 0755 phpcs.phar $PWD/build/bin/phpcs
|
||||
|
||||
# Install phpmd
|
||||
#- wget -c http://static.phpmd.org/php/latest/phpmd.phar
|
||||
#- install --mode 0755 phpmd.phar $PWD/build/bin/phpmd
|
||||
|
||||
|
||||
|
||||
script:
|
||||
# Check versions of validation tools
|
||||
#- node --version
|
||||
#- npm --version
|
||||
|
||||
#- htmlhint --version
|
||||
#- csslint --version
|
||||
#- jscs --version
|
||||
#- jshint --version
|
||||
#- phpcs --version
|
||||
#- phpmd --version
|
||||
#- jsonlint --version
|
||||
#- js-yaml --version
|
||||
#- shellcheck --version
|
||||
|
||||
#- html-minifier --version
|
||||
#- cleancss --version
|
||||
#- uglifyjs --version
|
||||
|
||||
# Run validation & publish
|
||||
#- make phpunit
|
||||
- composer validate
|
||||
- phpunit
|
||||
#- make phpcs
|
||||
|
||||
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#dbwebb"
|
||||
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/a89832db4f939e85ba97
|
||||
on_success: change # options: [always|never|change] default: always
|
||||
on_failure: always # options: [always|never|change] default: always
|
||||
on_start: never # options: [always|never|change] default: always
|
||||
|
@@ -175,7 +175,7 @@ class CAsciiArt
|
||||
*/
|
||||
public function getLuminance($red, $green, $blue)
|
||||
{
|
||||
switch($this->luminanceStrategy) {
|
||||
switch ($this->luminanceStrategy) {
|
||||
case 1:
|
||||
$luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
|
||||
break;
|
||||
|
107
CCache.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Deal with the cache directory and cached items.
|
||||
*
|
||||
*/
|
||||
class CCache
|
||||
{
|
||||
/**
|
||||
* Path to the cache directory.
|
||||
*/
|
||||
private $path;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the path to the cache dir which must exist.
|
||||
*
|
||||
* @param string path to the cache dir.
|
||||
*
|
||||
* @throws Exception when $path is not a directory.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDir($path)
|
||||
{
|
||||
if (!is_dir($path)) {
|
||||
throw new Exception("Cachedir is not a directory.");
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the path to the cache subdir and try to create it if its not there.
|
||||
*
|
||||
* @param string $subdir name of subdir
|
||||
* @param array $create default is to try to create the subdir
|
||||
*
|
||||
* @return string | boolean as real path to the subdir or
|
||||
* false if it does not exists
|
||||
*/
|
||||
public function getPathToSubdir($subdir, $create = true)
|
||||
{
|
||||
$path = realpath($this->path . "/" . $subdir);
|
||||
|
||||
if (is_dir($path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
if ($create && is_writable($this->path)) {
|
||||
$path = $this->path . "/" . $subdir;
|
||||
|
||||
if (mkdir($path)) {
|
||||
return realpath($path);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get status of the cache subdir.
|
||||
*
|
||||
* @param string $subdir name of subdir
|
||||
*
|
||||
* @return string with status
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove the cache subdir.
|
||||
*
|
||||
* @param string $subdir name of subdir
|
||||
*
|
||||
* @return null | boolean true if success else false, null if no operation
|
||||
*/
|
||||
public function removeSubdir($subdir)
|
||||
{
|
||||
$path = realpath($this->path . "/" . $subdir);
|
||||
|
||||
if (is_dir($path)) {
|
||||
return rmdir($path);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
374
CImage.php
@@ -63,6 +63,13 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add HTTP headers for outputing image.
|
||||
*/
|
||||
private $HTTPHeader = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default background color, red, green, blue, alpha.
|
||||
*
|
||||
@@ -337,20 +344,27 @@ class CImage
|
||||
|
||||
|
||||
/**
|
||||
* Calculate target dimension for image when using fill-to-fit resize strategy.
|
||||
*/
|
||||
* Calculate target dimension for image when using fill-to-fit resize strategy.
|
||||
*/
|
||||
private $fillWidth;
|
||||
private $fillHeight;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow remote file download, default is to disallow remote file download.
|
||||
*/
|
||||
* Allow remote file download, default is to disallow remote file download.
|
||||
*/
|
||||
private $allowRemote = false;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Path to cache for remote download.
|
||||
*/
|
||||
private $remoteCache;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pattern to recognize a remote file.
|
||||
*/
|
||||
@@ -382,12 +396,21 @@ class CImage
|
||||
|
||||
|
||||
/*
|
||||
* output to ascii can take som options as an array.
|
||||
* Output to ascii can take som options as an array.
|
||||
*/
|
||||
private $asciiOptions = array();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Image copy strategy, defaults to RESAMPLE.
|
||||
*/
|
||||
const RESIZE = 1;
|
||||
const RESAMPLE = 2;
|
||||
private $copyStrategy = NULL;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Properties, the class is mutable and the method setOptions()
|
||||
* decides (partly) what properties are created.
|
||||
@@ -496,13 +519,15 @@ class CImage
|
||||
* Allow or disallow remote image download.
|
||||
*
|
||||
* @param boolean $allow true or false to enable and disable.
|
||||
* @param string $cache path to cache dir.
|
||||
* @param string $pattern to use to detect if its a remote file.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRemoteDownload($allow, $pattern = null)
|
||||
public function setRemoteDownload($allow, $cache, $pattern = null)
|
||||
{
|
||||
$this->allowRemote = $allow;
|
||||
$this->remoteCache = $cache;
|
||||
$this->remotePattern = is_null($pattern) ? $this->remotePattern : $pattern;
|
||||
|
||||
$this->log(
|
||||
@@ -600,6 +625,26 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Normalize the file extension.
|
||||
*
|
||||
* @param string $extension of image file or skip to use internal.
|
||||
*
|
||||
* @return string $extension as a normalized file extension.
|
||||
*/
|
||||
private function normalizeFileExtension($extension = null)
|
||||
{
|
||||
$extension = strtolower($extension ? $extension : $this->extension);
|
||||
|
||||
if ($extension == 'jpeg') {
|
||||
$extension = 'jpg';
|
||||
}
|
||||
|
||||
return $extension;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Download a remote image and return path to its local copy.
|
||||
*
|
||||
@@ -612,23 +657,14 @@ class CImage
|
||||
if (!$this->isRemoteSourceOnWhitelist($src)) {
|
||||
throw new Exception("Hostname is not on whitelist for remote sources.");
|
||||
}
|
||||
|
||||
|
||||
$remote = new CRemoteImage();
|
||||
$cache = $this->saveFolder . "/remote/";
|
||||
|
||||
if (!is_dir($cache)) {
|
||||
if (!is_writable($this->saveFolder)) {
|
||||
throw new Exception("Can not create remote cache, cachefolder not writable.");
|
||||
}
|
||||
mkdir($cache);
|
||||
$this->log("The remote cache does not exists, creating it.");
|
||||
}
|
||||
|
||||
if (!is_writable($cache)) {
|
||||
if (!is_writable($this->remoteCache)) {
|
||||
$this->log("The remote cache is not writable.");
|
||||
}
|
||||
|
||||
$remote->setCache($cache);
|
||||
$remote->setCache($this->remoteCache);
|
||||
$remote->useCache($this->useCache);
|
||||
$src = $remote->download($src);
|
||||
|
||||
@@ -1262,10 +1298,11 @@ class CImage
|
||||
* @param string $base as optional basepath for storing file.
|
||||
* @param boolean $useSubdir use or skip the subdir part when creating the
|
||||
* filename.
|
||||
* @param string $prefix to add as part of filename
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function generateFilename($base = null, $useSubdir = true)
|
||||
public function generateFilename($base = null, $useSubdir = true, $prefix = null)
|
||||
{
|
||||
$filename = basename($this->pathToImage);
|
||||
$cropToFit = $this->cropToFit ? '_cf' : null;
|
||||
@@ -1279,8 +1316,16 @@ class CImage
|
||||
$rotateBefore = $this->rotateBefore ? "_rb{$this->rotateBefore}" : null;
|
||||
$rotateAfter = $this->rotateAfter ? "_ra{$this->rotateAfter}" : null;
|
||||
|
||||
$width = $this->newWidth;
|
||||
$height = $this->newHeight;
|
||||
$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']
|
||||
@@ -1329,14 +1374,14 @@ class CImage
|
||||
$subdir = ($subdir == '.') ? '_.' : $subdir;
|
||||
$subdir .= '_';
|
||||
}
|
||||
|
||||
$file = $subdir . $filename . '_' . $width . '_'
|
||||
. $height . $offset . $crop . $cropToFit . $fillToFit
|
||||
|
||||
$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;
|
||||
. $convolve . $copyStrat . $saveAs;
|
||||
|
||||
return $this->setTarget($file, $base);
|
||||
}
|
||||
@@ -1400,7 +1445,8 @@ class CImage
|
||||
if ($this->image === false) {
|
||||
throw new Exception("Could not load image.");
|
||||
}
|
||||
|
||||
|
||||
/* Removed v0.7.7
|
||||
if (image_type_to_mime_type($this->fileType) == 'image/png') {
|
||||
$type = $this->getPngType();
|
||||
$hasFewColors = imagecolorstotal($this->image);
|
||||
@@ -1412,14 +1458,15 @@ class CImage
|
||||
$this->palette = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($this->verbose) {
|
||||
$this->log("Image successfully loaded from file.");
|
||||
$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");
|
||||
$this->log(" Detected transparent color = " . ($index >= 0 ? implode(", ", imagecolorsforindex($this->image, $index)) : "NONE") . " at index = $index");
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -1430,37 +1477,20 @@ class CImage
|
||||
/**
|
||||
* Get the type of PNG image.
|
||||
*
|
||||
* @param string $filename to use instead of default.
|
||||
*
|
||||
* @return int as the type of the png-image
|
||||
*
|
||||
*/
|
||||
private function getPngType()
|
||||
public function getPngType($filename = null)
|
||||
{
|
||||
$pngType = ord(file_get_contents($this->pathToImage, false, null, 25, 1));
|
||||
$filename = $filename ? $filename : $this->pathToImage;
|
||||
|
||||
switch ($pngType) {
|
||||
$pngType = ord(file_get_contents($filename, false, null, 25, 1));
|
||||
|
||||
case self::PNG_GREYSCALE:
|
||||
$this->log("PNG is type 0, Greyscale.");
|
||||
break;
|
||||
|
||||
case self::PNG_RGB:
|
||||
$this->log("PNG is type 2, RGB");
|
||||
break;
|
||||
|
||||
case self::PNG_RGB_PALETTE:
|
||||
$this->log("PNG is type 3, RGB with palette");
|
||||
break;
|
||||
|
||||
case self::PNG_GREYSCALE_ALPHA:
|
||||
$this->Log("PNG is type 4, Greyscale with alpha channel");
|
||||
break;
|
||||
|
||||
case self::PNG_RGB_ALPHA:
|
||||
$this->Log("PNG is type 6, RGB with alpha channel (PNG 32-bit)");
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->Log("PNG is UNKNOWN type, is it really a PNG image?");
|
||||
if ($this->verbose) {
|
||||
$this->log("Checking png type of: " . $filename);
|
||||
$this->log($this->getPngTypeAsString($pngType));
|
||||
}
|
||||
|
||||
return $pngType;
|
||||
@@ -1468,6 +1498,59 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the type of PNG image as a verbose string.
|
||||
*
|
||||
* @param integer $type to use, default is to check the type.
|
||||
* @param string $filename to use instead of default.
|
||||
*
|
||||
* @return int as the type of the png-image
|
||||
*
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculate number of colors in an image.
|
||||
*
|
||||
@@ -1503,7 +1586,7 @@ class CImage
|
||||
*/
|
||||
public function preResize()
|
||||
{
|
||||
$this->log("Pre-process before resizing");
|
||||
$this->log("### Pre-process before resizing");
|
||||
|
||||
// Rotate image
|
||||
if ($this->rotateBefore) {
|
||||
@@ -1536,6 +1619,39 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resize or resample the image while resizing.
|
||||
*
|
||||
* @param int $strategy as CImage::RESIZE or CImage::RESAMPLE
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCopyResizeStrategy($strategy)
|
||||
{
|
||||
$this->copyStrategy = $strategy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resize and or crop the image.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resize and or crop the image.
|
||||
*
|
||||
@@ -1544,7 +1660,7 @@ class CImage
|
||||
public function resize()
|
||||
{
|
||||
|
||||
$this->log("Starting to Resize()");
|
||||
$this->log("### Starting to Resize()");
|
||||
$this->log("Upscale = '$this->upscale'");
|
||||
|
||||
// Only use a specified area of the image, $this->offset is defining the area to use
|
||||
@@ -1604,7 +1720,7 @@ class CImage
|
||||
$cropY = round(($this->cropHeight/2) - ($this->newHeight/2));
|
||||
$imgPreCrop = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);
|
||||
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
|
||||
imagecopyresampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -1643,7 +1759,7 @@ class CImage
|
||||
} else {
|
||||
$imgPreFill = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);
|
||||
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
|
||||
imagecopyresampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -1689,7 +1805,7 @@ class CImage
|
||||
}
|
||||
} else {
|
||||
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
|
||||
imagecopyresampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);
|
||||
$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;
|
||||
@@ -1708,7 +1824,7 @@ class CImage
|
||||
*/
|
||||
public function postResize()
|
||||
{
|
||||
$this->log("Post-process after resizing");
|
||||
$this->log("### Post-process after resizing");
|
||||
|
||||
// Rotate image
|
||||
if ($this->rotateAfter) {
|
||||
@@ -2107,7 +2223,7 @@ class CImage
|
||||
$index = $this->image
|
||||
? imagecolortransparent($this->image)
|
||||
: -1;
|
||||
|
||||
|
||||
if ($index != -1) {
|
||||
|
||||
imagealphablending($img, true);
|
||||
@@ -2168,14 +2284,15 @@ class CImage
|
||||
*/
|
||||
protected function getTargetImageExtension()
|
||||
{
|
||||
// switch on mimetype
|
||||
if (isset($this->extension)) {
|
||||
return strtolower($this->extension);
|
||||
} else {
|
||||
return image_type_to_extension($this->fileType);
|
||||
return substr(image_type_to_extension($this->fileType), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save image.
|
||||
@@ -2200,7 +2317,9 @@ class CImage
|
||||
is_writable($this->saveFolder)
|
||||
or $this->raiseError('Target directory is not writable.');
|
||||
|
||||
switch($this->getTargetImageExtension()) {
|
||||
$type = $this->getTargetImageExtension();
|
||||
$this->Log("Saving image as " . $type);
|
||||
switch($type) {
|
||||
|
||||
case 'jpeg':
|
||||
case 'jpg':
|
||||
@@ -2279,6 +2398,74 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert image from one colorpsace/color profile to sRGB without
|
||||
* color profile.
|
||||
*
|
||||
* @param string $src of image.
|
||||
* @param string $dir as base directory where images are.
|
||||
* @param string $cache as base directory where to store images.
|
||||
* @param string $iccFile filename of colorprofile.
|
||||
* @param boolean $useCache or not, default to always use cache.
|
||||
*
|
||||
* @return string | boolean false if no conversion else the converted
|
||||
* filename.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
// Prepare
|
||||
$this->setSaveFolder($cache)
|
||||
->setSource($src, $dir)
|
||||
->generateFilename(null, false, 'srgb_');
|
||||
|
||||
// Check if the cached version is accurate.
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Only covert if cachedir is writable
|
||||
if (is_writable($this->saveFolder)) {
|
||||
// Load file and check if conversion is needed
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a hard link, as an alias, to the cached file.
|
||||
*
|
||||
@@ -2294,8 +2481,6 @@ class CImage
|
||||
return $this;
|
||||
}
|
||||
|
||||
$alias = $alias . "." . $this->getTargetImageExtension();
|
||||
|
||||
if (is_readable($alias)) {
|
||||
unlink($alias);
|
||||
}
|
||||
@@ -2313,11 +2498,28 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add HTTP header for putputting together with image.
|
||||
*
|
||||
* @param string $type the header type such as "Cache-Control"
|
||||
* @param string $value the value to use
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addHTTPHeader($type, $value)
|
||||
{
|
||||
$this->HTTPHeader[$type] = $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output image to browser using caching.
|
||||
*
|
||||
* @param string $file to read and output, default is to use $this->cacheFileName
|
||||
* @param string $format set to json to output file as json object with details
|
||||
* @param string $file to read and output, default is to
|
||||
* use $this->cacheFileName
|
||||
* @param string $format set to json to output file as json
|
||||
* object with details
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2354,6 +2556,10 @@ class CImage
|
||||
header('Last-Modified: ' . $gmdate . " GMT");
|
||||
}
|
||||
|
||||
foreach($this->HTTPHeader as $key => $val) {
|
||||
header("$key: $val");
|
||||
}
|
||||
|
||||
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {
|
||||
|
||||
if ($this->verbose) {
|
||||
@@ -2366,21 +2572,25 @@ class CImage
|
||||
|
||||
} else {
|
||||
|
||||
// Get details on image
|
||||
$info = getimagesize($file);
|
||||
!empty($info) or $this->raiseError("The file doesn't seem to be an image.");
|
||||
$mime = $info['mime'];
|
||||
$size = filesize($file);
|
||||
|
||||
if ($this->verbose) {
|
||||
$this->log("Last modified: " . $gmdate . " GMT");
|
||||
$this->log("Last-Modified: " . $gmdate . " GMT");
|
||||
$this->log("Content-type: " . $mime);
|
||||
$this->log("Content-length: " . $size);
|
||||
$this->verboseOutput();
|
||||
|
||||
|
||||
if (is_null($this->verboseFileName)) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Get details on image
|
||||
$info = getimagesize($file);
|
||||
!empty($info) or $this->raiseError("The file doesn't seem to be an image.");
|
||||
$mime = $info['mime'];
|
||||
|
||||
header('Content-type: ' . $mime);
|
||||
header("Content-type: $mime");
|
||||
header("Content-length: $size");
|
||||
readfile($file);
|
||||
}
|
||||
|
||||
@@ -2421,6 +2631,18 @@ class CImage
|
||||
$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")) {
|
||||
|
@@ -101,7 +101,7 @@ class CRemoteImage
|
||||
*/
|
||||
public function setCache($path)
|
||||
{
|
||||
$this->saveFolder = $path;
|
||||
$this->saveFolder = rtrim($path, "/") . "/";
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,12 @@ class CRemoteImage
|
||||
*/
|
||||
public function setHeaderFields()
|
||||
{
|
||||
$this->http->setHeader("User-Agent", "CImage/0.7.2 (PHP/". phpversion() . " cURL)");
|
||||
$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) {
|
||||
|
13
README.md
@@ -1,9 +1,10 @@
|
||||
[](https://travis-ci.org/mosbth/cimage)
|
||||
[](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)
|
||||
|
||||
Image conversion on the fly using PHP
|
||||
=====================================
|
||||
|
||||
[](https://gitter.im/mosbth/cimage?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://travis-ci.org/mosbth/cimage)
|
||||
[](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)
|
||||
|
||||
About
|
||||
-------------------------------------
|
||||
|
||||
@@ -45,14 +46,14 @@ There are several ways of installing. You either install the whole project which
|
||||
|
||||
The [sourcode is available on GitHub](https://github.com/mosbth/cimage). Clone, fork or [download as zip](https://github.com/mosbth/cimage/archive/master.zip).
|
||||
|
||||
**Latest stable version is v0.7.6 released 2015-10-18.**
|
||||
**Latest stable version is v0.7.9 released 2015-12-07.**
|
||||
|
||||
I prefer cloning like this. Do switch to the latest stable version.
|
||||
|
||||
```bash
|
||||
git clone git://github.com/mosbth/cimage.git
|
||||
cd cimage
|
||||
git checkout v0.7.6
|
||||
git checkout v0.7.9
|
||||
```
|
||||
|
||||
Make the cache-directory writable by the webserver.
|
||||
@@ -75,7 +76,7 @@ There are some all-included bundles of `img.php` that can be downloaded and used
|
||||
Dowload the version of your choice like this.
|
||||
|
||||
```bash
|
||||
wget https://github.com/mosbth/cimage/tree/v0.7.6/webroot/imgp.php
|
||||
wget https://raw.githubusercontent.com/mosbth/cimage/v0.7.9/webroot/imgp.php
|
||||
```
|
||||
|
||||
Open 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.
|
||||
|
41
REVISION.md
@@ -5,6 +5,47 @@ Revision history
|
||||
[](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)
|
||||
|
||||
|
||||
v0.7.9 (2015-12-07)
|
||||
-------------------------------------
|
||||
|
||||
* Strict mode only reporting 404 when failure, #127.
|
||||
* Added correct CImage version to remote agent string, #131.
|
||||
* Adding CCache to improve cache handling of caching for dummy, remote and srgb. #130.
|
||||
|
||||
|
||||
v0.7.8 (2015-12-06)
|
||||
-------------------------------------
|
||||
|
||||
* HTTP error messages now 403, 404 and 500 as in #128 and #127.
|
||||
* More examples on dealing with cache through bash `bin/cache.bash`, #129.
|
||||
* Added conversion to sRGB using option `?srgb`. #120.
|
||||
* Added Gitter badge to README, #126.
|
||||
* Fix proper download url in README, #125.
|
||||
* Change path in `webroot/htaccess` to make it work in current environment.
|
||||
|
||||
|
||||
v0.7.7 (2015-10-21)
|
||||
-------------------------------------
|
||||
|
||||
* One can now add a HTTP header for Cache-Control in the config file, #109.
|
||||
* Added hook in img,php before CImage is called, #123.
|
||||
* Added configuration for default jpeg quality and png compression in the config file, #107.
|
||||
* Strip comments and whitespace in imgs.php, #115.
|
||||
* Bundle imgs.php did not have the correct mode.
|
||||
* Adding option &status to get an overview of the installed on configured utilities, #116.
|
||||
* Bug, all files saved as png-files, when not saving as specific file.
|
||||
* Removed saving filename extension for alias images.
|
||||
* Added option to decide if resample or resize when copying images internally. `&no-resample` makes resize, instead of resample as is default.
|
||||
* Verbose now correctly states if transparent color is detected.
|
||||
* Compare-tool now supports 6 images.
|
||||
* Added option for dark background in the compare-tool.
|
||||
* 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.
|
||||
* Adding save-as as part of the generated cache filename, #121.
|
||||
* Add extra fields to json-response, #114.
|
||||
* Add header for Content-Length, #111.
|
||||
* Add check for postprocessing tools in path in `webroot/check_system.php`, #104.
|
||||
|
||||
|
||||
v0.7.6 (2015-10-18)
|
||||
-------------------------------------
|
||||
|
||||
|
@@ -1,22 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Specify the utilities used
|
||||
# ls -ult list and sorts fils by its access time
|
||||
#
|
||||
ECHO="printf"
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Main, start by checking basic usage
|
||||
#
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
$ECHO "Usage: $0 [cache-dir]\n"
|
||||
echo "Usage: $0 [cache-dir]"
|
||||
exit 1
|
||||
elif [ ! -d "$1" ]; then
|
||||
$ECHO "Usage: $0 [cache-dir]\n"
|
||||
$ECHO "$1 is not a directory.\n"
|
||||
echo "Usage: $0 [cache-dir]"
|
||||
echo "$1 is not a directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -25,12 +20,24 @@ fi
|
||||
#
|
||||
# Print out details on cache-directory
|
||||
#
|
||||
$ECHO "Total size: $( du -sh $1 | cut -f1 )"
|
||||
$ECHO "\nNumber of files: $( find $1 | wc -l )"
|
||||
$ECHO "\n\nTop-5 largest files:\n"
|
||||
$ECHO "$( du -s $1/* | sort -nr | head -5 )"
|
||||
$ECHO "\n\nLast-5 created files:\n"
|
||||
$ECHO "$( find $1/* -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r | head -5 )"
|
||||
$ECHO "\n\nLast-5 accessed files:\n"
|
||||
$ECHO "$( find $1/* -printf '%AY-%Am-%Ad %AH:%AM %f\n' | sort -r | head -5 )"
|
||||
$ECHO "\n"
|
||||
echo "# Size"
|
||||
echo "Total size: $( du -sh $1 | cut -f1 )"
|
||||
echo "Number of files: $( find $1 -type f | wc -l )"
|
||||
echo "Number of dirs: $( find $1 -type d | wc -l )"
|
||||
echo
|
||||
echo "# Top-5 largest files/dirs:"
|
||||
echo "$( du -s $1/* | sort -nr | head -5 )"
|
||||
echo
|
||||
echo "# Last-5 created files:"
|
||||
echo "$( find $1 -type f -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r | head -5 )"
|
||||
echo
|
||||
echo "# Last-5 accessed files:"
|
||||
echo "$( find $1 -type f -printf '%AY-%Am-%Ad %AH:%AM %f\n' | sort -r | head -5 )"
|
||||
echo
|
||||
echo "# 5 Oldest files:"
|
||||
echo "$( find $1 -type f -printf '%AY-%Am-%Ad %AH:%AM %f\n' | sort | head -5 )"
|
||||
echo
|
||||
echo "# Files not accessed within the last 30 days"
|
||||
echo "Number of files: $( find $1 -type f -atime +30 | wc -l )"
|
||||
echo "Total file size: $( find $1 -type f -atime +30 -exec du {} \; | cut -f1 | paste -sd+ | bc )"
|
||||
echo
|
||||
|
@@ -39,6 +39,7 @@ $ECHO "\n CRemoteImage.php"
|
||||
$ECHO "\n CWhitelist.php"
|
||||
$ECHO "\n CAsciiArt.php"
|
||||
$ECHO "\n CImage.php"
|
||||
$ECHO "\n CCache.php"
|
||||
$ECHO "\n webroot/img.php"
|
||||
$ECHO "\n"
|
||||
$ECHO "\n'$TARGET_D' is for development mode."
|
||||
@@ -55,7 +56,7 @@ read answer
|
||||
#
|
||||
cat webroot/img_header.php > $TARGET_P
|
||||
cat webroot/img_header.php | sed "s|//'mode' => 'production',|'mode' => 'development',|" > $TARGET_D
|
||||
cat webroot/img_header.php | sed "s|//'mode' => 'production',|'mode' => 'development',|" > $TARGET_S
|
||||
cat webroot/img_header.php | sed "s|//'mode' => 'production',|'mode' => 'strict',|" > $TARGET_S
|
||||
|
||||
$ECHO "$NEWLINES" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
|
||||
@@ -74,9 +75,14 @@ $ECHO "$NEWLINES" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
tail -n +2 CImage.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
$ECHO "$NEWLINES" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
|
||||
tail -n +2 CCache.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
$ECHO "$NEWLINES" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
|
||||
tail -n +2 webroot/img.php | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
$ECHO "$NEWLINES" | tee -a $TARGET_D $TARGET_P $TARGET_S > /dev/null
|
||||
|
||||
php -w $TARGET_S > tmp && mv tmp $TARGET_S
|
||||
|
||||
$ECHO "\nDone."
|
||||
$ECHO "\n"
|
||||
$ECHO "\n"
|
||||
|
0
cache/dummy/README.md
vendored
@@ -26,7 +26,8 @@
|
||||
"CHttpGet.php",
|
||||
"CRemoteImage.php",
|
||||
"CWhitelist.php",
|
||||
"CAsciiArt.php"
|
||||
"CAsciiArt.php",
|
||||
"CCache.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
731
docs/api/classes/CAsciiArt.html
Normal file
@@ -0,0 +1,731 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
|
||||
<meta charset="utf-8"/>
|
||||
<title>CImage API Documentaion</title>
|
||||
<meta name="author" content=""/>
|
||||
<meta name="description" content=""/>
|
||||
|
||||
<link href="../css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
|
||||
<link href="../css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="../css/prism.css" rel="stylesheet" media="all"/>
|
||||
<link href="../css/template.css" rel="stylesheet" media="all"/>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../js/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script src="../js/jquery-1.11.0.min.js"></script>
|
||||
<script src="../js/ui/1.10.4/jquery-ui.min.js"></script>
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
<script src="../js/jquery.smooth-scroll.js"></script>
|
||||
<script src="../js/prism.min.js"></script>
|
||||
<!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->
|
||||
<script type="text/javascript">
|
||||
function loadExternalCodeSnippets() {
|
||||
Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
|
||||
var src = pre.getAttribute('data-src');
|
||||
var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
|
||||
var language = 'php';
|
||||
|
||||
var code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
|
||||
pre.textContent = '';
|
||||
|
||||
code.textContent = 'Loading…';
|
||||
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState == 4) {
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
|
||||
Prism.highlightElement(code);
|
||||
}
|
||||
else if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
}
|
||||
else {
|
||||
code.textContent = '✖ Error: File does not exist or is empty';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
loadExternalCodeSnippets();
|
||||
});
|
||||
$('#source-view').on('shown', function () {
|
||||
loadExternalCodeSnippets();
|
||||
})
|
||||
</script>
|
||||
|
||||
<link rel="shortcut icon" href="../images/favicon.ico"/>
|
||||
<link rel="apple-touch-icon" href="../images/apple-touch-icon.png"/>
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="../images/apple-touch-icon-72x72.png"/>
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="../images/apple-touch-icon-114x114.png"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<i class="icon-ellipsis-vertical"></i>
|
||||
</a>
|
||||
<a class="brand" href="../index.html">CImage API Documentaion</a>
|
||||
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav pull-right">
|
||||
<li class="dropdown" id="charts-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
Charts <b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../graphs/class.html">
|
||||
<i class="icon-list-alt"></i> Class hierarchy diagram
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown" id="reports-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
Reports <b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/deprecated.html">
|
||||
<i class="icon-list-alt"></i> Deprecated <span class="label label-info pull-right">0</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="go_to_top">-->
|
||||
<!--<a href="#___" style="color: inherit">Back to top  <i class="icon-upload icon-white"></i></a>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
|
||||
<div id="___" class="container-fluid">
|
||||
<section class="row-fluid">
|
||||
<div class="span2 sidebar">
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1847469476"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-1847469476" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<section class="row-fluid">
|
||||
<div class="span10 offset2">
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<nav>
|
||||
<a href="../namespaces/default.html">\</a> <i class="icon-level-up"></i>
|
||||
</nav>
|
||||
<a href="#source-view" role="button" class="pull-right btn" data-toggle="modal"><i class="icon-code"></i></a>
|
||||
|
||||
<h1><small>\</small>CAsciiArt</h1>
|
||||
<p><em>Create an ASCII version of an image.</em></p>
|
||||
|
||||
|
||||
|
||||
<section id="summary">
|
||||
<h2>Summary</h2>
|
||||
<section class="row-fluid heading">
|
||||
<section class="span4">
|
||||
<a href="#methods">Methods</a>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<a href="#properties">Properties</a>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<a href="#constants">Constants</a>
|
||||
</section>
|
||||
</section>
|
||||
<section class="row-fluid public">
|
||||
<section class="span4">
|
||||
<a href="../classes/CAsciiArt.html#method___construct" class="">__construct()</a><br />
|
||||
<a href="../classes/CAsciiArt.html#method_addCharacterSet" class="">addCharacterSet()</a><br />
|
||||
<a href="../classes/CAsciiArt.html#method_setOptions" class="">setOptions()</a><br />
|
||||
<a href="../classes/CAsciiArt.html#method_createFromFile" class="">createFromFile()</a><br />
|
||||
<a href="../classes/CAsciiArt.html#method_luminanceAreaAverage" class="">luminanceAreaAverage()</a><br />
|
||||
<a href="../classes/CAsciiArt.html#method_getLuminance" class="">getLuminance()</a><br />
|
||||
<a href="../classes/CAsciiArt.html#method_luminance2character" class="">luminance2character()</a><br />
|
||||
</section>
|
||||
<section class="span4">
|
||||
<em>No public properties found</em>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<em>No constants found</em>
|
||||
</section>
|
||||
</section>
|
||||
<section class="row-fluid protected">
|
||||
<section class="span4">
|
||||
<em>No protected methods found</em>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<em>No protected properties found</em>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<em>N/A</em>
|
||||
</section>
|
||||
</section>
|
||||
<section class="row-fluid private">
|
||||
<section class="span4">
|
||||
<em>No private methods found</em>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<a href="../classes/CAsciiArt.html#property_characterSet" class="">$characterSet</a><br />
|
||||
<a href="../classes/CAsciiArt.html#property_characters" class="">$characters</a><br />
|
||||
<a href="../classes/CAsciiArt.html#property_charCount" class="">$charCount</a><br />
|
||||
<a href="../classes/CAsciiArt.html#property_scale" class="">$scale</a><br />
|
||||
<a href="../classes/CAsciiArt.html#property_luminanceStrategy" class="">$luminanceStrategy</a><br />
|
||||
</section>
|
||||
<section class="span4">
|
||||
<em>N/A</em>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>File</dt>
|
||||
<dd><a href="../files/CAsciiArt.html"><div class="path-wrapper">CAsciiArt.php</div></a></dd>
|
||||
<dt>Package</dt>
|
||||
<dd><div class="namespace-wrapper">Default</div></dd>
|
||||
<dt>Class hierarchy</dt>
|
||||
<dd class="hierarchy">
|
||||
<div class="namespace-wrapper">\CAsciiArt</div>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
|
||||
<a id="properties" name="properties"></a>
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<h2>Properties</h2>
|
||||
</div>
|
||||
<aside class="span4 detailsbar"></aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="property_characterSet" name="property_characterSet" class="anchor"></a>
|
||||
<article class="property">
|
||||
<h3 class="private ">$characterSet</h3>
|
||||
<pre class="signature">$characterSet : </pre>
|
||||
<p><em>Character set to use.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="property_characters" name="property_characters" class="anchor"></a>
|
||||
<article class="property">
|
||||
<h3 class="private ">$characters</h3>
|
||||
<pre class="signature">$characters : </pre>
|
||||
<p><em>Current character set.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="property_charCount" name="property_charCount" class="anchor"></a>
|
||||
<article class="property">
|
||||
<h3 class="private ">$charCount</h3>
|
||||
<pre class="signature">$charCount : </pre>
|
||||
<p><em>Length of current character set.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="property_scale" name="property_scale" class="anchor"></a>
|
||||
<article class="property">
|
||||
<h3 class="private ">$scale</h3>
|
||||
<pre class="signature">$scale : </pre>
|
||||
<p><em>Scale of the area to swap to a character.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="property_luminanceStrategy" name="property_luminanceStrategy" class="anchor"></a>
|
||||
<article class="property">
|
||||
<h3 class="private ">$luminanceStrategy</h3>
|
||||
<pre class="signature">$luminanceStrategy : </pre>
|
||||
<p><em>Strategy to calculate luminance.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
|
||||
<a id="methods" name="methods"></a>
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class"><h2>Methods</h2></div>
|
||||
<aside class="span4 detailsbar"></aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method___construct" name="method___construct" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">__construct()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">__construct() </pre>
|
||||
<p><em>Constructor which sets default options.</em></p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_addCharacterSet" name="method_addCharacterSet" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">addCharacterSet()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">addCharacterSet(string <span class="argument">$key</span>, string <span class="argument">$value</span>) : $this</pre>
|
||||
<p><em>Add a custom character set.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td>$key </td>
|
||||
<td><p>for the character set.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td>$value </td>
|
||||
<td><p>for the character set.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
$this
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_setOptions" name="method_setOptions" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">setOptions()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">setOptions(array <span class="argument">$options = array()</span>) : $this</pre>
|
||||
<p><em>Set options for processing, defaults are available.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td>array</td>
|
||||
<td>$options </td>
|
||||
<td><p>to use as default settings.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
$this
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_createFromFile" name="method_createFromFile" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">createFromFile()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">createFromFile(string <span class="argument">$filename</span>) : string</pre>
|
||||
<p><em>Create an Ascii image from an image file.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td>$filename </td>
|
||||
<td><p>of the image to use.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
string
|
||||
— <p>$ascii with the ASCII image.</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_luminanceAreaAverage" name="method_luminanceAreaAverage" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">luminanceAreaAverage()</h3>
|
||||
<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>
|
||||
<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>
|
||||
<p><em>Get the luminance from a region of an image using average color value.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td>$img </td>
|
||||
<td><p>the image.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>integer</td>
|
||||
<td>$x1 </td>
|
||||
<td><p>the area to get pixels from.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>integer</td>
|
||||
<td>$y1 </td>
|
||||
<td><p>the area to get pixels from.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>integer</td>
|
||||
<td>$x2 </td>
|
||||
<td><p>the area to get pixels from.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>integer</td>
|
||||
<td>$y2 </td>
|
||||
<td><p>the area to get pixels from.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
integer
|
||||
— <p>$luminance with a value between 0 and 100.</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_getLuminance" name="method_getLuminance" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">getLuminance()</h3>
|
||||
<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>
|
||||
<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>
|
||||
<p><em>Calculate luminance value with different strategies.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td>integer</td>
|
||||
<td>$red </td>
|
||||
<td><p>The color red.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>integer</td>
|
||||
<td>$green </td>
|
||||
<td><p>The color green.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>integer</td>
|
||||
<td>$blue </td>
|
||||
<td><p>The color blue.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
float
|
||||
— <p>$luminance with a value between 0 and 1.</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_luminance2character" name="method_luminance2character" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">luminance2character()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">luminance2character( <span class="argument">$luminance</span>) : string</pre>
|
||||
<p><em>Translate the luminance value to a character.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>$luminance </td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
string
|
||||
— <p>with the ascii character.</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div id="source-view" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="source-view-label" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="source-view-label">CAsciiArt.php</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<pre data-src="../files/CAsciiArt.php.txt" class="language-php line-numbers"></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="row-fluid">
|
||||
<section class="span10 offset2">
|
||||
<section class="row-fluid">
|
||||
<section class="span10 offset1">
|
||||
<section class="row-fluid footer-sections">
|
||||
<section class="span4">
|
||||
<h1><i class="icon-code"></i></h1>
|
||||
<div>
|
||||
<ul>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<h1><i class="icon-bar-chart"></i></h1>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="../graphs/class.html">Class Hierarchy Diagram</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<h1><i class="icon-pushpin"></i></h1>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="../reports/errors.html">Errors</a></li>
|
||||
<li><a href="../reports/markers.html">Markers</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
<section class="row-fluid">
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1983965054"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-603682456"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-1983965054" class="accordion-body collapse in">
|
||||
<div id="namespace-603682456" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -186,6 +187,7 @@
|
||||
<section class="row-fluid public">
|
||||
<section class="span4">
|
||||
<a href="../classes/CHttpGet.html#method___construct" class="">__construct()</a><br />
|
||||
<a href="../classes/CHttpGet.html#method_buildUrl" class="">buildUrl()</a><br />
|
||||
<a href="../classes/CHttpGet.html#method_setUrl" class="">setUrl()</a><br />
|
||||
<a href="../classes/CHttpGet.html#method_setHeader" class="">setHeader()</a><br />
|
||||
<a href="../classes/CHttpGet.html#method_parseHeader" class="">parseHeader()</a><br />
|
||||
@@ -331,6 +333,49 @@
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_buildUrl" name="method_buildUrl" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">buildUrl()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">buildUrl(string <span class="argument">$baseUrl</span>, string <span class="argument">$merge</span>) : string</pre>
|
||||
<p><em>Build an encoded url.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td>$baseUrl </td>
|
||||
<td><p>This is the original url which will be merged.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td>$merge </td>
|
||||
<td><p>Thse parts should be merged into the baseUrl,
|
||||
the format is as parse_url.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
string
|
||||
— <p>$url as the modified url.</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
@@ -468,6 +513,11 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4>Throws</h4>
|
||||
<dl>
|
||||
<dt>\Exception</dt>
|
||||
<dd><p>when curl fails to retrieve url.</p></dd>
|
||||
</dl>
|
||||
|
||||
<h4>Returns</h4>
|
||||
boolean
|
||||
@@ -587,16 +637,16 @@
|
||||
<tr>
|
||||
<td>mixed</td>
|
||||
<td>$default </td>
|
||||
<td><p>as default value (int seconds) if date is</p>
|
||||
<pre><code> missing in response header.</code></pre></td>
|
||||
<td><p>as default value (int seconds) if date is
|
||||
missing in response header.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
integer
|
||||
— <p>as timestamp or $default if Date is missing in</p>
|
||||
<pre><code> response header.</code></pre>
|
||||
— <p>as timestamp or $default if Date is missing in
|
||||
response header.</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
@@ -626,8 +676,8 @@
|
||||
<tr>
|
||||
<td>mixed</td>
|
||||
<td>$default </td>
|
||||
<td><p>as default value if date is missing in response</p>
|
||||
<pre><code> header.</code></pre></td>
|
||||
<td><p>as default value if date is missing in response
|
||||
header.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -727,7 +777,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-811883102"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1171772037"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-811883102" class="accordion-body collapse in">
|
||||
<div id="namespace-1171772037" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -185,13 +186,11 @@
|
||||
</section>
|
||||
<section class="row-fluid public">
|
||||
<section class="span4">
|
||||
<a href="../classes/CRemoteImage.html#method___construct" class="">__construct()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_getStatus" class="">getStatus()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_getDetails" class="">getDetails()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_setCache" class="">setCache()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_isCacheWritable" class="">isCacheWritable()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_useCache" class="">useCache()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_contentTypeToFileExtension" class="">contentTypeToFileExtension()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_setHeaderFields" class="">setHeaderFields()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_save" class="">save()</a><br />
|
||||
<a href="../classes/CRemoteImage.html#method_updateCacheDetails" class="">updateCacheDetails()</a><br />
|
||||
@@ -230,7 +229,6 @@
|
||||
<a href="../classes/CRemoteImage.html#property_url" class="">$url</a><br />
|
||||
<a href="../classes/CRemoteImage.html#property_fileName" class="">$fileName</a><br />
|
||||
<a href="../classes/CRemoteImage.html#property_fileJson" class="">$fileJson</a><br />
|
||||
<a href="../classes/CRemoteImage.html#property_fileImage" class="">$fileImage</a><br />
|
||||
<a href="../classes/CRemoteImage.html#property_cache" class="">$cache</a><br />
|
||||
</section>
|
||||
<section class="span4">
|
||||
@@ -423,7 +421,7 @@
|
||||
<article class="property">
|
||||
<h3 class="private ">$fileName</h3>
|
||||
<pre class="signature">$fileName : </pre>
|
||||
<p><em>Base name of cache file for downloaded item.</em></p>
|
||||
<p><em>Base name of cache file for downloaded item and name of image.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
@@ -450,30 +448,6 @@
|
||||
<p><em>Filename for json-file with details of cached item.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="property_fileImage" name="property_fileImage" class="anchor"></a>
|
||||
<article class="property">
|
||||
<h3 class="private ">$fileImage</h3>
|
||||
<pre class="signature">$fileImage : </pre>
|
||||
<p><em>Filename for image-file.</em></p>
|
||||
|
||||
|
||||
<h4>Type</h4>
|
||||
|
||||
</article>
|
||||
@@ -522,32 +496,6 @@
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method___construct" name="method___construct" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">__construct()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">__construct() </pre>
|
||||
<p><em>Constructor</em></p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_getStatus" name="method_getStatus" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">getStatus()</h3>
|
||||
@@ -712,43 +660,6 @@ a remote file.</em></p>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_contentTypeToFileExtension" name="method_contentTypeToFileExtension" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">contentTypeToFileExtension()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">contentTypeToFileExtension(string <span class="argument">$type</span>) : string</pre>
|
||||
<p><em>Translate a content type to a file extension.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td>$type </td>
|
||||
<td><p>a valid content type.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Returns</h4>
|
||||
string
|
||||
— <p>as file extension or false if no match.</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<aside class="span4 detailsbar">
|
||||
<h1><i class="icon-arrow-down"></i></h1>
|
||||
<dl>
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content class">
|
||||
<a id="method_setHeaderFields" name="method_setHeaderFields" class="anchor"></a>
|
||||
<article class="method">
|
||||
<h3 class="public ">setHeaderFields()</h3>
|
||||
@@ -852,6 +763,11 @@ a remote file.</em></p>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4>Throws</h4>
|
||||
<dl>
|
||||
<dt>\Exception</dt>
|
||||
<dd><p>when status code does not match 200 or 304.</p></dd>
|
||||
</dl>
|
||||
|
||||
<h4>Returns</h4>
|
||||
string
|
||||
@@ -976,7 +892,7 @@ a remote file.</em></p>
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-470874282"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1100227540"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-470874282" class="accordion-body collapse in">
|
||||
<div id="namespace-1100227540" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -300,8 +301,8 @@ whitelist should be a regexp without the surrounding / or #.</em></p>
|
||||
<tr>
|
||||
<td>array</td>
|
||||
<td>$whitelist </td>
|
||||
<td><p>with all valid options,</p>
|
||||
<pre><code> default is to clear the whitelist.</code></pre></td>
|
||||
<td><p>with all valid options,
|
||||
default is to clear the whitelist.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -413,7 +414,7 @@ whitelist should be a regexp without the surrounding / or #.</em></p>
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
257
docs/api/files/CAsciiArt.html
Normal file
@@ -0,0 +1,257 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
|
||||
<meta charset="utf-8"/>
|
||||
<title>CImage API Documentaion</title>
|
||||
<meta name="author" content=""/>
|
||||
<meta name="description" content=""/>
|
||||
|
||||
<link href="../css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
|
||||
<link href="../css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="../css/prism.css" rel="stylesheet" media="all"/>
|
||||
<link href="../css/template.css" rel="stylesheet" media="all"/>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../js/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script src="../js/jquery-1.11.0.min.js"></script>
|
||||
<script src="../js/ui/1.10.4/jquery-ui.min.js"></script>
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
<script src="../js/jquery.smooth-scroll.js"></script>
|
||||
<script src="../js/prism.min.js"></script>
|
||||
<!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->
|
||||
<script type="text/javascript">
|
||||
function loadExternalCodeSnippets() {
|
||||
Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
|
||||
var src = pre.getAttribute('data-src');
|
||||
var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
|
||||
var language = 'php';
|
||||
|
||||
var code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
|
||||
pre.textContent = '';
|
||||
|
||||
code.textContent = 'Loading…';
|
||||
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState == 4) {
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
|
||||
Prism.highlightElement(code);
|
||||
}
|
||||
else if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
}
|
||||
else {
|
||||
code.textContent = '✖ Error: File does not exist or is empty';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
loadExternalCodeSnippets();
|
||||
});
|
||||
$('#source-view').on('shown', function () {
|
||||
loadExternalCodeSnippets();
|
||||
})
|
||||
</script>
|
||||
|
||||
<link rel="shortcut icon" href="../images/favicon.ico"/>
|
||||
<link rel="apple-touch-icon" href="../images/apple-touch-icon.png"/>
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="../images/apple-touch-icon-72x72.png"/>
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="../images/apple-touch-icon-114x114.png"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<i class="icon-ellipsis-vertical"></i>
|
||||
</a>
|
||||
<a class="brand" href="../index.html">CImage API Documentaion</a>
|
||||
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav pull-right">
|
||||
<li class="dropdown" id="charts-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
Charts <b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../graphs/class.html">
|
||||
<i class="icon-list-alt"></i> Class hierarchy diagram
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown" id="reports-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
Reports <b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/deprecated.html">
|
||||
<i class="icon-list-alt"></i> Deprecated <span class="label label-info pull-right">0</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="go_to_top">-->
|
||||
<!--<a href="#___" style="color: inherit">Back to top  <i class="icon-upload icon-white"></i></a>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
|
||||
<div id="___" class="container-fluid">
|
||||
<section class="row-fluid">
|
||||
<div class="span2 sidebar">
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-306826089"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-306826089" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<section class="row-fluid">
|
||||
<div class="span10 offset2">
|
||||
<div class="row-fluid">
|
||||
<div class="span8 content file">
|
||||
<nav>
|
||||
</nav>
|
||||
|
||||
<a href="#source-view" role="button" class="pull-right btn" data-toggle="modal"><i class="icon-code"></i></a>
|
||||
<h1><small></small>CAsciiArt.php</h1>
|
||||
<p><em></em></p>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Classes</h2>
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<td><a href="../classes/CAsciiArt.html">CAsciiArt</a></td>
|
||||
<td><em>Create an ASCII version of an image.</em></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<aside class="span4 detailsbar">
|
||||
<dl>
|
||||
<dt>Package</dt>
|
||||
<dd><div class="namespace-wrapper">\Default</div></dd>
|
||||
|
||||
|
||||
</dl>
|
||||
<h2>Tags</h2>
|
||||
<table class="table table-condensed">
|
||||
<tr><td colspan="2"><em>None found</em></td></tr>
|
||||
</table>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div id="source-view" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="source-view-label" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="source-view-label"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<pre data-src="../files/CAsciiArt.php.txt" class="language-php line-numbers"></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="row-fluid">
|
||||
<section class="span10 offset2">
|
||||
<section class="row-fluid">
|
||||
<section class="span10 offset1">
|
||||
<section class="row-fluid footer-sections">
|
||||
<section class="span4">
|
||||
<h1><i class="icon-code"></i></h1>
|
||||
<div>
|
||||
<ul>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<h1><i class="icon-bar-chart"></i></h1>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="../graphs/class.html">Class Hierarchy Diagram</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<section class="span4">
|
||||
<h1><i class="icon-pushpin"></i></h1>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="../reports/errors.html">Errors</a></li>
|
||||
<li><a href="../reports/markers.html">Markers</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
<section class="row-fluid">
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
213
docs/api/files/CAsciiArt.php.txt
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
/**
|
||||
* Create an ASCII version of an image.
|
||||
*
|
||||
*/
|
||||
class CAsciiArt
|
||||
{
|
||||
/**
|
||||
* Character set to use.
|
||||
*/
|
||||
private $characterSet = array(
|
||||
'one' => "#0XT|:,.' ",
|
||||
'two' => "@%#*+=-:. ",
|
||||
'three' => "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. "
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Current character set.
|
||||
*/
|
||||
private $characters = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Length of current character set.
|
||||
*/
|
||||
private $charCount = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Scale of the area to swap to a character.
|
||||
*/
|
||||
private $scale = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Strategy to calculate luminance.
|
||||
*/
|
||||
private $luminanceStrategy = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor which sets default options.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setOptions();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a custom character set.
|
||||
*
|
||||
* @param string $key for the character set.
|
||||
* @param string $value for the character set.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addCharacterSet($key, $value)
|
||||
{
|
||||
$this->characterSet[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set options for processing, defaults are available.
|
||||
*
|
||||
* @param array $options to use as default settings.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create an Ascii image from an image file.
|
||||
*
|
||||
* @param string $filename of the image to use.
|
||||
*
|
||||
* @return string $ascii with the ASCII image.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the luminance from a region of an image using average color value.
|
||||
*
|
||||
* @param string $img the image.
|
||||
* @param integer $x1 the area to get pixels from.
|
||||
* @param integer $y1 the area to get pixels from.
|
||||
* @param integer $x2 the area to get pixels from.
|
||||
* @param integer $y2 the area to get pixels from.
|
||||
*
|
||||
* @return integer $luminance with a value between 0 and 100.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculate luminance value with different strategies.
|
||||
*
|
||||
* @param integer $red The color red.
|
||||
* @param integer $green The color green.
|
||||
* @param integer $blue The color blue.
|
||||
*
|
||||
* @return float $luminance with a value between 0 and 1.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Translate the luminance value to a character.
|
||||
*
|
||||
* @param string $position a value between 0-100 representing the
|
||||
* luminance.
|
||||
*
|
||||
* @return string with the ascii character.
|
||||
*/
|
||||
public function luminance2character($luminance)
|
||||
{
|
||||
$position = (int) round($luminance * ($this->charCount - 1));
|
||||
$char = $this->characters[$position];
|
||||
return $char;
|
||||
}
|
||||
}
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-785926434"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1589006485"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-785926434" class="accordion-body collapse in">
|
||||
<div id="namespace-1589006485" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -245,7 +246,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -21,6 +21,33 @@ class CHttpGet
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Build an encoded url.
|
||||
*
|
||||
* @param string $baseUrl This is the original url which will be merged.
|
||||
* @param string $merge Thse parts should be merged into the baseUrl,
|
||||
* the format is as parse_url.
|
||||
*
|
||||
* @return string $url as the modified url.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the url for the request.
|
||||
*
|
||||
@@ -30,6 +57,18 @@ class CHttpGet
|
||||
*/
|
||||
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;
|
||||
}
|
||||
@@ -62,7 +101,14 @@ class CHttpGet
|
||||
*/
|
||||
public function parseHeader()
|
||||
{
|
||||
$header = explode("\r\n", rtrim($this->response['headerRaw'], "\r\n"));
|
||||
//$header = explode("\r\n", rtrim($this->response['headerRaw'], "\r\n"));
|
||||
|
||||
$rawHeaders = rtrim($this->response['headerRaw'], "\r\n");
|
||||
# Handle multiple responses e.g. with redirections (proxies too)
|
||||
$headerGroups = explode("\r\n\r\n", $rawHeaders);
|
||||
# We're only interested in the last one
|
||||
$header = explode("\r\n", end($headerGroups));
|
||||
|
||||
$output = array();
|
||||
|
||||
if ('HTTP' === substr($header[0], 0, 4)) {
|
||||
@@ -86,6 +132,8 @@ class CHttpGet
|
||||
*
|
||||
* @param boolean $debug set to true to dump headers.
|
||||
*
|
||||
* @throws Exception when curl fails to retrieve url.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function doGet($debug = false)
|
||||
@@ -99,6 +147,8 @@ class CHttpGet
|
||||
CURLINFO_HEADER_OUT => $debug,
|
||||
CURLOPT_CONNECTTIMEOUT => 5,
|
||||
CURLOPT_TIMEOUT => 5,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_MAXREDIRS => 2,
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
@@ -106,7 +156,7 @@ class CHttpGet
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if (!$response) {
|
||||
return false;
|
||||
throw new Exception("Failed retrieving url, details follows: " . curl_error($ch));
|
||||
}
|
||||
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-163130442"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1494355388"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-163130442" class="accordion-body collapse in">
|
||||
<div id="namespace-1494355388" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -245,7 +246,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -63,6 +63,13 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add HTTP headers for outputing image.
|
||||
*/
|
||||
private $HTTPHeader = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default background color, red, green, blue, alpha.
|
||||
*
|
||||
@@ -113,13 +120,6 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The root folder of images (only used in constructor to create $pathToImage?).
|
||||
*/
|
||||
private $imageFolder;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Image filename, may include subdirectory, relative from $imageFolder
|
||||
*/
|
||||
@@ -193,6 +193,7 @@ class CImage
|
||||
* Path to command for filter optimize, for example optipng or null.
|
||||
*/
|
||||
private $pngFilter;
|
||||
private $pngFilterCmd;
|
||||
|
||||
|
||||
|
||||
@@ -200,13 +201,16 @@ class CImage
|
||||
* Path to command for deflate optimize, for example pngout or null.
|
||||
*/
|
||||
private $pngDeflate;
|
||||
private $pngDeflateCmd;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Path to command to optimize jpeg images, for example jpegtran or null.
|
||||
*/
|
||||
private $jpegOptimize;
|
||||
private $jpegOptimize;
|
||||
private $jpegOptimizeCmd;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -282,6 +286,56 @@ class CImage
|
||||
private $fillToFit;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To store value for option scale.
|
||||
*/
|
||||
private $scale;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To store value for option.
|
||||
*/
|
||||
private $rotateBefore;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To store value for option.
|
||||
*/
|
||||
private $rotateAfter;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To store value for option.
|
||||
*/
|
||||
private $autoRotate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To store value for option.
|
||||
*/
|
||||
private $sharpen;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To store value for option.
|
||||
*/
|
||||
private $emboss;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To store value for option.
|
||||
*/
|
||||
private $blur;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used with option area to set which parts of the image to use.
|
||||
*/
|
||||
@@ -318,6 +372,38 @@ class CImage
|
||||
private $useCache = true;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set whitelist for valid hostnames from where remote source can be
|
||||
* downloaded.
|
||||
*/
|
||||
private $remoteHostWhitelist = null;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Do verbose logging to file by setting this to a filename.
|
||||
*/
|
||||
private $verboseFileName = null;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Output to ascii can take som options as an array.
|
||||
*/
|
||||
private $asciiOptions = array();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Image copy strategy, defaults to RESAMPLE.
|
||||
*/
|
||||
const RESIZE = 1;
|
||||
const RESAMPLE = 2;
|
||||
private $copyStrategy = NULL;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Properties, the class is mutable and the method setOptions()
|
||||
* decides (partly) what properties are created.
|
||||
@@ -332,9 +418,7 @@ class CImage
|
||||
public $crop_x;
|
||||
public $crop_y;
|
||||
public $filters;
|
||||
private $type; // Calculated from source image
|
||||
private $attr; // Calculated from source image
|
||||
private $useOriginal; // Use original image if possible
|
||||
|
||||
|
||||
|
||||
@@ -391,9 +475,7 @@ class CImage
|
||||
/**
|
||||
* Use cache or not.
|
||||
*
|
||||
* @todo clean up how $this->noCache is used in other methods.
|
||||
*
|
||||
* @param string $use true or false to use cache.
|
||||
* @param boolean $use true or false to use cache.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -405,6 +487,27 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create and save a dummy image. Use dimensions as stated in
|
||||
* $this->newWidth, or $width or default to 100 (same for height.
|
||||
*
|
||||
* @param integer $width use specified width for image dimension.
|
||||
* @param integer $height use specified width for image dimension.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow or disallow remote image download.
|
||||
*
|
||||
@@ -418,10 +521,12 @@ class CImage
|
||||
$this->allowRemote = $allow;
|
||||
$this->remotePattern = is_null($pattern) ? $this->remotePattern : $pattern;
|
||||
|
||||
$this->log("Set remote download to: "
|
||||
$this->log(
|
||||
"Set remote download to: "
|
||||
. ($this->allowRemote ? "true" : "false")
|
||||
. " using pattern "
|
||||
. $this->remotePattern);
|
||||
. $this->remotePattern
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -445,7 +550,7 @@ class CImage
|
||||
|
||||
|
||||
/**
|
||||
* Set whitelist for valid hostnames from where remote source can be
|
||||
* Set whitelist for valid hostnames from where remote source can be
|
||||
* downloaded.
|
||||
*
|
||||
* @param array $whitelist with regexp hostnames to allow download from.
|
||||
@@ -455,14 +560,17 @@ class CImage
|
||||
public function setRemoteHostWhitelist($whitelist = null)
|
||||
{
|
||||
$this->remoteHostWhitelist = $whitelist;
|
||||
$this->log("Setting remote host whitelist to: " . print_r($this->remoteHostWhitelist, 1));
|
||||
$this->log(
|
||||
"Setting remote host whitelist to: "
|
||||
. (is_null($whitelist) ? "null" : print_r($whitelist, 1))
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check if the hostname for the remote image, is on a whitelist,
|
||||
* Check if the hostname for the remote image, is on a whitelist,
|
||||
* if the whitelist is defined.
|
||||
*
|
||||
* @param string $src the remote source.
|
||||
@@ -472,14 +580,18 @@ class CImage
|
||||
public function isRemoteSourceOnWhitelist($src)
|
||||
{
|
||||
if (is_null($this->remoteHostWhitelist)) {
|
||||
$allow = true;
|
||||
} else {
|
||||
$whitelist = new CWhitelist();
|
||||
$hostname = parse_url($src, PHP_URL_HOST);
|
||||
$allow = $whitelist->check($hostname, $this->remoteHostWhitelist);
|
||||
$this->log("Remote host on whitelist not configured - allowing.");
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->log("Remote host is on whitelist: " . ($allow ? "true" : "false"));
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -504,6 +616,26 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Normalize the file extension.
|
||||
*
|
||||
* @param string $extension of image file or skip to use internal.
|
||||
*
|
||||
* @return string $extension as a normalized file extension.
|
||||
*/
|
||||
private function normalizeFileExtension($extension = null)
|
||||
{
|
||||
$extension = strtolower($extension ? $extension : $this->extension);
|
||||
|
||||
if ($extension == 'jpeg') {
|
||||
$extension = 'jpg';
|
||||
}
|
||||
|
||||
return $extension;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Download a remote image and return path to its local copy.
|
||||
*
|
||||
@@ -537,7 +669,7 @@ class CImage
|
||||
$src = $remote->download($src);
|
||||
|
||||
$this->log("Remote HTTP status: " . $remote->getStatus());
|
||||
$this->log("Remote item has local cached file: $src");
|
||||
$this->log("Remote item is in local cache: $src");
|
||||
$this->log("Remote details on cache:" . print_r($remote->getDetails(), true));
|
||||
|
||||
return $src;
|
||||
@@ -546,16 +678,18 @@ class CImage
|
||||
|
||||
|
||||
/**
|
||||
* Set src file.
|
||||
* Set source file to use as image source.
|
||||
*
|
||||
* @param string $src of image.
|
||||
* @param string $dir as base directory where images are.
|
||||
* @param string $dir as optional base directory where images are.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSource($src, $dir = null)
|
||||
{
|
||||
if (!isset($src)) {
|
||||
$this->imageSrc = null;
|
||||
$this->pathToImage = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -569,9 +703,9 @@ class CImage
|
||||
$src = basename($src);
|
||||
}
|
||||
|
||||
$this->imageSrc = ltrim($src, '/');
|
||||
$this->imageFolder = rtrim($dir, '/');
|
||||
$this->pathToImage = $this->imageFolder . '/' . $this->imageSrc;
|
||||
$this->imageSrc = ltrim($src, '/');
|
||||
$imageFolder = rtrim($dir, '/');
|
||||
$this->pathToImage = $imageFolder . '/' . $this->imageSrc;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -582,23 +716,23 @@ class CImage
|
||||
* Set target file.
|
||||
*
|
||||
* @param string $src of target image.
|
||||
* @param string $dir as base directory where images are stored.
|
||||
* @param string $dir as optional base directory where images are stored.
|
||||
* Uses $this->saveFolder if null.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTarget($src = null, $dir = null)
|
||||
{
|
||||
if (!(isset($src) && isset($dir))) {
|
||||
if (!isset($src)) {
|
||||
$this->cacheFileName = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->saveFolder = $dir;
|
||||
$this->cacheFileName = $dir . '/' . $src;
|
||||
if (isset($dir)) {
|
||||
$this->saveFolder = rtrim($dir, '/');
|
||||
}
|
||||
|
||||
/* Allow readonly cache
|
||||
is_writable($this->saveFolder)
|
||||
or $this->raiseError('Target directory is not writable.');
|
||||
*/
|
||||
$this->cacheFileName = $this->saveFolder . '/' . $src;
|
||||
|
||||
// Sanitize filename
|
||||
$this->cacheFileName = preg_replace('/^a-zA-Z0-9\.-_/', '', $this->cacheFileName);
|
||||
@@ -609,6 +743,18 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get filename of target file.
|
||||
*
|
||||
* @return Boolean|String as filename of target or false if not set.
|
||||
*/
|
||||
public function getTarget()
|
||||
{
|
||||
return $this->cacheFileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set options to use when processing image.
|
||||
*
|
||||
@@ -656,11 +802,6 @@ class CImage
|
||||
// Output format
|
||||
'outputFormat' => null,
|
||||
'dpr' => 1,
|
||||
|
||||
// Options for saving
|
||||
//'quality' => null,
|
||||
//'compress' => null,
|
||||
//'saveAs' => null,
|
||||
);
|
||||
|
||||
// Convert crop settings from string to array
|
||||
@@ -777,7 +918,9 @@ class CImage
|
||||
|
||||
// Get details on image
|
||||
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
||||
!empty($info) or $this->raiseError("The file doesn't seem to be an image.");
|
||||
if (empty($info)) {
|
||||
throw new Exception("The file doesn't seem to be a valid image.");
|
||||
}
|
||||
|
||||
if ($this->verbose) {
|
||||
$this->log("Loading image details for: {$file}");
|
||||
@@ -974,7 +1117,7 @@ class CImage
|
||||
$this->cropHeight = round($height / $ratio);
|
||||
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
||||
|
||||
} else if ($this->fillToFit) {
|
||||
} elseif ($this->fillToFit) {
|
||||
|
||||
// Use newWidth and newHeigh as defined width/height,
|
||||
// image should fit the area.
|
||||
@@ -1152,13 +1295,15 @@ class CImage
|
||||
/**
|
||||
* Generate filename to save file in cache.
|
||||
*
|
||||
* @param string $base as basepath for storing file.
|
||||
* @param string $base as optional basepath for storing file.
|
||||
* @param boolean $useSubdir use or skip the subdir part when creating the
|
||||
* filename.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function generateFilename($base)
|
||||
public function generateFilename($base = null, $useSubdir = true)
|
||||
{
|
||||
$parts = pathinfo($this->pathToImage);
|
||||
$filename = basename($this->pathToImage);
|
||||
$cropToFit = $this->cropToFit ? '_cf' : null;
|
||||
$fillToFit = $this->fillToFit ? '_ff' : null;
|
||||
$crop_x = $this->crop_x ? "_x{$this->crop_x}" : null;
|
||||
@@ -1170,6 +1315,14 @@ class CImage
|
||||
$rotateBefore = $this->rotateBefore ? "_rb{$this->rotateBefore}" : null;
|
||||
$rotateAfter = $this->rotateAfter ? "_ra{$this->rotateAfter}" : null;
|
||||
|
||||
$saveAs = $this->normalizeFileExtension();
|
||||
$saveAs = $saveAs ? "_$saveAs" : null;
|
||||
|
||||
$copyStrat = null;
|
||||
if ($this->copyStrategy === self::RESIZE) {
|
||||
$copyStrat = "_rs";
|
||||
}
|
||||
|
||||
$width = $this->newWidth;
|
||||
$height = $this->newHeight;
|
||||
|
||||
@@ -1187,7 +1340,7 @@ class CImage
|
||||
if (is_array($filter)) {
|
||||
$filters .= "_f{$filter['id']}";
|
||||
for ($i=1; $i<=$filter['argc']; $i++) {
|
||||
$filters .= ":".$filter["arg{$i}"];
|
||||
$filters .= "-".$filter["arg{$i}"];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1200,16 +1353,6 @@ class CImage
|
||||
|
||||
$autoRotate = $this->autoRotate ? 'ar' : null;
|
||||
|
||||
$this->extension = isset($this->extension)
|
||||
? $this->extension
|
||||
: (isset($parts['extension'])
|
||||
? $parts['extension']
|
||||
: null);
|
||||
|
||||
$extension = empty($this->extension)
|
||||
? null
|
||||
: "." . $this->extension;
|
||||
|
||||
$optimize = $this->jpegOptimize ? 'o' : null;
|
||||
$optimize .= $this->pngFilter ? 'f' : null;
|
||||
$optimize .= $this->pngDeflate ? 'd' : null;
|
||||
@@ -1224,14 +1367,20 @@ class CImage
|
||||
$upscale = '_nu';
|
||||
}
|
||||
|
||||
$subdir = str_replace('/', '-', dirname($this->imageSrc));
|
||||
$subdir = ($subdir == '.') ? '_.' : $subdir;
|
||||
$file = $subdir . '_' . $parts['filename'] . '_' . $width . '_'
|
||||
$subdir = null;
|
||||
if ($useSubdir === true) {
|
||||
$subdir = str_replace('/', '-', dirname($this->imageSrc));
|
||||
$subdir = ($subdir == '.') ? '_.' : $subdir;
|
||||
$subdir .= '_';
|
||||
}
|
||||
|
||||
$file = $subdir . $filename . '_' . $width . '_'
|
||||
. $height . $offset . $crop . $cropToFit . $fillToFit
|
||||
. $crop_x . $crop_y . $upscale
|
||||
. $quality . $filters . $sharpen . $emboss . $blur . $palette . $optimize
|
||||
. $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor . $convolve
|
||||
. $extension;
|
||||
. $quality . $filters . $sharpen . $emboss . $blur . $palette
|
||||
. $optimize . $compress
|
||||
. $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor
|
||||
. $convolve . $copyStrat . $saveAs;
|
||||
|
||||
return $this->setTarget($file, $base);
|
||||
}
|
||||
@@ -1274,23 +1423,7 @@ class CImage
|
||||
|
||||
|
||||
/**
|
||||
* To display error message when failing to load somehow corrupt image.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function failedToLoad()
|
||||
{
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
echo("CImage.php says 404: Fatal error when opening image.<br>");
|
||||
$image = imagecreatefromstring(file_get_contents($this->pathToImage));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load image from disk. Try to load image without verbose error message,
|
||||
* Load image from disk. Try to load image without verbose error message,
|
||||
* if fail, load again and display error messages.
|
||||
*
|
||||
* @param string $src of image.
|
||||
@@ -1307,9 +1440,12 @@ class CImage
|
||||
|
||||
$this->loadImageDetails($this->pathToImage);
|
||||
|
||||
$this->image = @imagecreatefromstring(file_get_contents($this->pathToImage));
|
||||
$this->image or $this->failedToLoad();
|
||||
$this->image = imagecreatefromstring(file_get_contents($this->pathToImage));
|
||||
if ($this->image === false) {
|
||||
throw new Exception("Could not load image.");
|
||||
}
|
||||
|
||||
/* Removed v0.7.7
|
||||
if (image_type_to_mime_type($this->fileType) == 'image/png') {
|
||||
$type = $this->getPngType();
|
||||
$hasFewColors = imagecolorstotal($this->image);
|
||||
@@ -1321,14 +1457,15 @@ class CImage
|
||||
$this->palette = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($this->verbose) {
|
||||
$this->log("Image successfully loaded from file.");
|
||||
$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");
|
||||
$this->log(" Detected transparent color = " . ($index >= 0 ? implode(", ", imagecolorsforindex($this->image, $index)) : "NONE") . " at index = $index");
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -1339,44 +1476,80 @@ class CImage
|
||||
/**
|
||||
* Get the type of PNG image.
|
||||
*
|
||||
* @param string $filename to use instead of default.
|
||||
*
|
||||
* @return int as the type of the png-image
|
||||
*
|
||||
*/
|
||||
private function getPngType()
|
||||
public function getPngType($filename = null)
|
||||
{
|
||||
$pngType = ord(file_get_contents($this->pathToImage, false, null, 25, 1));
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the type of PNG image as a verbose string.
|
||||
*
|
||||
* @param integer $type to use, default is to check the type.
|
||||
* @param string $filename to use instead of default.
|
||||
*
|
||||
* @return int as the type of the png-image
|
||||
*
|
||||
*/
|
||||
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:
|
||||
$this->log("PNG is type 0, Greyscale.");
|
||||
$text = "PNG is type 0, Greyscale$transparent";
|
||||
break;
|
||||
|
||||
case self::PNG_RGB:
|
||||
$this->log("PNG is type 2, RGB");
|
||||
$text = "PNG is type 2, RGB$transparent";
|
||||
break;
|
||||
|
||||
case self::PNG_RGB_PALETTE:
|
||||
$this->log("PNG is type 3, RGB with palette");
|
||||
$text = "PNG is type 3, RGB with palette$transparent";
|
||||
break;
|
||||
|
||||
case self::PNG_GREYSCALE_ALPHA:
|
||||
$this->Log("PNG is type 4, Greyscale with alpha channel");
|
||||
$text = "PNG is type 4, Greyscale with alpha channel";
|
||||
break;
|
||||
|
||||
case self::PNG_RGB_ALPHA:
|
||||
$this->Log("PNG is type 6, RGB with alpha channel (PNG 32-bit)");
|
||||
$text = "PNG is type 6, RGB with alpha channel (PNG 32-bit)";
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->Log("PNG is UNKNOWN type, is it really a PNG image?");
|
||||
$text = "PNG is UNKNOWN type, is it really a PNG image?";
|
||||
}
|
||||
|
||||
return $pngType;
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculate number of colors in an image.
|
||||
*
|
||||
@@ -1412,7 +1585,7 @@ class CImage
|
||||
*/
|
||||
public function preResize()
|
||||
{
|
||||
$this->log("Pre-process before resizing");
|
||||
$this->log("### Pre-process before resizing");
|
||||
|
||||
// Rotate image
|
||||
if ($this->rotateBefore) {
|
||||
@@ -1445,6 +1618,39 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resize or resample the image while resizing.
|
||||
*
|
||||
* @param int $strategy as CImage::RESIZE or CImage::RESAMPLE
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCopyResizeStrategy($strategy)
|
||||
{
|
||||
$this->copyStrategy = $strategy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resize and or crop the image.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resize and or crop the image.
|
||||
*
|
||||
@@ -1453,7 +1659,7 @@ class CImage
|
||||
public function resize()
|
||||
{
|
||||
|
||||
$this->log("Starting to Resize()");
|
||||
$this->log("### Starting to Resize()");
|
||||
$this->log("Upscale = '$this->upscale'");
|
||||
|
||||
// Only use a specified area of the image, $this->offset is defining the area to use
|
||||
@@ -1513,7 +1719,7 @@ class CImage
|
||||
$cropY = round(($this->cropHeight/2) - ($this->newHeight/2));
|
||||
$imgPreCrop = $this->CreateImageKeepTransparency($this->cropWidth, $this->cropHeight);
|
||||
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
|
||||
imagecopyresampled($imgPreCrop, $this->image, 0, 0, 0, 0, $this->cropWidth, $this->cropHeight, $this->width, $this->height);
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -1521,7 +1727,7 @@ class CImage
|
||||
$this->width = $this->newWidth;
|
||||
$this->height = $this->newHeight;
|
||||
|
||||
} else if ($this->fillToFit) {
|
||||
} elseif ($this->fillToFit) {
|
||||
|
||||
// Resize by fill to fit
|
||||
$this->log("Resizing using strategy - Fill to fit");
|
||||
@@ -1552,7 +1758,7 @@ class CImage
|
||||
} else {
|
||||
$imgPreFill = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);
|
||||
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
|
||||
imagecopyresampled($imgPreFill, $this->image, 0, 0, 0, 0, $this->fillWidth, $this->fillHeight, $this->width, $this->height);
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -1560,7 +1766,7 @@ class CImage
|
||||
$this->width = $this->newWidth;
|
||||
$this->height = $this->newHeight;
|
||||
|
||||
} else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
||||
} elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
||||
|
||||
// Resize it
|
||||
$this->log("Resizing, new height and/or width");
|
||||
@@ -1581,10 +1787,10 @@ class CImage
|
||||
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
||||
$posX = round(($this->newWidth - $this->width) / 2);
|
||||
$posY = round(($this->newHeight - $this->height) / 2);
|
||||
} else if ($this->newWidth > $this->width) {
|
||||
} elseif ($this->newWidth > $this->width) {
|
||||
$posX = round(($this->newWidth - $this->width) / 2);
|
||||
$cropY = round(($this->height - $this->newHeight) / 2);
|
||||
} else if ($this->newHeight > $this->height) {
|
||||
} elseif ($this->newHeight > $this->height) {
|
||||
$posY = round(($this->newHeight - $this->height) / 2);
|
||||
$cropX = round(($this->width - $this->newWidth) / 2);
|
||||
}
|
||||
@@ -1598,7 +1804,7 @@ class CImage
|
||||
}
|
||||
} else {
|
||||
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
|
||||
imagecopyresampled($imageResized, $this->image, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);
|
||||
$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;
|
||||
@@ -1617,7 +1823,7 @@ class CImage
|
||||
*/
|
||||
public function postResize()
|
||||
{
|
||||
$this->log("Post-process after resizing");
|
||||
$this->log("### Post-process after resizing");
|
||||
|
||||
// Rotate image
|
||||
if ($this->rotateAfter) {
|
||||
@@ -2013,7 +2219,10 @@ class CImage
|
||||
imagealphablending($img, false);
|
||||
imagesavealpha($img, true);
|
||||
|
||||
$index = imagecolortransparent($this->image);
|
||||
$index = $this->image
|
||||
? imagecolortransparent($this->image)
|
||||
: -1;
|
||||
|
||||
if ($index != -1) {
|
||||
|
||||
imagealphablending($img, true);
|
||||
@@ -2074,10 +2283,11 @@ class CImage
|
||||
*/
|
||||
protected function getTargetImageExtension()
|
||||
{
|
||||
// switch on mimetype
|
||||
if (isset($this->extension)) {
|
||||
return strtolower($this->extension);
|
||||
} else {
|
||||
return image_type_to_extension($this->fileType);
|
||||
return substr(image_type_to_extension($this->fileType), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2086,21 +2296,29 @@ class CImage
|
||||
/**
|
||||
* Save image.
|
||||
*
|
||||
* @param string $src as target filename.
|
||||
* @param string $base as base directory where to store images.
|
||||
* @param string $src as target filename.
|
||||
* @param string $base as base directory where to store images.
|
||||
* @param boolean $overwrite or not, default to always overwrite file.
|
||||
*
|
||||
* @return $this or false if no folder is set.
|
||||
*/
|
||||
public function save($src = null, $base = null)
|
||||
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;
|
||||
}
|
||||
|
||||
is_writable($this->saveFolder)
|
||||
or $this->raiseError('Target directory is not writable.');
|
||||
|
||||
switch($this->getTargetImageExtension()) {
|
||||
$type = $this->getTargetImageExtension();
|
||||
$this->Log("Saving image as " . $type);
|
||||
switch($type) {
|
||||
|
||||
case 'jpeg':
|
||||
case 'jpg':
|
||||
@@ -2194,8 +2412,6 @@ class CImage
|
||||
return $this;
|
||||
}
|
||||
|
||||
$alias = $alias . "." . $this->getTargetImageExtension();
|
||||
|
||||
if (is_readable($alias)) {
|
||||
unlink($alias);
|
||||
}
|
||||
@@ -2213,11 +2429,28 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add HTTP header for putputting together with image.
|
||||
*
|
||||
* @param string $type the header type such as "Cache-Control"
|
||||
* @param string $value the value to use
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addHTTPHeader($type, $value)
|
||||
{
|
||||
$this->HTTPHeader[$type] = $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output image to browser using caching.
|
||||
*
|
||||
* @param string $file to read and output, default is to use $this->cacheFileName
|
||||
* @param string $format set to json to output file as json object with details
|
||||
* @param string $file to read and output, default is to
|
||||
* use $this->cacheFileName
|
||||
* @param string $format set to json to output file as json
|
||||
* object with details
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2237,6 +2470,10 @@ class CImage
|
||||
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");
|
||||
@@ -2250,6 +2487,10 @@ class CImage
|
||||
header('Last-Modified: ' . $gmdate . " GMT");
|
||||
}
|
||||
|
||||
foreach($this->HTTPHeader as $key => $val) {
|
||||
header("$key: $val");
|
||||
}
|
||||
|
||||
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {
|
||||
|
||||
if ($this->verbose) {
|
||||
@@ -2262,18 +2503,25 @@ class CImage
|
||||
|
||||
} else {
|
||||
|
||||
if ($this->verbose) {
|
||||
$this->log("Last modified: " . $gmdate . " GMT");
|
||||
$this->verboseOutput();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get details on image
|
||||
$info = getimagesize($file);
|
||||
!empty($info) or $this->raiseError("The file doesn't seem to be an image.");
|
||||
$mime = $info['mime'];
|
||||
$size = filesize($file);
|
||||
|
||||
header('Content-type: ' . $mime);
|
||||
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("Content-length: $size");
|
||||
readfile($file);
|
||||
}
|
||||
|
||||
@@ -2314,6 +2562,18 @@ class CImage
|
||||
$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")) {
|
||||
@@ -2325,6 +2585,38 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set options for creating ascii version of image.
|
||||
*
|
||||
* @param array $options empty to use default or set options to change.
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
public function setAsciiOptions($options = array())
|
||||
{
|
||||
$this->asciiOptions = $options;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create an ASCII version from the image details.
|
||||
*
|
||||
* @param string $file the file to output.
|
||||
*
|
||||
* @return string ASCII representation of the image.
|
||||
*/
|
||||
public function ascii($file = null)
|
||||
{
|
||||
$file = $file ? $file : $this->cacheFileName;
|
||||
|
||||
$asciiArt = new CAsciiArt();
|
||||
$asciiArt->setOptions($this->asciiOptions);
|
||||
return $asciiArt->createFromFile($file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Log an event if verbose mode.
|
||||
*
|
||||
@@ -2343,6 +2635,21 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Do verbose output to a file.
|
||||
*
|
||||
* @param string $fileName where to write the verbose output.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setVerboseToFile($fileName)
|
||||
{
|
||||
$this->log("Setting verbose output to file.");
|
||||
$this->verboseFileName = $fileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Do verbose output and print out the log and the actual images.
|
||||
*
|
||||
@@ -2368,15 +2675,17 @@ class CImage
|
||||
}
|
||||
}
|
||||
|
||||
echo <<<EOD
|
||||
<!doctype html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
<title>CImage verbose output</title>
|
||||
<style>body{background-color: #ddd}</style>
|
||||
if (!is_null($this->verboseFileName)) {
|
||||
file_put_contents(
|
||||
$this->verboseFileName,
|
||||
str_replace("<br/>", "\n", $log)
|
||||
);
|
||||
} else {
|
||||
echo <<<EOD
|
||||
<h1>CImage Verbose Output</h1>
|
||||
<pre>{$log}</pre>
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-609156684"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1879794739"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-609156684" class="accordion-body collapse in">
|
||||
<div id="namespace-1879794739" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -245,7 +246,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -48,7 +48,7 @@ class CRemoteImage
|
||||
|
||||
|
||||
/**
|
||||
* Base name of cache file for downloaded item.
|
||||
* Base name of cache file for downloaded item and name of image.
|
||||
*/
|
||||
private $fileName;
|
||||
|
||||
@@ -61,13 +61,6 @@ class CRemoteImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Filename for image-file.
|
||||
*/
|
||||
private $fileImage;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cache details loaded from file.
|
||||
*/
|
||||
@@ -75,16 +68,6 @@ class CRemoteImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get status of last HTTP request.
|
||||
*
|
||||
@@ -157,34 +140,14 @@ class CRemoteImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Translate a content type to a file extension.
|
||||
*
|
||||
* @param string $type a valid content type.
|
||||
*
|
||||
* @return string as file extension or false if no match.
|
||||
*/
|
||||
function contentTypeToFileExtension($type) {
|
||||
$extension = array(
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/gif' => 'gif',
|
||||
);
|
||||
|
||||
return isset($extension[$type])
|
||||
? $extension[$type]
|
||||
: false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set header fields.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
function setHeaderFields() {
|
||||
$this->http->setHeader("User-Agent", "CImage/0.6 (PHP/". phpversion() . " cURL)");
|
||||
public function setHeaderFields()
|
||||
{
|
||||
$this->http->setHeader("User-Agent", "CImage/0.7.2 (PHP/". phpversion() . " cURL)");
|
||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||
|
||||
if ($this->useCache) {
|
||||
@@ -202,37 +165,31 @@ class CRemoteImage
|
||||
*
|
||||
* @return string as path to saved file or false if not saved.
|
||||
*/
|
||||
function save() {
|
||||
|
||||
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();
|
||||
$extension = $this->contentTypeToFileExtension($type);
|
||||
|
||||
$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['File-Extension'] = $extension;
|
||||
$this->cache['Url'] = $this->url;
|
||||
|
||||
if ($lastModified) {
|
||||
$this->cache['Last-Modified'] = gmdate("D, d M Y H:i:s T", $lastModified);
|
||||
}
|
||||
|
||||
if ($extension) {
|
||||
// Save only if body is a valid image
|
||||
$body = $this->http->getBody();
|
||||
$img = imagecreatefromstring($body);
|
||||
|
||||
$this->fileImage = $this->fileName . "." . $extension;
|
||||
|
||||
// Save only if body is a valid image
|
||||
$body = $this->http->getBody();
|
||||
$img = imagecreatefromstring($body);
|
||||
|
||||
if ($img !== false) {
|
||||
file_put_contents($this->fileImage, $body);
|
||||
file_put_contents($this->fileJson, json_encode($this->cache));
|
||||
return $this->fileImage;
|
||||
}
|
||||
if ($img !== false) {
|
||||
file_put_contents($this->fileName, $body);
|
||||
file_put_contents($this->fileJson, json_encode($this->cache));
|
||||
return $this->fileName;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -245,21 +202,21 @@ class CRemoteImage
|
||||
*
|
||||
* @return string as path to cached file.
|
||||
*/
|
||||
function updateCacheDetails() {
|
||||
|
||||
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;
|
||||
$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->fileImage;
|
||||
return $this->fileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,10 +226,12 @@ class CRemoteImage
|
||||
*
|
||||
* @param string $url a remote url.
|
||||
*
|
||||
* @throws Exception when status code does not match 200 or 304.
|
||||
*
|
||||
* @return string as path to downloaded file or false if failed.
|
||||
*/
|
||||
function download($url) {
|
||||
|
||||
public function download($url)
|
||||
{
|
||||
$this->http = new CHttpGet();
|
||||
$this->url = $url;
|
||||
|
||||
@@ -296,12 +255,12 @@ class CRemoteImage
|
||||
if ($this->status === 200) {
|
||||
$this->isCacheWritable();
|
||||
return $this->save();
|
||||
} else if ($this->status === 304) {
|
||||
} elseif ($this->status === 304) {
|
||||
$this->isCacheWritable();
|
||||
return $this->updateCacheDetails();
|
||||
}
|
||||
|
||||
return false;
|
||||
throw new Exception("Unknown statuscode when downloading remote image: " . $this->status);
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +272,7 @@ class CRemoteImage
|
||||
*/
|
||||
public function loadCacheDetails()
|
||||
{
|
||||
$cacheFile = str_replace(array("/", ":", "#", ".", "?"), "-", $this->url);
|
||||
$cacheFile = md5($this->url);
|
||||
$this->fileName = $this->saveFolder . $cacheFile;
|
||||
$this->fileJson = $this->fileName . ".json";
|
||||
if (is_readable($this->fileJson)) {
|
||||
@@ -330,15 +289,15 @@ class CRemoteImage
|
||||
*/
|
||||
public function getCachedSource()
|
||||
{
|
||||
$this->fileImage = $this->fileName . "." . $this->cache['File-Extension'];
|
||||
$imageExists = is_readable($this->fileImage);
|
||||
$imageExists = is_readable($this->fileName);
|
||||
|
||||
// Is cache valid?
|
||||
$date = strtotime($this->cache['Date']);
|
||||
$maxAge = $this->cache['Max-Age'];
|
||||
$now = time();
|
||||
$now = time();
|
||||
|
||||
if ($imageExists && $date + $maxAge > $now) {
|
||||
return $this->fileImage;
|
||||
return $this->fileName;
|
||||
}
|
||||
|
||||
// Prepare for a 304 if available
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1345074256"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1920829892"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-1345074256" class="accordion-body collapse in">
|
||||
<div id="namespace-1920829892" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -245,7 +246,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -13,21 +13,21 @@ class CWhitelist
|
||||
|
||||
|
||||
/**
|
||||
* Set the whitelist from an array of strings, each item in the
|
||||
* Set the whitelist from an array of strings, each item in the
|
||||
* whitelist should be a regexp without the surrounding / or #.
|
||||
*
|
||||
* @param array $whitelist with all valid options,
|
||||
* @param array $whitelist with all valid options,
|
||||
* default is to clear the whitelist.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function set($whitelist = array())
|
||||
{
|
||||
if (is_array($whitelist)) {
|
||||
$this->whitelist = $whitelist;
|
||||
} else {
|
||||
if (!is_array($whitelist)) {
|
||||
throw new Exception("Whitelist is not of a supported format.");
|
||||
}
|
||||
|
||||
$this->whitelist = $whitelist;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ class CWhitelist
|
||||
public function check($item, $whitelist = null)
|
||||
{
|
||||
if ($whitelist !== null) {
|
||||
$this->set($whitelist);
|
||||
}
|
||||
$this->set($whitelist);
|
||||
}
|
||||
|
||||
if (empty($item) or empty($this->whitelist)) {
|
||||
return false;
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-716918064"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-105414451"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-716918064" class="accordion-body collapse in">
|
||||
<div id="namespace-105414451" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -238,7 +239,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -17,7 +17,7 @@
|
||||
spl_autoload_register(function ($class) {
|
||||
//$path = CIMAGE_SOURCE_PATH . "/{$class}.php";
|
||||
$path = __DIR__ . "/{$class}.php";
|
||||
if(is_file($path)) {
|
||||
if (is_file($path)) {
|
||||
require($path);
|
||||
}
|
||||
});
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-110318675"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-543265601"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-110318675" class="accordion-body collapse in">
|
||||
<div id="namespace-543265601" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -219,7 +220,7 @@
|
||||
<h3 class=" ">errorPage()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">errorPage(string <span class="argument">$msg</span>) : void</pre>
|
||||
<p><em>Default configuration options, can be overridden in own config-file.</em></p>
|
||||
<p><em>Display error message.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
@@ -506,7 +507,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -106,12 +106,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -136,15 +136,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-805317831"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-112631378"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-805317831" class="accordion-body collapse in">
|
||||
<div id="namespace-112631378" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -240,7 +241,7 @@ config-file imgtest_config.php.</em></p>
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
1167
docs/api/files/webroot/img.php.txt
Normal file
386
docs/api/files/webroot/img_config.php.txt
Normal file
@@ -0,0 +1,386 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration for img.php, name the config file the same as your img.php and
|
||||
* append _config. If you are testing out some in imgtest.php then label that
|
||||
* config-file imgtest_config.php.
|
||||
*
|
||||
*/
|
||||
return array(
|
||||
|
||||
/**
|
||||
* Set mode as 'strict', 'production' or 'development'.
|
||||
*
|
||||
* Default values:
|
||||
* mode: 'production'
|
||||
*/
|
||||
//'mode' => 'production', // 'development', 'strict'
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Where are the sources for the classfiles.
|
||||
*
|
||||
* Default values:
|
||||
* autoloader: null // used from v0.6.2
|
||||
* cimage_class: null // used until v0.6.1
|
||||
*/
|
||||
'autoloader' => __DIR__ . '/../autoload.php',
|
||||
//'cimage_class' => __DIR__ . '/../CImage.php',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Paths, where are the images stored and where is the cache.
|
||||
* End all paths with a slash.
|
||||
*
|
||||
* Default values:
|
||||
* image_path: __DIR__ . '/img/'
|
||||
* cache_path: __DIR__ . '/../cache/'
|
||||
* alias_path: null
|
||||
*/
|
||||
'image_path' => __DIR__ . '/img/',
|
||||
'cache_path' => __DIR__ . '/../cache/',
|
||||
//'alias_path' => __DIR__ . '/img/alias/',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use password to protect from missusage, send &pwd=... or &password=..
|
||||
* with the request to match the password or set to false to disable.
|
||||
* Passwords are only used together with options for remote download
|
||||
* and aliasing.
|
||||
*
|
||||
* Create a passwords like this, depending on the type used:
|
||||
* text: 'my_password'
|
||||
* md5: md5('my_password')
|
||||
* hash: password_hash('my_password', PASSWORD_DEFAULT)
|
||||
*
|
||||
* Default values.
|
||||
* password_always: false // do not always require password,
|
||||
* password: false // as in do not use password
|
||||
* password_type: 'text' // use plain password, not encoded,
|
||||
*/
|
||||
//'password_always' => false, // always require password,
|
||||
//'password' => false, // "secret-password",
|
||||
//'password_type' => 'text', // supports 'text', 'md5', 'hash',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow or disallow downloading of remote images available on
|
||||
* remote servers. Default is to disallow remote download.
|
||||
*
|
||||
* When enabling remote download, the default is to allow download any
|
||||
* link starting with http or https. This can be changed using
|
||||
* remote_pattern.
|
||||
*
|
||||
* When enabling remote_whitelist a check is made that the hostname of the
|
||||
* source to download matches the whitelist. By default the check is
|
||||
* disabled and thereby allowing download from any hosts.
|
||||
*
|
||||
* Default values.
|
||||
* remote_allow: false
|
||||
* remote_pattern: null // use default values from CImage which is to
|
||||
* // allow download from any http- and
|
||||
* // https-source.
|
||||
* remote_whitelist: null // use default values from CImage which is to
|
||||
* // allow download from any hosts.
|
||||
*/
|
||||
//'remote_allow' => true,
|
||||
//'remote_pattern' => '#^https?://#',
|
||||
//'remote_whitelist' => array(
|
||||
// '\.facebook\.com$',
|
||||
// '^(?:images|photos-[a-z])\.ak\.instagram\.com$',
|
||||
// '\.google\.com$'
|
||||
//),
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A regexp for validating characters in the image or alias filename.
|
||||
*
|
||||
* Default value:
|
||||
* valid_filename: '#^[a-z0-9A-Z-/_ \.:]+$#'
|
||||
* valid_aliasname: '#^[a-z0-9A-Z-_]+$#'
|
||||
*/
|
||||
//'valid_filename' => '#^[a-z0-9A-Z-/_ \.:]+$#',
|
||||
//'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Change the default values for CImage quality and compression used
|
||||
* when saving images.
|
||||
*
|
||||
* Default value:
|
||||
* jpg_quality: null, integer between 0-100
|
||||
* png_compression: null, integer between 0-9
|
||||
*/
|
||||
//'jpg_quality' => 75,
|
||||
//'png_compression' => 1,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A function (hook) can be called after img.php has processed all
|
||||
* configuration options and before processing the image using CImage.
|
||||
* The function receives the $img variabel and an array with the
|
||||
* majority of current settings.
|
||||
*
|
||||
* Default value:
|
||||
* hook_before_CImage: null
|
||||
*/
|
||||
/*'hook_before_CImage' => function (CImage $img, Array $allConfig) {
|
||||
if ($allConfig['newWidth'] > 10) {
|
||||
$allConfig['newWidth'] *= 2;
|
||||
}
|
||||
return $allConfig;
|
||||
},*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add header for cache control when outputting images.
|
||||
*
|
||||
* Default value:
|
||||
* cache_control: null, or set to string
|
||||
*/
|
||||
//'cache_control' => "max-age=86400",
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The name representing a dummy image which is automatically created
|
||||
* and stored at the defined path. The dummy image can then be used
|
||||
* inplace of an original image as a placeholder.
|
||||
* The dummy_dir must be writable and it defaults to a subdir of the
|
||||
* cache directory.
|
||||
* Write protect the dummy_dir to prevent creation of new dummy images,
|
||||
* but continue to use the existing ones.
|
||||
*
|
||||
* Default value:
|
||||
* dummy_enabled: true as default, disable dummy feature by setting
|
||||
* to false.
|
||||
* dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.
|
||||
* dummy_dir: Defaults to subdirectory of 'cache_path',
|
||||
* named the same as 'dummy_filename'
|
||||
*/
|
||||
//'dummy_enabled' => true,
|
||||
//'dummy_filename' => 'dummy',
|
||||
//'dummy_dir' => 'some writable directory',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check that the imagefile is a file below 'image_path' using realpath().
|
||||
* Security constraint to avoid reaching images outside image_path.
|
||||
* This means that symbolic links to images outside the image_path will fail.
|
||||
*
|
||||
* Default value:
|
||||
* image_path_constraint: true
|
||||
*/
|
||||
//'image_path_constraint' => false,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set default timezone.
|
||||
*
|
||||
* Default values.
|
||||
* default_timezone: ini_get('default_timezone') or 'UTC'
|
||||
*/
|
||||
//'default_timezone' => 'UTC',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Max image dimensions, larger dimensions results in 404.
|
||||
* This is basically a security constraint to avoid using resources on creating
|
||||
* large (unwanted) images.
|
||||
*
|
||||
* Default values.
|
||||
* max_width: 2000
|
||||
* max_height: 2000
|
||||
*/
|
||||
//'max_width' => 2000,
|
||||
//'max_height' => 2000,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set default background color for all images. Override it using
|
||||
* option bgColor.
|
||||
* Colorvalue is 6 digit hex string between 000000-FFFFFF
|
||||
* or 8 digit hex string if using the alpha channel where
|
||||
* the alpha value is between 00 (opaqe) and 7F (transparent),
|
||||
* that is between 00000000-FFFFFF7F.
|
||||
*
|
||||
* Default values.
|
||||
* background_color: As specified by CImage
|
||||
*/
|
||||
//'background_color' => "FFFFFF",
|
||||
//'background_color' => "FFFFFF7F",
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Post processing of images using external tools, set to true or false
|
||||
* and set command to be executed.
|
||||
*
|
||||
* Default values.
|
||||
*
|
||||
* 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'
|
||||
*/
|
||||
/*
|
||||
'postprocessing' => array(
|
||||
'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',
|
||||
),
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create custom convolution expressions, matrix 3x3, divisor and
|
||||
* offset.
|
||||
*
|
||||
* Default values.
|
||||
* convolution_constant: array()
|
||||
*/
|
||||
/*
|
||||
'convolution_constant' => array(
|
||||
//'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',
|
||||
),
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prevent leeching of images by controlling the hostname of those who
|
||||
* can access the images. Default is to allow hotlinking.
|
||||
*
|
||||
* Password apply when hotlinking is disallowed, use password to allow
|
||||
* hotlinking.
|
||||
*
|
||||
* The whitelist is an array of regexpes for allowed hostnames that can
|
||||
* hotlink images.
|
||||
*
|
||||
* Default values.
|
||||
* allow_hotlinking: true
|
||||
* hotlinking_whitelist: array()
|
||||
*/
|
||||
/*
|
||||
'allow_hotlinking' => false,
|
||||
'hotlinking_whitelist' => array(
|
||||
'^dbwebb\.se$',
|
||||
),
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Create custom shortcuts for more advanced expressions.
|
||||
*
|
||||
* Default values.
|
||||
* shortcut: array(
|
||||
* 'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
|
||||
* )
|
||||
*/
|
||||
/*
|
||||
'shortcut' => array(
|
||||
'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
|
||||
),*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Predefined size constants.
|
||||
*
|
||||
* These can be used together with &width or &height to create a constant value
|
||||
* for a width or height where can be changed in one place.
|
||||
* Useful when your site changes its layout or if you have a grid to fit images into.
|
||||
*
|
||||
* Example:
|
||||
* &width=w1 // results in width=613
|
||||
* &width=c2 // results in spanning two columns with a gutter, 30*2+10=70
|
||||
* &width=c24 // results in spanning whole grid 24*30+((24-1)*10)=950
|
||||
*
|
||||
* Default values.
|
||||
* size_constant: As specified by the function below.
|
||||
*/
|
||||
/*
|
||||
'size_constant' => function () {
|
||||
|
||||
// Set sizes to map constant to value, easier to use with width or height
|
||||
$sizes = array(
|
||||
'w1' => 613,
|
||||
'w2' => 630,
|
||||
);
|
||||
|
||||
// Add grid column width, useful for use as predefined size for width (or height).
|
||||
$gridColumnWidth = 30;
|
||||
$gridGutterWidth = 10;
|
||||
$gridColumns = 24;
|
||||
|
||||
for ($i = 1; $i <= $gridColumns; $i++) {
|
||||
$sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
|
||||
}
|
||||
|
||||
return $sizes;
|
||||
},*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Predefined aspect ratios.
|
||||
*
|
||||
* Default values.
|
||||
* aspect_ratio_constant: As the function below.
|
||||
*/
|
||||
/*'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,
|
||||
);
|
||||
},*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* default options for ascii image.
|
||||
*
|
||||
* Default values as specified below in the array.
|
||||
* ascii-options:
|
||||
* characterSet: Choose any character set available in CAsciiArt.
|
||||
* scale: How many pixels should each character
|
||||
* translate to.
|
||||
* luminanceStrategy: Choose any strategy available in CAsciiArt.
|
||||
* customCharacterSet: Define your own character set.
|
||||
*/
|
||||
/*'ascii-options' => array(
|
||||
"characterSet" => 'two',
|
||||
"scale" => 14,
|
||||
"luminanceStrategy" => 3,
|
||||
"customCharacterSet" => null,
|
||||
);
|
||||
},*/
|
||||
);
|
||||
|
@@ -83,12 +83,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -152,7 +152,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -4,32 +4,37 @@
|
||||
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
|
||||
-->
|
||||
<!-- Title: G Pages: 1 -->
|
||||
<svg width="138pt" height="258pt"
|
||||
viewBox="0.00 0.00 138.00 258.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 254)">
|
||||
<svg width="138pt" height="312pt"
|
||||
viewBox="0.00 0.00 138.00 312.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 308)">
|
||||
<title>G</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-254 134,-254 134,4 -4,4"/>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-308 134,-308 134,4 -4,4"/>
|
||||
<g id="clust1" class="cluster"><title>cluster_Global</title>
|
||||
<path fill="none" stroke="gray" d="M20,-8C20,-8 110,-8 110,-8 116,-8 122,-14 122,-20 122,-20 122,-230 122,-230 122,-236 116,-242 110,-242 110,-242 20,-242 20,-242 14,-242 8,-236 8,-230 8,-230 8,-20 8,-20 8,-14 14,-8 20,-8"/>
|
||||
<text text-anchor="middle" x="65" y="-229.2" font-family="Times,serif" font-size="11.00" fill="gray">Global</text>
|
||||
<path fill="none" stroke="gray" d="M20,-8C20,-8 110,-8 110,-8 116,-8 122,-14 122,-20 122,-20 122,-284 122,-284 122,-290 116,-296 110,-296 110,-296 20,-296 20,-296 14,-296 8,-290 8,-284 8,-284 8,-20 8,-20 8,-14 14,-8 20,-8"/>
|
||||
<text text-anchor="middle" x="65" y="-283.2" font-family="Times,serif" font-size="11.00" fill="gray">Global</text>
|
||||
</g>
|
||||
<!-- \\CRemoteImage -->
|
||||
<g id="node1" class="node"><title>\\CRemoteImage</title>
|
||||
<polygon fill="none" stroke="black" points="114,-214 16,-214 16,-178 114,-178 114,-214"/>
|
||||
<text text-anchor="middle" x="65" y="-193.2" font-family="Courier,monospace" font-size="11.00">CRemoteImage</text>
|
||||
<polygon fill="none" stroke="black" points="114,-268 16,-268 16,-232 114,-232 114,-268"/>
|
||||
<text text-anchor="middle" x="65" y="-247.2" font-family="Courier,monospace" font-size="11.00">CRemoteImage</text>
|
||||
</g>
|
||||
<!-- \\CImage -->
|
||||
<g id="node2" class="node"><title>\\CImage</title>
|
||||
<polygon fill="none" stroke="black" points="93.5,-160 36.5,-160 36.5,-124 93.5,-124 93.5,-160"/>
|
||||
<text text-anchor="middle" x="65" y="-139.2" font-family="Courier,monospace" font-size="11.00">CImage</text>
|
||||
<polygon fill="none" stroke="black" points="93.5,-214 36.5,-214 36.5,-178 93.5,-178 93.5,-214"/>
|
||||
<text text-anchor="middle" x="65" y="-193.2" font-family="Courier,monospace" font-size="11.00">CImage</text>
|
||||
</g>
|
||||
<!-- \\CAsciiArt -->
|
||||
<g id="node3" class="node"><title>\\CAsciiArt</title>
|
||||
<polygon fill="none" stroke="black" points="103.5,-160 26.5,-160 26.5,-124 103.5,-124 103.5,-160"/>
|
||||
<text text-anchor="middle" x="65" y="-139.2" font-family="Courier,monospace" font-size="11.00">CAsciiArt</text>
|
||||
</g>
|
||||
<!-- \\CHttpGet -->
|
||||
<g id="node3" class="node"><title>\\CHttpGet</title>
|
||||
<g id="node4" class="node"><title>\\CHttpGet</title>
|
||||
<polygon fill="none" stroke="black" points="100.5,-106 29.5,-106 29.5,-70 100.5,-70 100.5,-106"/>
|
||||
<text text-anchor="middle" x="65" y="-85.2" font-family="Courier,monospace" font-size="11.00">CHttpGet</text>
|
||||
</g>
|
||||
<!-- \\CWhitelist -->
|
||||
<g id="node4" class="node"><title>\\CWhitelist</title>
|
||||
<g id="node5" class="node"><title>\\CWhitelist</title>
|
||||
<polygon fill="none" stroke="black" points="107,-52 23,-52 23,-16 107,-16 107,-52"/>
|
||||
<text text-anchor="middle" x="65" y="-31.2" font-family="Courier,monospace" font-size="11.00">CWhitelist</text>
|
||||
</g>
|
||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.4 KiB |
@@ -58,12 +58,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -88,15 +88,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-11723610"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-774114870"></a>
|
||||
<a href="namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-11723610" class="accordion-body collapse in">
|
||||
<div id="namespace-774114870" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -123,6 +124,10 @@
|
||||
<h2>Classes</h2>
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<td><a href="classes/CAsciiArt.html">CAsciiArt</a></td>
|
||||
<td><em>Create an ASCII version of an image.</em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="classes/CHttpGet.html">CHttpGet</a></td>
|
||||
<td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>
|
||||
</tr>
|
||||
@@ -166,7 +171,7 @@
|
||||
<h3 class=" ">errorPage()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">errorPage(string <span class="argument">$msg</span>) : void</pre>
|
||||
<p><em>Default configuration options, can be overridden in own config-file.</em></p>
|
||||
<p><em>Display error message.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
@@ -443,7 +448,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -58,12 +58,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -88,15 +88,16 @@
|
||||
<div class="accordion" style="margin-bottom: 0">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1315371834"></a>
|
||||
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1997823667"></a>
|
||||
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
|
||||
</div>
|
||||
<div id="namespace-1315371834" class="accordion-body collapse in">
|
||||
<div id="namespace-1997823667" class="accordion-body collapse in">
|
||||
<div class="accordion-inner">
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CAsciiArt.html">CAsciiArt</a></li>
|
||||
<li class="class"><a href="../classes/CHttpGet.html">CHttpGet</a></li>
|
||||
<li class="class"><a href="../classes/CImage.html">CImage</a></li>
|
||||
<li class="class"><a href="../classes/CRemoteImage.html">CRemoteImage</a></li>
|
||||
<li class="class"><a href="../classes/CWhitelist.html">CWhitelist</a></li>
|
||||
@@ -123,6 +124,10 @@
|
||||
<h2>Classes</h2>
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<td><a href="../classes/CAsciiArt.html">CAsciiArt</a></td>
|
||||
<td><em>Create an ASCII version of an image.</em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="../classes/CHttpGet.html">CHttpGet</a></td>
|
||||
<td><em>Get a image from a remote server using HTTP GET and If-Modified-Since.</em></td>
|
||||
</tr>
|
||||
@@ -166,7 +171,7 @@
|
||||
<h3 class=" ">errorPage()</h3>
|
||||
<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>
|
||||
<pre class="signature" style="margin-right: 54px;">errorPage(string <span class="argument">$msg</span>) : void</pre>
|
||||
<p><em>Default configuration options, can be overridden in own config-file.</em></p>
|
||||
<p><em>Display error message.</em></p>
|
||||
|
||||
|
||||
<h4>Parameters</h4>
|
||||
@@ -443,7 +448,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -59,12 +59,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -142,7 +142,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -59,12 +59,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -91,6 +91,7 @@
|
||||
<li class="nav-header">Navigation</li>
|
||||
<li><a href="#CRemoteImage.php"><i class="icon-file"></i> CRemoteImage.php</a></li>
|
||||
<li><a href="#CImage.php"><i class="icon-file"></i> CImage.php</a></li>
|
||||
<li><a href="#CAsciiArt.php"><i class="icon-file"></i> CAsciiArt.php</a></li>
|
||||
<li><a href="#CHttpGet.php"><i class="icon-file"></i> CHttpGet.php</a></li>
|
||||
<li><a href="#CWhitelist.php"><i class="icon-file"></i> CWhitelist.php</a></li>
|
||||
</ul>
|
||||
@@ -110,7 +111,7 @@
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
CRemoteImage.php
|
||||
<small style="float: right;padding-right: 10px;">2</small>
|
||||
<small style="float: right;padding-right: 10px;">1</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
@@ -126,11 +127,6 @@
|
||||
<td>error</td>
|
||||
<td>0</td>
|
||||
<td>No summary was found for this file</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>119</td>
|
||||
<td>Argument $path is missing from the Docblock of setCache()</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -141,7 +137,7 @@
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
CImage.php
|
||||
<small style="float: right;padding-right: 10px;">21</small>
|
||||
<small style="float: right;padding-right: 10px;">34</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
@@ -160,103 +156,194 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1042</td>
|
||||
<td>Argument $saveAs is missing from the Docblock of setSaveAsExtension()</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $dst_image is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1702</td>
|
||||
<td>Argument $bgColor is missing from the Docblock of rotate()</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $src_image is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>87</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $dst_x is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $dst_y is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $src_x is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $src_y is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $dst_w is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $dst_h is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $src_w is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>1641</td>
|
||||
<td>Argument $src_h is missing from the Docblock of imageCopyResampled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>94</td>
|
||||
<td>No summary for property $bgColorDefault</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>216</td>
|
||||
<td>196</td>
|
||||
<td>No summary for property $pngFilterCmd</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>204</td>
|
||||
<td>No summary for property $pngDeflateCmd</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>212</td>
|
||||
<td>No summary for property $jpegOptimizeCmd</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>220</td>
|
||||
<td>No summary for property $height</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>223</td>
|
||||
<td>227</td>
|
||||
<td>No summary for property $newWidthOrig</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>224</td>
|
||||
<td>228</td>
|
||||
<td>No summary for property $newHeight</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>225</td>
|
||||
<td>229</td>
|
||||
<td>No summary for property $newHeightOrig</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>238</td>
|
||||
<td>242</td>
|
||||
<td>No summary for property $upscale</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>246</td>
|
||||
<td>250</td>
|
||||
<td>No summary for property $cropOrig</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>296</td>
|
||||
<td>350</td>
|
||||
<td>No summary for property $fillHeight</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>311</td>
|
||||
<td>365</td>
|
||||
<td>No summary for property $remotePattern</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>329</td>
|
||||
<td>380</td>
|
||||
<td>No summary for property $remoteHostWhitelist</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>387</td>
|
||||
<td>No summary for property $verboseFileName</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>394</td>
|
||||
<td>No summary for property $asciiOptions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>403</td>
|
||||
<td>No summary for property $copyStrategy</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>415</td>
|
||||
<td>No summary for property $cropToFit</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>330</td>
|
||||
<td>416</td>
|
||||
<td>No summary for property $cropWidth</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>331</td>
|
||||
<td>417</td>
|
||||
<td>No summary for property $cropHeight</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>332</td>
|
||||
<td>418</td>
|
||||
<td>No summary for property $crop_x</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>333</td>
|
||||
<td>419</td>
|
||||
<td>No summary for property $crop_y</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>334</td>
|
||||
<td>420</td>
|
||||
<td>No summary for property $filters</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>335</td>
|
||||
<td>No summary for property $type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>336</td>
|
||||
<td>421</td>
|
||||
<td>No summary for property $attr</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="package-contents">
|
||||
<a name="CAsciiArt.php" id="CAsciiArt.php"></a>
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
CAsciiArt.php
|
||||
<small style="float: right;padding-right: 10px;">1</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Line</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>337</td>
|
||||
<td>No summary for property $useOriginal</td>
|
||||
<td>0</td>
|
||||
<td>No summary was found for this file</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -367,7 +454,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
@@ -59,12 +59,12 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="../reports/errors.html">
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">27</span>
|
||||
<i class="icon-list-alt"></i> Errors <span class="label label-info pull-right">40</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reports/markers.html">
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">164</span>
|
||||
<i class="icon-list-alt"></i> Markers <span class="label label-info pull-right">2</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -88,13 +88,8 @@
|
||||
<div class="span2 sidebar">
|
||||
<ul class="side-nav nav nav-list">
|
||||
<li class="nav-header">Navigation</li>
|
||||
<li><a href="#webroot/img.php"><i class="icon-file"></i> webroot/img.php</a></li>
|
||||
<li><a href="#CRemoteImage.php"><i class="icon-file"></i> CRemoteImage.php</a></li>
|
||||
<li><a href="#CImage.php"><i class="icon-file"></i> CImage.php</a></li>
|
||||
<li><a href="#webroot/img_config.php"><i class="icon-file"></i> webroot/img_config.php</a></li>
|
||||
<li><a href="#CHttpGet.php"><i class="icon-file"></i> CHttpGet.php</a></li>
|
||||
<li><a href="#autoload.php"><i class="icon-file"></i> autoload.php</a></li>
|
||||
</ul>
|
||||
<li><a href="#CImage.php"><i class="icon-file"></i> CImage.php</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="span10 offset2">
|
||||
@@ -106,196 +101,12 @@
|
||||
|
||||
|
||||
<div id="marker-accordion">
|
||||
<div class="package-contents">
|
||||
<a name="webroot/img.php" id="webroot/img.php"></a>
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
webroot/img.php
|
||||
<small style="float: right;padding-right: 10px;">25</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Line</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>6</td>
|
||||
<td>dbwebb.se/opensource/cimage</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>7</td>
|
||||
<td>github.com/mosbth/cimage</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>158</td>
|
||||
<td>Settings for any mode</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>166</td>
|
||||
<td>Specific settings for each mode</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>217</td>
|
||||
<td>Check if passwords match, if configured to use passwords</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>249</td>
|
||||
<td>Always allow when password match</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>255</td>
|
||||
<td>Allow when serverName matches refererHost</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>346</td>
|
||||
<td>Check for valid/invalid characters</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>356</td>
|
||||
<td>If source is a remote file, ignore local file checks.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>360</td>
|
||||
<td>Check that the image is a file below the directory 'image_path'.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>387</td>
|
||||
<td>Set sizes to map constant to value, easier to use with width or height</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>393</td>
|
||||
<td>Add grid column width, useful for use as predefined size for width (or height).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>415</td>
|
||||
<td>Check to replace predefined size</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>420</td>
|
||||
<td>Support width as % of original width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>440</td>
|
||||
<td>Check to replace predefined size</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>445</td>
|
||||
<td>height</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>475</td>
|
||||
<td>Check to replace predefined aspect ratio</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>750</td>
|
||||
<td>php.net/manual/en/function.imageconvolution.php</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>755</td>
|
||||
<td>Check if the convolve is matching an existing constant</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>835</td>
|
||||
<td>code.jquery.com/jquery-2.1.1.min.js"></script></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>866</td>
|
||||
<td>Options for calculate dimensions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>877</td>
|
||||
<td>Pre-processing, before resizing is done</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>882</td>
|
||||
<td>General processing options</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>885</td>
|
||||
<td>Post-processing, after resizing is done</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>894</td>
|
||||
<td>Output format</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="package-contents">
|
||||
<a name="CRemoteImage.php" id="CRemoteImage.php"></a>
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
CRemoteImage.php
|
||||
<small style="float: right;padding-right: 10px;">5</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Line</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>227</td>
|
||||
<td>Save only if body is a valid image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>279</td>
|
||||
<td>First check if the cache is valid and can be used</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>290</td>
|
||||
<td>Do a HTTP request to download item</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>336</td>
|
||||
<td>Is cache valid?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>344</td>
|
||||
<td>Prepare for a 304 if available</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="package-contents">
|
||||
<div class="package-contents">
|
||||
<a name="CImage.php" id="CImage.php"></a>
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
CImage.php
|
||||
<small style="float: right;padding-right: 10px;">93</small>
|
||||
<small style="float: right;padding-right: 10px;">2</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
@@ -305,730 +116,19 @@
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>6</td>
|
||||
<td>dbwebb.se/opensource/cimage</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>7</td>
|
||||
<td>github.com/mosbth/cimage</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>86</td>
|
||||
<td>private $bgColorDefault = self::BACKGROUND_COLOR;</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>215</td>
|
||||
<td>Calculated from source image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>216</td>
|
||||
<td>Calculated from source image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>223</td>
|
||||
<td>Save original value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>225</td>
|
||||
<td>Save original value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>246</td>
|
||||
<td>Save original value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>310</td>
|
||||
<td>private $remotePattern = '#^[http|https]://#';</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>311</td>
|
||||
<td>#';</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>335</td>
|
||||
<td>Calculated from source image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>336</td>
|
||||
<td>Calculated from source image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>337</td>
|
||||
<td>Use original image if possible</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>603</td>
|
||||
<td>Sanitize filename</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>624</td>
|
||||
<td>Options for calculate dimensions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>631</td>
|
||||
<td>array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>632</td>
|
||||
<td>'0,0,0,0',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>635</td>
|
||||
<td>Options for caching or using original</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>639</td>
|
||||
<td>Pre-processing, before resizing is done</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>644</td>
|
||||
<td>General options</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>647</td>
|
||||
<td>Post-processing, after resizing is done</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>656</td>
|
||||
<td>Output format</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>660</td>
|
||||
<td>Options for saving</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>661</td>
|
||||
<td>'quality' => null,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>662</td>
|
||||
<td>'compress' => null,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>663</td>
|
||||
<td>'saveAs' => null,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>666</td>
|
||||
<td>Convert crop settings from string to array</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>677</td>
|
||||
<td>Convert area settings from string to array</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>688</td>
|
||||
<td>Convert filter settings from array of string to array of array</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>700</td>
|
||||
<td>php.net/manual/en/function.imagefilter.php'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>708</td>
|
||||
<td>Merge default arguments with incoming and set properties.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>709</td>
|
||||
<td>$args = array_merge_recursive($defaults, $args);</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>719</td>
|
||||
<td>Save original values to enable re-calculating</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>778</td>
|
||||
<td>Get details on image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>805</td>
|
||||
<td>width as %</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>811</td>
|
||||
<td>height as %</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>819</td>
|
||||
<td>width & height from aspect ratio</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>841</td>
|
||||
<td>Change width & height based on dpr</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>853</td>
|
||||
<td>Check values to be within domain</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>876</td>
|
||||
<td>Crop, use cropped width and height as base for calulations</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>881</td>
|
||||
<td>Check if there is an area to crop off</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>898</td>
|
||||
<td>Check if crop is set</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>922</td>
|
||||
<td>Calculate new width and height if keeping aspect-ratio.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>927</td>
|
||||
<td>Crop-to-fit and both new width and height are set.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>930</td>
|
||||
<td>Use newWidth and newHeigh as width/height, image should fit in box.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>935</td>
|
||||
<td>Both new width and height are set.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>936</td>
|
||||
<td>Use newWidth and newHeigh as max width/height, image should not be larger.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>946</td>
|
||||
<td>Use new width as max-width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>953</td>
|
||||
<td>Use new height as max-hight</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>960</td>
|
||||
<td>Get image dimensions for pre-resize image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>963</td>
|
||||
<td>Get relations of original & target image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>969</td>
|
||||
<td>Use newWidth and newHeigh as defined width/height,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>970</td>
|
||||
<td>image should fit the area.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>979</td>
|
||||
<td>Use newWidth and newHeigh as defined width/height,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>980</td>
|
||||
<td>image should fit the area.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>990</td>
|
||||
<td>Crop, ensure to set new width and height</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>997</td>
|
||||
<td>Fill to fit, ensure to set new width and height</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1004</td>
|
||||
<td>No new height or width is set, use existing measures.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1417</td>
|
||||
<td>Rotate image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1424</td>
|
||||
<td>Auto-rotate image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1431</td>
|
||||
<td>Scale the original image before starting</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1459</td>
|
||||
<td>Only use a specified area of the image, $this->offset is defining the area to use</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1472</td>
|
||||
<td>Do as crop, take only part of image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1482</td>
|
||||
<td>Consider rewriting the no-upscale code to fit within this if-statement,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1483</td>
|
||||
<td>likely to be more readable code.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1484</td>
|
||||
<td>The code is more or leass equal in below crop-to-fit, fill-to-fit and stretch</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1489</td>
|
||||
<td>Resize by crop to fit</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1526</td>
|
||||
<td>Resize by fill to fit</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1535</td>
|
||||
<td>Check ratio for landscape or portrait</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1565</td>
|
||||
<td>Resize it</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1592</td>
|
||||
<td>$this->log("posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY.");</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1622</td>
|
||||
<td>Rotate image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1628</td>
|
||||
<td>Apply filters</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1659</td>
|
||||
<td>Convert to palette image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1665</td>
|
||||
<td>Blur the image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1671</td>
|
||||
<td>Emboss the image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1677</td>
|
||||
<td>Sharpen the image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1683</td>
|
||||
<td>Custom convolution</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1685</td>
|
||||
<td>$this->log("Convolve: " . $this->convolve);</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1764</td>
|
||||
<td>stackoverflow.com/questions/5752514/how-to-convert-png-to-8-bit-png-using-php-gd-library</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1837</td>
|
||||
<td>Check of matching constant</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1845</td>
|
||||
<td>Expect list of 11 numbers, split by , and build up arguments</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1897</td>
|
||||
<td>Use incoming options or use $this.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1900</td>
|
||||
<td>Treat incoming as string, split by +</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>1904</td>
|
||||
<td>Check each option if it matches constant value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>2110</td>
|
||||
<td>Use JPEG optimize if defined</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>2133</td>
|
||||
<td>Turn off alpha blending and set alpha flag</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>2138</td>
|
||||
<td>Use external program to filter PNG, if defined</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>2151</td>
|
||||
<td>Use external program to deflate PNG, if defined</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>2244</td>
|
||||
<td>Get image modification time</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>2271</td>
|
||||
<td>Get details on image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TODO</td>
|
||||
<td>383</td>
|
||||
<td>467</td>
|
||||
<td>clean up how $this->saveFolder is used in other methods.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TODO</td>
|
||||
<td>328</td>
|
||||
<td>414</td>
|
||||
<td>Clean up these and check if and how they are used</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="package-contents">
|
||||
<a name="webroot/img_config.php" id="webroot/img_config.php"></a>
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
webroot/img_config.php
|
||||
<small style="float: right;padding-right: 10px;">36</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Line</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>17</td>
|
||||
<td>'mode' => 'production', // 'development', 'strict'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>25</td>
|
||||
<td>used from v0.6.2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>26</td>
|
||||
<td>used until v0.6.1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>29</td>
|
||||
<td>'cimage_class' => __DIR__ . '/../CImage.php',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>44</td>
|
||||
<td>'alias_path' => __DIR__ . '/img/alias/',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>55</td>
|
||||
<td>as in do not use password</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>56</td>
|
||||
<td>do not always require password,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>58</td>
|
||||
<td>'password' => false, // "secret-password",</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>59</td>
|
||||
<td>'password_always' => false, // always require password,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>77</td>
|
||||
<td>use default values from CImage which is to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>78</td>
|
||||
<td>allow download from any http- and </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>79</td>
|
||||
<td>https-source.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>80</td>
|
||||
<td>use default values from CImage which is to </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>81</td>
|
||||
<td>allow download from any hosts.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>83</td>
|
||||
<td>'remote_allow' => true,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>84</td>
|
||||
<td>'remote_pattern' => '#^https?://#',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>85</td>
|
||||
<td>'remote_whitelist' => array(</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>86</td>
|
||||
<td>'\.facebook\.com$',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>87</td>
|
||||
<td>'^(?:images|photos-[a-z])\.ak\.instagram\.com$',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>88</td>
|
||||
<td>'\.google\.com$'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>89</td>
|
||||
<td>),</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>100</td>
|
||||
<td>'valid_filename' => '#^[a-z0-9A-Z-/_\.:]+$#',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>101</td>
|
||||
<td>'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>113</td>
|
||||
<td>'image_path_constraint' => false,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>123</td>
|
||||
<td>'default_timezone' => 'UTC',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>136</td>
|
||||
<td>'max_width' => 2000,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>137</td>
|
||||
<td>'max_height' => 2000,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>152</td>
|
||||
<td>'background_color' => "FFFFFF",</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>153</td>
|
||||
<td>'background_color' => "FFFFFF7F",</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>196</td>
|
||||
<td>'sharpen' => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>197</td>
|
||||
<td>'sharpen-alt' => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>247</td>
|
||||
<td>results in width=613</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>248</td>
|
||||
<td>results in spanning two columns with a gutter, 30*2+10=70</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>249</td>
|
||||
<td>results in spanning whole grid 24*30+((24-1)*10)=950</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>257</td>
|
||||
<td>Set sizes to map constant to value, easier to use with width or height</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>263</td>
|
||||
<td>Add grid column width, useful for use as predefined size for width (or height).</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="package-contents">
|
||||
<a name="CHttpGet.php" id="CHttpGet.php"></a>
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
CHttpGet.php
|
||||
<small style="float: right;padding-right: 10px;">1</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Line</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>211</td>
|
||||
<td>max-age=2592000</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="package-contents">
|
||||
<a name="autoload.php" id="autoload.php"></a>
|
||||
<h3>
|
||||
<i class="icon-file"></i>
|
||||
autoload.php
|
||||
<small style="float: right;padding-right: 10px;">4</small>
|
||||
</h3>
|
||||
<div>
|
||||
<table class="table markers table-bordered">
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Line</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>6</td>
|
||||
<td>include __DIR__ . "/../CHttpGet.php";</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>7</td>
|
||||
<td>include __DIR__ . "/../CRemoteImage.php";</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>8</td>
|
||||
<td>include __DIR__ . "/../CImage.php";</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>18</td>
|
||||
<td>$path = CIMAGE_SOURCE_PATH . "/{$class}.php";</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1068,7 +168,7 @@
|
||||
<section class="span10 offset1">
|
||||
<hr />
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
|
||||
on March 6th, 2015 at 12:38.
|
||||
on December 2nd, 2015 at 11:04.
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
BIN
icc/sRGB_IEC61966-2-1_black_scaled.icc
Normal file
@@ -13,4 +13,10 @@
|
||||
<log type="coverage-clover" target="coverage.clover" />
|
||||
</logging>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<file>*.php</file>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
</phpunit>
|
||||
|
68
test/CCacheTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* A testclass
|
||||
*
|
||||
*/
|
||||
class CCacheTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSetCacheDir()
|
||||
{
|
||||
$cache = new CCache();
|
||||
$cache->setDir(CACHE_PATH);
|
||||
|
||||
$exp = "exists, writable";
|
||||
$res = $cache->getStatusOfSubdir("");
|
||||
$this->assertEquals($exp, $res, "Status of cache dir missmatch.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
* @expectedException Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSetWrongCacheDir()
|
||||
{
|
||||
$cache = new CCache();
|
||||
$cache->setDir(CACHE_PATH . "/NO_EXISTS");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateSubdir()
|
||||
{
|
||||
$cache = new CCache();
|
||||
$cache->setDir(CACHE_PATH);
|
||||
|
||||
$subdir = "__test__";
|
||||
$cache->removeSubdir($subdir);
|
||||
|
||||
$exp = "does not exist";
|
||||
$res = $cache->getStatusOfSubdir($subdir, false);
|
||||
$this->assertEquals($exp, $res, "Subdir should not be created.");
|
||||
|
||||
$res = $cache->getPathToSubdir($subdir);
|
||||
$exp = realpath(CACHE_PATH . "/$subdir");
|
||||
$this->assertEquals($exp, $res, "Subdir path missmatch.");
|
||||
|
||||
$exp = "exists, writable";
|
||||
$res = $cache->getStatusOfSubdir($subdir);
|
||||
$this->assertEquals($exp, $res, "Subdir should exist.");
|
||||
|
||||
$res = $cache->removeSubdir($subdir);
|
||||
$this->assertTrue($res, "Remove subdir.");
|
||||
}
|
||||
}
|
@@ -5,6 +5,57 @@
|
||||
*/
|
||||
class CImageDummyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
const DUMMY = "__dummy__";
|
||||
private $cachepath;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Setup environment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$cache = new CCache();
|
||||
$cache->setDir(CACHE_PATH);
|
||||
$this->cachepath = $cache->getPathToSubdir(self::DUMMY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Clean up cache dir content.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeFilesInCacheDir()
|
||||
{
|
||||
$files = glob($this->cachepath . "/*");
|
||||
foreach ($files as $file) {
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Teardown environment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
$cache = new CCache();
|
||||
$cache->setDir(CACHE_PATH);
|
||||
$this->removeFilesInCacheDir();
|
||||
$cache->removeSubdir(self::DUMMY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
@@ -14,15 +65,15 @@ class CImageDummyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$img = new CImage();
|
||||
|
||||
$img->setSaveFolder(CACHE_PATH . "/dummy");
|
||||
$img->setSource('dummy', CACHE_PATH . "/dummy");
|
||||
$img->setSaveFolder($this->cachepath);
|
||||
$img->setSource(self::DUMMY, $this->cachepath);
|
||||
$img->createDummyImage();
|
||||
$img->generateFilename(null, false);
|
||||
$img->save(null, null, false);
|
||||
|
||||
$filename = $img->getTarget();
|
||||
|
||||
$this->assertEquals(basename($filename), "dummy_100_100", "Filename not as expected on dummy image.");
|
||||
$this->assertEquals(basename($filename), self::DUMMY . "_100_100", "Filename not as expected on dummy image.");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,14 +87,14 @@ class CImageDummyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$img = new CImage();
|
||||
|
||||
$img->setSaveFolder(CACHE_PATH . "/dummy");
|
||||
$img->setSource('dummy', CACHE_PATH . "/dummy");
|
||||
$img->setSaveFolder($this->cachepath);
|
||||
$img->setSource(self::DUMMY, $this->cachepath);
|
||||
$img->createDummyImage(200, 400);
|
||||
$img->generateFilename(null, false);
|
||||
$img->save(null, null, false);
|
||||
|
||||
$filename = $img->getTarget();
|
||||
|
||||
$this->assertEquals(basename($filename), "dummy_200_400", "Filename not as expected on dummy image.");
|
||||
$this->assertEquals(basename($filename), self::DUMMY . "_200_400", "Filename not as expected on dummy image.");
|
||||
}
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ class CImageRemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
||||
public function testAllowRemoteDownloadDefaultPatternValid($source)
|
||||
{
|
||||
$img = new CImage();
|
||||
$img->setRemoteDownload(true);
|
||||
$img->setRemoteDownload(true, "");
|
||||
|
||||
$res = $img->isRemoteSource($source);
|
||||
$this->assertTrue($res, "Should be a valid remote source: '$source'.");
|
||||
@@ -79,7 +79,7 @@ class CImageRemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
||||
public function testAllowRemoteDownloadDefaultPatternInvalid($source)
|
||||
{
|
||||
$img = new CImage();
|
||||
$img->setRemoteDownload(true);
|
||||
$img->setRemoteDownload(true, "");
|
||||
|
||||
$res = $img->isRemoteSource($source);
|
||||
$this->assertFalse($res, "Should not be a valid remote source: '$source'.");
|
||||
|
74
test/CImageSRGBTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* A testclass
|
||||
*
|
||||
*/
|
||||
class CImageSRGBTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $srgbDir = "srgb";
|
||||
private $cache;
|
||||
private $srgbColorProfile;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Setup before test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->srgbColorProfile = __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc';
|
||||
$this->cache = CACHE_PATH . "/" . $this->srgbDir;
|
||||
|
||||
if (!is_writable($this->cache)) {
|
||||
mkdir($this->cache);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreate1()
|
||||
{
|
||||
$img = new CImage();
|
||||
|
||||
$filename = $img->convert2sRGBColorSpace(
|
||||
'car.png',
|
||||
IMAGE_PATH,
|
||||
$this->cache,
|
||||
$this->srgbColorProfile
|
||||
);
|
||||
|
||||
if (class_exists("Imagick")) {
|
||||
$this->assertEquals("srgb_car.png", basename($filename), "Filename not as expected on image.");
|
||||
} else {
|
||||
$this->assertFalse($filename, "ImageMagick not installed, silent fail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreate2()
|
||||
{
|
||||
$img = new CImage();
|
||||
|
||||
$filename = $img->convert2sRGBColorSpace(
|
||||
'car.jpg',
|
||||
IMAGE_PATH,
|
||||
$this->cache,
|
||||
$this->srgbColorProfile
|
||||
);
|
||||
|
||||
$this->assertFalse($filename);
|
||||
}
|
||||
}
|
@@ -4,6 +4,15 @@ echo 'Current PHP version: ' . phpversion() . '<br><br>';
|
||||
|
||||
echo 'Running on: ' . $_SERVER['SERVER_SOFTWARE'] . '<br><br>';
|
||||
|
||||
$no = extension_loaded('exif') ? null : 'NOT';
|
||||
echo "Extension exif is $no loaded.<br>";
|
||||
|
||||
$no = extension_loaded('curl') ? null : 'NOT';
|
||||
echo "Extension curl is $no loaded.<br>";
|
||||
|
||||
$no = extension_loaded('imagick') ? null : 'NOT';
|
||||
echo "Extension imagick is $no loaded.<br>";
|
||||
|
||||
$no = extension_loaded('gd') ? null : 'NOT';
|
||||
echo "Extension gd is $no loaded.<br>";
|
||||
|
||||
@@ -11,8 +20,13 @@ if (!$no) {
|
||||
echo "<pre>", var_dump(gd_info()), "</pre>";
|
||||
}
|
||||
|
||||
$no = extension_loaded('exif') ? null : 'NOT';
|
||||
echo "Extension exif is $no loaded.<br>";
|
||||
echo "<strong>Checking path for postprocessing tools</strong>";
|
||||
|
||||
$no = extension_loaded('curl') ? null : 'NOT';
|
||||
echo "Extension curl is $no loaded.<br>";
|
||||
echo "<br>optipng: ";
|
||||
system("which optipng");
|
||||
|
||||
echo "<br>pngout: ";
|
||||
system("which pngout");
|
||||
|
||||
echo "<br>jpegtran: ";
|
||||
system("which jpegtran");
|
||||
|
@@ -29,7 +29,12 @@ input[type=text] {
|
||||
.area {
|
||||
float: left;
|
||||
padding: 1em;
|
||||
background-color: #fff;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.invert {
|
||||
background-color: #666;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.json {
|
||||
@@ -45,7 +50,7 @@ input[type=text] {
|
||||
|
||||
<body>
|
||||
<h1>Compare images</h1>
|
||||
<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>
|
||||
<p>Add link to images and visually compare them. Change the link och press return to load the image. Add <code>&black</code> to the querystring to get a black background. <a href="http://dbwebb.se/opensource/cimage">Read more...</a></p>
|
||||
|
||||
<p><a id="permalink" href="?">Direct link to this setup.</a></p>
|
||||
|
||||
@@ -55,8 +60,11 @@ input[type=text] {
|
||||
<label>Image 2: <input type="text" id="input2" data-id="2"></label> <img id="thumb2"></br>
|
||||
<label>Image 3: <input type="text" id="input3" data-id="3"></label> <img id="thumb3"></br>
|
||||
<label>Image 4: <input type="text" id="input4" data-id="4"></label> <img id="thumb4"></br>
|
||||
<label>Image 5: <input type="text" id="input5" data-id="5"></label> <img id="thumb5"></br>
|
||||
<label>Image 6: <input type="text" id="input6" data-id="6"></label> <img id="thumb6"></br>
|
||||
<label><input type="checkbox" id="viewDetails">Show image details</label><br/>
|
||||
<label><input type="checkbox" id="stack">Stack images?</label>
|
||||
<label><input type="checkbox" id="stack">Stack images?</label><br/>
|
||||
<label><input type="checkbox" id="bg">Dark background?</label>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -65,6 +73,8 @@ input[type=text] {
|
||||
<button id="button2" class="button" data-id="2">Image 2</button>
|
||||
<button id="button3" class="button" data-id="3">Image 3</button>
|
||||
<button id="button4" class="button" data-id="4">Image 4</button>
|
||||
<button id="button5" class="button" data-id="5">Image 5</button>
|
||||
<button id="button6" class="button" data-id="6">Image 6</button>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
@@ -93,6 +103,18 @@ input[type=text] {
|
||||
<pre id="json4" class="json hidden"></pre>
|
||||
</div>
|
||||
|
||||
<div id="area5" class="area">
|
||||
<code>Image 5</code><br>
|
||||
<img id="img5">
|
||||
<pre id="json5" class="json hidden"></pre>
|
||||
</div>
|
||||
|
||||
<div id="area6" class="area">
|
||||
<code>Image 6</code><br>
|
||||
<img id="img6">
|
||||
<pre id="json6" class="json hidden"></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -110,8 +132,11 @@ if (isset($_GET['input1'])) {
|
||||
"input2": "<?=$_GET['input2']?>",
|
||||
"input3": "<?=$_GET['input3']?>",
|
||||
"input4": "<?=$_GET['input4']?>",
|
||||
"input5": "<?=$_GET['input5']?>",
|
||||
"input6": "<?=$_GET['input6']?>",
|
||||
"json": <?=$_GET['json']?>,
|
||||
"stack": <?=$_GET['stack']?>
|
||||
"stack": <?=$_GET['stack']?>,
|
||||
"bg": <?=$_GET['bg']?>
|
||||
});
|
||||
<?php
|
||||
} elseif (isset($script)) {
|
||||
|
16
webroot/compare/issue117-PNG24.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$script = <<<EOD
|
||||
CImage.compare({
|
||||
"input1": "../img.php?src=issue117/tri_original.png",
|
||||
"input2": "../img.php?src=issue117/tri_imageresizing.png",
|
||||
"input3": "../img.php?src=issue117/tri_cimage.png",
|
||||
"input4": "../img.php?src=issue117/tri_imagemagick.png",
|
||||
"input5": "../img.php?src=issue117/tri_original.png&w=190",
|
||||
"input6": "../img.php?src=issue117/tri_original.png&w=190&no-resample",
|
||||
"json": true,
|
||||
"stack": false,
|
||||
"bg": true
|
||||
});
|
||||
EOD;
|
||||
|
||||
include __DIR__ . "/compare.php";
|
@@ -5,7 +5,6 @@
|
||||
#
|
||||
# img A directory where all images are stored
|
||||
# img/me.jpg Access a image as usually.
|
||||
# img/img.php This is where I choose to place img.php (and img_config.php).
|
||||
# image/me.jpg Access a image though img.php using htaccess rewrite.
|
||||
# image/me.jpg?w=300 Using options to img.php.
|
||||
#
|
||||
@@ -15,4 +14,4 @@
|
||||
# image/me/me.jpg?w=300 Using options to img.php.
|
||||
#
|
||||
RewriteEngine on
|
||||
RewriteRule ^image/(.*)$ img/img.php?src=$1 [QSA,NC,L]
|
||||
RewriteRule ^image/(.*)$ img.php?src=$1 [QSA,NC,L]
|
||||
|
364
webroot/img.php
@@ -8,7 +8,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
$version = "v0.7.6 (2015-10-18)";
|
||||
$version = "v0.7.9 (2015-12-07)";
|
||||
|
||||
// For CRemoteImage
|
||||
define("CIMAGE_USER_AGENT", "CImage/$version");
|
||||
|
||||
|
||||
|
||||
@@ -16,21 +19,37 @@ $version = "v0.7.6 (2015-10-18)";
|
||||
* Display error message.
|
||||
*
|
||||
* @param string $msg to display.
|
||||
* @param int $type of HTTP error to display.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function errorPage($msg)
|
||||
function errorPage($msg, $type = 500)
|
||||
{
|
||||
global $mode;
|
||||
|
||||
header("HTTP/1.0 500 Internal Server Error");
|
||||
switch ($type) {
|
||||
case 403:
|
||||
$header = "403 Forbidden";
|
||||
break;
|
||||
case 404:
|
||||
$header = "404 Not Found";
|
||||
break;
|
||||
default:
|
||||
$header = "500 Internal Server Error";
|
||||
}
|
||||
|
||||
if ($mode == 'development') {
|
||||
header("HTTP/1.0 $header");
|
||||
|
||||
if ($mode == "development") {
|
||||
die("[img.php] $msg");
|
||||
}
|
||||
|
||||
if ($mode == "strict") {
|
||||
$header = "404 Not Found";
|
||||
}
|
||||
|
||||
error_log("[img.php] $msg");
|
||||
die("HTTP/1.0 500 Internal Server Error");
|
||||
die("HTTP/1.0 $header");
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +63,8 @@ set_exception_handler(function ($exception) {
|
||||
. $exception->getMessage()
|
||||
. "</p><pre>"
|
||||
. $exception->getTraceAsString()
|
||||
. "</pre>"
|
||||
. "</pre>",
|
||||
500
|
||||
);
|
||||
});
|
||||
|
||||
@@ -157,6 +177,13 @@ verbose("img.php version = $version");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* status - do a verbose dump of the configuration
|
||||
*/
|
||||
$status = getDefined('status', true, false);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set mode as strict, production or development.
|
||||
* Default is production environment.
|
||||
@@ -168,7 +195,7 @@ set_time_limit(20);
|
||||
ini_set('gd.jpeg_ignore_warning', 1);
|
||||
|
||||
if (!extension_loaded('gd')) {
|
||||
errorPage("Extension gd is nod loaded.");
|
||||
errorPage("Extension gd is not loaded.", 500);
|
||||
}
|
||||
|
||||
// Specific settings for each mode
|
||||
@@ -178,14 +205,16 @@ if ($mode == 'strict') {
|
||||
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') {
|
||||
@@ -202,7 +231,7 @@ if ($mode == 'strict') {
|
||||
ini_set('log_errors', 0);
|
||||
|
||||
} else {
|
||||
errorPage("Unknown mode: $mode");
|
||||
errorPage("Unknown mode: $mode", 500);
|
||||
}
|
||||
|
||||
verbose("mode = $mode");
|
||||
@@ -235,7 +264,7 @@ $pwd = get(array('password', 'pwd'), null);
|
||||
// Check if passwords match, if configured to use passwords
|
||||
$passwordMatch = null;
|
||||
if ($pwd) {
|
||||
switch($pwdType) {
|
||||
switch ($pwdType) {
|
||||
case 'md5':
|
||||
$passwordMatch = ($pwdConfig === md5($pwd));
|
||||
break;
|
||||
@@ -251,7 +280,7 @@ if ($pwd) {
|
||||
}
|
||||
|
||||
if ($pwdAlways && $passwordMatch !== true) {
|
||||
errorPage("Password required and does not match or exists.");
|
||||
errorPage("Password required and does not match or exists.", 403);
|
||||
}
|
||||
|
||||
verbose("password match = $passwordMatch");
|
||||
@@ -275,9 +304,9 @@ if (!$allowHotlinking) {
|
||||
; // Always allow when password match
|
||||
verbose("Hotlinking since passwordmatch");
|
||||
} elseif ($passwordMatch === false) {
|
||||
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
||||
errorPage("Hotlinking/leeching not allowed when password missmatch.", 403);
|
||||
} elseif (!$referer) {
|
||||
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
||||
errorPage("Hotlinking/leeching not allowed and referer is missing.", 403);
|
||||
} elseif (strcmp($serverName, $refererHost) == 0) {
|
||||
; // Allow when serverName matches refererHost
|
||||
verbose("Hotlinking disallowed but serverName matches refererHost.");
|
||||
@@ -288,11 +317,11 @@ if (!$allowHotlinking) {
|
||||
if ($allowedByWhitelist) {
|
||||
verbose("Hotlinking/leeching allowed by whitelist.");
|
||||
} else {
|
||||
errorPage("Hotlinking/leeching not allowed by whitelist. Referer: $referer.");
|
||||
errorPage("Hotlinking/leeching not allowed by whitelist. Referer: $referer.", 403);
|
||||
}
|
||||
|
||||
} else {
|
||||
errorPage("Hotlinking/leeching not allowed.");
|
||||
errorPage("Hotlinking/leeching not allowed.", 403);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,6 +353,16 @@ $img->setVerbose($verbose || $verboseFile);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the cachepath from config.
|
||||
*/
|
||||
$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');
|
||||
$cache = new CCache();
|
||||
$cache->setDir($cachePath);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow or disallow remote download of images from other servers.
|
||||
* Passwords apply if used.
|
||||
@@ -332,8 +371,10 @@ $img->setVerbose($verbose || $verboseFile);
|
||||
$allowRemote = getConfig('remote_allow', false);
|
||||
|
||||
if ($allowRemote && $passwordMatch !== false) {
|
||||
$cacheRemote = $cache->getPathToSubdir("remote");
|
||||
|
||||
$pattern = getConfig('remote_pattern', null);
|
||||
$img->setRemoteDownload($allowRemote, $pattern);
|
||||
$img->setRemoteDownload($allowRemote, $cacheRemote, $pattern);
|
||||
|
||||
$whitelist = getConfig('remote_whitelist', null);
|
||||
$img->setRemoteHostWhitelist($whitelist);
|
||||
@@ -366,7 +407,7 @@ if (isset($shortcut)
|
||||
* src - the source image file.
|
||||
*/
|
||||
$srcImage = urldecode(get('src'))
|
||||
or errorPage('Must set src-attribute.');
|
||||
or errorPage('Must set src-attribute.', 404);
|
||||
|
||||
// Check for valid/invalid characters
|
||||
$imagePath = getConfig('image_path', __DIR__ . '/img/');
|
||||
@@ -379,7 +420,7 @@ $dummyFilename = getConfig('dummy_filename', 'dummy');
|
||||
$dummyImage = false;
|
||||
|
||||
preg_match($validFilename, $srcImage)
|
||||
or errorPage('Filename contains invalid characters.');
|
||||
or errorPage('Filename contains invalid characters.', 404);
|
||||
|
||||
if ($dummyEnabled && $srcImage === $dummyFilename) {
|
||||
|
||||
@@ -399,13 +440,15 @@ if ($dummyEnabled && $srcImage === $dummyFilename) {
|
||||
is_file($pathToImage)
|
||||
or errorPage(
|
||||
'Source image is not a valid file, check the filename and that a
|
||||
matching file exists on the filesystem.'
|
||||
matching file exists on the filesystem.',
|
||||
404
|
||||
);
|
||||
|
||||
substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0
|
||||
or errorPage(
|
||||
'Security constraint: Source image is not below the directory "image_path"
|
||||
as specified in the config file img_config.php.'
|
||||
as specified in the config file img_config.php.',
|
||||
404
|
||||
);
|
||||
}
|
||||
|
||||
@@ -455,11 +498,11 @@ if (isset($sizes[$newWidth])) {
|
||||
// Support width as % of original width
|
||||
if ($newWidth[strlen($newWidth)-1] == '%') {
|
||||
is_numeric(substr($newWidth, 0, -1))
|
||||
or errorPage('Width % not numeric.');
|
||||
or errorPage('Width % not numeric.', 404);
|
||||
} else {
|
||||
is_null($newWidth)
|
||||
or ($newWidth > 10 && $newWidth <= $maxWidth)
|
||||
or errorPage('Width out of range.');
|
||||
or errorPage('Width out of range.', 404);
|
||||
}
|
||||
|
||||
verbose("new width = $newWidth");
|
||||
@@ -480,11 +523,11 @@ if (isset($sizes[$newHeight])) {
|
||||
// height
|
||||
if ($newHeight[strlen($newHeight)-1] == '%') {
|
||||
is_numeric(substr($newHeight, 0, -1))
|
||||
or errorPage('Height % out of range.');
|
||||
or errorPage('Height % out of range.', 404);
|
||||
} else {
|
||||
is_null($newHeight)
|
||||
or ($newHeight > 10 && $newHeight <= $maxHeight)
|
||||
or errorPage('Hight out of range.');
|
||||
or errorPage('Height out of range.', 404);
|
||||
}
|
||||
|
||||
verbose("new height = $newHeight");
|
||||
@@ -522,7 +565,7 @@ if ($negateAspectRatio) {
|
||||
|
||||
is_null($aspectRatio)
|
||||
or is_numeric($aspectRatio)
|
||||
or errorPage('Aspect ratio out of range');
|
||||
or errorPage('Aspect ratio out of range', 404);
|
||||
|
||||
verbose("aspect ratio = $aspectRatio");
|
||||
|
||||
@@ -558,6 +601,19 @@ verbose("bgColor = $bgColor");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Do or do not resample image when resizing.
|
||||
*/
|
||||
$resizeStrategy = getDefined(array('no-resample'), true, false);
|
||||
|
||||
if ($resizeStrategy) {
|
||||
$img->setCopyResizeStrategy($img::RESIZE);
|
||||
verbose("Setting = Resize instead of resample");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* fill-to-fit, ff - affecting the resulting image width, height and resize options
|
||||
*/
|
||||
@@ -609,6 +665,12 @@ verbose("area = $area");
|
||||
* skip-original, so - skip the original image and always process a new image
|
||||
*/
|
||||
$useOriginal = getDefined(array('skip-original', 'so'), false, true);
|
||||
$useOriginalDefault = getConfig('skip_original', false);
|
||||
|
||||
if ($useOriginalDefault === true) {
|
||||
verbose("use original is default ON");
|
||||
$useOriginal = true;
|
||||
}
|
||||
|
||||
verbose("use original = $useOriginal");
|
||||
|
||||
@@ -627,10 +689,15 @@ verbose("use cache = $useCache");
|
||||
* quality, q - set level of quality for jpeg images
|
||||
*/
|
||||
$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');
|
||||
or errorPage('Quality out of range', 404);
|
||||
|
||||
if (is_null($quality) && !is_null($qualityDefault)) {
|
||||
$quality = $qualityDefault;
|
||||
}
|
||||
|
||||
verbose("quality = $quality");
|
||||
|
||||
@@ -640,11 +707,15 @@ verbose("quality = $quality");
|
||||
* compress, co - what strategy to use when compressing png images
|
||||
*/
|
||||
$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');
|
||||
or errorPage('Compress out of range', 404);
|
||||
|
||||
if (is_null($compress) && !is_null($compressDefault)) {
|
||||
$compress = $compressDefault;
|
||||
}
|
||||
|
||||
verbose("compress = $compress");
|
||||
|
||||
@@ -666,7 +737,7 @@ $scale = get(array('scale', 's'));
|
||||
|
||||
is_null($scale)
|
||||
or ($scale >= 0 and $scale <= 400)
|
||||
or errorPage('Scale out of range');
|
||||
or errorPage('Scale out of range', 404);
|
||||
|
||||
verbose("scale = $scale");
|
||||
|
||||
@@ -715,7 +786,7 @@ $rotateBefore = get(array('rotateBefore', 'rotate-before', 'rb'));
|
||||
|
||||
is_null($rotateBefore)
|
||||
or ($rotateBefore >= -360 and $rotateBefore <= 360)
|
||||
or errorPage('RotateBefore out of range');
|
||||
or errorPage('RotateBefore out of range', 404);
|
||||
|
||||
verbose("rotateBefore = $rotateBefore");
|
||||
|
||||
@@ -728,7 +799,7 @@ $rotateAfter = get(array('rotateAfter', 'rotate-after', 'ra', 'rotate', 'r'));
|
||||
|
||||
is_null($rotateAfter)
|
||||
or ($rotateAfter >= -360 and $rotateAfter <= 360)
|
||||
or errorPage('RotateBefore out of range');
|
||||
or errorPage('RotateBefore out of range', 404);
|
||||
|
||||
verbose("rotateAfter = $rotateAfter");
|
||||
|
||||
@@ -877,13 +948,13 @@ if ($alias && $aliasPath && $passwordMatch) {
|
||||
$useCache = false;
|
||||
|
||||
is_writable($aliasPath)
|
||||
or errorPage("Directory for alias is not writable.");
|
||||
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.');
|
||||
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.');
|
||||
errorPage('Alias is not enabled in the config file or password not matching.', 403);
|
||||
}
|
||||
|
||||
verbose("alias = $alias");
|
||||
@@ -891,9 +962,181 @@ verbose("alias = $alias");
|
||||
|
||||
|
||||
/**
|
||||
* Get the cachepath from config.
|
||||
* Add cache control HTTP header.
|
||||
*/
|
||||
$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');
|
||||
$cacheControl = getConfig('cache_control', null);
|
||||
|
||||
if ($cacheControl) {
|
||||
verbose("cacheControl = $cacheControl");
|
||||
$img->addHTTPHeader("Cache-Control", $cacheControl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prepare a dummy image and use it as source image.
|
||||
*/
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prepare a sRGB version of the image and use it as source image.
|
||||
*/
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Display status
|
||||
*/
|
||||
if ($status) {
|
||||
$text = "img.php version = $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";
|
||||
|
||||
$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>";
|
||||
|
||||
if (!$no) {
|
||||
$text .= print_r(gd_info(), 1);
|
||||
}
|
||||
|
||||
echo <<<EOD
|
||||
<!doctype html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
<title>CImage status</title>
|
||||
<pre>$text</pre>
|
||||
EOD;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Log verbose details to file
|
||||
*/
|
||||
if ($verboseFile) {
|
||||
$img->setVerboseToFile("$cachePath/log.txt");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Hook after img.php configuration and before processing with CImage
|
||||
*/
|
||||
$hookBeforeCImage = getConfig('hook_before_CImage', null);
|
||||
|
||||
if (is_callable($hookBeforeCImage)) {
|
||||
verbose("hookBeforeCImage activated");
|
||||
|
||||
$allConfig = $hookBeforeCImage($img, array(
|
||||
// Options for calculate dimensions
|
||||
'newWidth' => $newWidth,
|
||||
'newHeight' => $newHeight,
|
||||
'aspectRatio' => $aspectRatio,
|
||||
'keepRatio' => $keepRatio,
|
||||
'cropToFit' => $cropToFit,
|
||||
'fillToFit' => $fillToFit,
|
||||
'crop' => $crop,
|
||||
'area' => $area,
|
||||
'upscale' => $upscale,
|
||||
|
||||
// Pre-processing, before resizing is done
|
||||
'scale' => $scale,
|
||||
'rotateBefore' => $rotateBefore,
|
||||
'autoRotate' => $autoRotate,
|
||||
|
||||
// General processing options
|
||||
'bgColor' => $bgColor,
|
||||
|
||||
// Post-processing, after resizing is done
|
||||
'palette' => $palette,
|
||||
'filters' => $filters,
|
||||
'sharpen' => $sharpen,
|
||||
'emboss' => $emboss,
|
||||
'blur' => $blur,
|
||||
'convolve' => $convolve,
|
||||
'rotateAfter' => $rotateAfter,
|
||||
|
||||
// Output format
|
||||
'outputFormat' => $outputFormat,
|
||||
'dpr' => $dpr,
|
||||
|
||||
// Other
|
||||
'postProcessing' => $postProcessing,
|
||||
));
|
||||
verbose(print_r($allConfig, 1));
|
||||
extract($allConfig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -924,7 +1167,7 @@ if ($verbose) {
|
||||
window.getDetails = function (url, id) {
|
||||
$.getJSON(url, function(data) {
|
||||
element = document.getElementById(id);
|
||||
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;
|
||||
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 : '');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -934,53 +1177,6 @@ EOD;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Log verbose details to file
|
||||
*/
|
||||
if ($verboseFile) {
|
||||
$img->setVerboseToFile("$cachePath/log.txt");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set basic options for image processing.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Prepare a dummy image and use it as source image.
|
||||
*/
|
||||
if ($dummyImage === true) {
|
||||
|
||||
$dummyDir = getConfig('dummy_dir', $cachePath. "/" . $dummyFilename);
|
||||
|
||||
is_writable($dummyDir)
|
||||
or verbose("dummy dir not writable = $dummyDir");
|
||||
|
||||
$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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load, process and output the image
|
||||
*/
|
||||
|
BIN
webroot/img/car_srgb.png
Normal file
After Width: | Height: | Size: 245 KiB |
BIN
webroot/img/hamburger.jpg
Normal file
After Width: | Height: | Size: 517 KiB |
BIN
webroot/img/issue117/tri_cimage.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
webroot/img/issue117/tri_imagemagick.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
webroot/img/issue117/tri_imageresizing.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
webroot/img/issue117/tri_original.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
@@ -13,7 +13,9 @@ return array(
|
||||
* Default values:
|
||||
* mode: 'production'
|
||||
*/
|
||||
//'mode' => 'production', // 'development', 'strict'
|
||||
//'mode' => 'production',
|
||||
//'mode' => 'development',
|
||||
//'mode' => 'strict',
|
||||
|
||||
|
||||
|
||||
@@ -108,25 +110,78 @@ return array(
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Change the default values for CImage quality and compression used
|
||||
* when saving images.
|
||||
*
|
||||
* Default value:
|
||||
* jpg_quality: null, integer between 0-100
|
||||
* png_compression: null, integer between 0-9
|
||||
*/
|
||||
//'jpg_quality' => 75,
|
||||
//'png_compression' => 1,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert the image to srgb before processing. Saves the converted
|
||||
* image in a cache subdir 'srgb'. This option is default false but can
|
||||
* be changed to default true to do this conversion for all images.
|
||||
* This option requires PHP extension imagick and will silently fail
|
||||
* if that is not installed.
|
||||
*
|
||||
* Default value:
|
||||
* srgb_default: false
|
||||
* srgb_colorprofile: __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'
|
||||
*/
|
||||
//'srgb_default' => false,
|
||||
//'srgb_colorprofile' => __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A function (hook) can be called after img.php has processed all
|
||||
* configuration options and before processing the image using CImage.
|
||||
* The function receives the $img variabel and an array with the
|
||||
* majority of current settings.
|
||||
*
|
||||
* Default value:
|
||||
* hook_before_CImage: null
|
||||
*/
|
||||
/*'hook_before_CImage' => function (CImage $img, Array $allConfig) {
|
||||
if ($allConfig['newWidth'] > 10) {
|
||||
$allConfig['newWidth'] *= 2;
|
||||
}
|
||||
return $allConfig;
|
||||
},*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add header for cache control when outputting images.
|
||||
*
|
||||
* Default value:
|
||||
* cache_control: null, or set to string
|
||||
*/
|
||||
//'cache_control' => "max-age=86400",
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The name representing a dummy image which is automatically created
|
||||
* and stored at the defined path. The dummy image can then be used
|
||||
* inplace of an original image as a placeholder.
|
||||
* The dummy_dir must be writable and it defaults to a subdir of the
|
||||
* cache directory.
|
||||
* Write protect the dummy_dir to prevent creation of new dummy images,
|
||||
* but continue to use the existing ones.
|
||||
* and stored as a image in the dir CACHE_PATH/dummy. The dummy image
|
||||
* can then be used as a placeholder image.
|
||||
* The dir CACHE_PATH/dummy is automatically created when needed.
|
||||
* Write protect the CACHE_PATH/dummy to prevent creation of new
|
||||
* dummy images, but continue to use the existing ones.
|
||||
*
|
||||
* Default value:
|
||||
* dummy_enabled: true as default, disable dummy feature by setting
|
||||
* to false.
|
||||
* dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.
|
||||
* dummy_dir: Defaults to subdirectory of 'cache_path',
|
||||
* named the same as 'dummy_filename'
|
||||
*/
|
||||
//'dummy_enabled' => true,
|
||||
//'dummy_filename' => 'dummy',
|
||||
//'dummy_dir' => 'some writable directory',
|
||||
|
||||
|
||||
|
||||
|
858
webroot/imgd.php
Normal file → Executable file
858
webroot/imgp.php
Normal file → Executable file
4511
webroot/imgs.php
@@ -25,8 +25,11 @@ window.CImage = (function() {
|
||||
input2 = document.getElementById("input2"),
|
||||
input3 = document.getElementById("input3"),
|
||||
input4 = document.getElementById("input4"),
|
||||
input5 = document.getElementById("input5"),
|
||||
input6 = document.getElementById("input6"),
|
||||
details = document.getElementById("viewDetails"),
|
||||
stack = document.getElementById("stack"),
|
||||
bg = document.getElementById("bg"),
|
||||
permalink = document.getElementById("permalink");
|
||||
|
||||
link = "?";
|
||||
@@ -34,8 +37,11 @@ window.CImage = (function() {
|
||||
link += "input2=" + encodeURIComponent(input2.value) + "&";
|
||||
link += "input3=" + encodeURIComponent(input3.value) + "&";
|
||||
link += "input4=" + encodeURIComponent(input4.value) + "&";
|
||||
link += "input5=" + encodeURIComponent(input5.value) + "&";
|
||||
link += "input6=" + encodeURIComponent(input6.value) + "&";
|
||||
link += "json=" + encodeURIComponent(details.checked) + "&";
|
||||
link += "stack=" + encodeURIComponent(stack.checked);
|
||||
link += "stack=" + encodeURIComponent(stack.checked) + "&";
|
||||
link += "bg=" + encodeURIComponent(bg.checked);
|
||||
permalink.href = link;
|
||||
}
|
||||
|
||||
@@ -69,7 +75,7 @@ window.CImage = (function() {
|
||||
area.classList.remove("hidden");
|
||||
|
||||
$.getJSON(this.value + "&json", function(data) {
|
||||
json.innerHTML = "filename: " + data.filename + "\ncolors: " + data.colors + "\nsize: " + data.size + "\nwidth: " + data.width + "\nheigh: " + data.height + "\naspect-ratio: " + data.aspectRatio;
|
||||
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;
|
||||
})
|
||||
.fail(function() {
|
||||
json.innerHTML = "Details not available."
|
||||
@@ -95,14 +101,19 @@ window.CImage = (function() {
|
||||
input2 = document.getElementById("input2"),
|
||||
input3 = document.getElementById("input3"),
|
||||
input4 = document.getElementById("input4"),
|
||||
input5 = document.getElementById("input5"),
|
||||
input6 = document.getElementById("input6"),
|
||||
details = document.getElementById("viewDetails"),
|
||||
stack = document.getElementById("stack"),
|
||||
bg = document.getElementById("bg"),
|
||||
buttons = document.getElementById("buttonWrap");
|
||||
|
||||
input1.addEventListener("change", compareLoadImage);
|
||||
input2.addEventListener("change", compareLoadImage);
|
||||
input3.addEventListener("change", compareLoadImage);
|
||||
input4.addEventListener("change", compareLoadImage);
|
||||
input5.addEventListener("change", compareLoadImage);
|
||||
input6.addEventListener("change", compareLoadImage);
|
||||
|
||||
// Toggle json
|
||||
details.addEventListener("change", function() {
|
||||
@@ -129,6 +140,23 @@ window.CImage = (function() {
|
||||
details.dispatchEvent(myEvent);
|
||||
}
|
||||
|
||||
// Toggle background color
|
||||
bg.addEventListener("change", function() {
|
||||
var elements = document.querySelectorAll(".area");
|
||||
|
||||
forEach(elements, function (index, element) {
|
||||
element.classList.toggle("invert");
|
||||
});
|
||||
});
|
||||
|
||||
// Check background
|
||||
if (options.bg === true) {
|
||||
bg.setAttribute("checked", "checked");
|
||||
bg.classList.toggle("invert");
|
||||
myEvent = new CustomEvent("change");
|
||||
bg.dispatchEvent(myEvent);
|
||||
}
|
||||
|
||||
// Toggle stack
|
||||
stack.addEventListener("change", function() {
|
||||
var element,
|
||||
@@ -200,11 +228,15 @@ window.CImage = (function() {
|
||||
input2.value = options.input2 || null;
|
||||
input3.value = options.input3 || null;
|
||||
input4.value = options.input4 || null;
|
||||
input5.value = options.input5 || null;
|
||||
input6.value = options.input6 || null;
|
||||
|
||||
compareLoadImage.call(input1);
|
||||
compareLoadImage.call(input2);
|
||||
compareLoadImage.call(input3);
|
||||
compareLoadImage.call(input4);
|
||||
compareLoadImage.call(input5);
|
||||
compareLoadImage.call(input6);
|
||||
|
||||
console.log(options);
|
||||
}
|
||||
|