1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-26 17:14:27 +02:00

Compare commits

..

5 Commits
078 ... v0.7.8

Author SHA1 Message Date
Mikael Roos
29743b75ec prepare to tag v0.7.8 2015-12-06 12:47:47 +01:00
Mikael Roos
902c0aaef8 generate new bundles 2015-12-06 12:40:54 +01:00
Mikael Roos
6c487c6f34 ignore build dir 2015-12-06 12:38:17 +01:00
Mikael Roos
a1d811a318 Merge branch '078' 2015-12-06 12:37:11 +01:00
Mikael Roos
a205d65ad5 moving to new travis environment 2015-12-06 12:27:54 +01:00
4 changed files with 40 additions and 37 deletions

3
.gitignore vendored
View File

@@ -8,3 +8,6 @@ coverage.clover
# Composer # Composer
composer.lock composer.lock
vendor vendor
# Build and test
build/

View File

@@ -46,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). 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.7 released 2015-10-21.** **Latest stable version is v0.7.8 released 2015-12-06.**
I prefer cloning like this. Do switch to the latest stable version. I prefer cloning like this. Do switch to the latest stable version.
```bash ```bash
git clone git://github.com/mosbth/cimage.git git clone git://github.com/mosbth/cimage.git
cd cimage cd cimage
git checkout v0.7.7 git checkout v0.7.8
``` ```
Make the cache-directory writable by the webserver. Make the cache-directory writable by the webserver.
@@ -76,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. Dowload the version of your choice like this.
```bash ```bash
wget https://raw.githubusercontent.com/mosbth/cimage/v0.7.7/webroot/imgp.php wget https://raw.githubusercontent.com/mosbth/cimage/v0.7.8/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. 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.

View File

@@ -1545,7 +1545,7 @@ class CImage
private function normalizeFileExtension($extension = null) private function normalizeFileExtension($extension = null)
{ {
$extension = strtolower($extension ? $extension : $this->extension); $extension = strtolower($extension ? $extension : $this->extension);
if ($extension == 'jpeg') { if ($extension == 'jpeg') {
$extension = 'jpg'; $extension = 'jpg';
} }
@@ -1567,7 +1567,7 @@ class CImage
if (!$this->isRemoteSourceOnWhitelist($src)) { if (!$this->isRemoteSourceOnWhitelist($src)) {
throw new Exception("Hostname is not on whitelist for remote sources."); throw new Exception("Hostname is not on whitelist for remote sources.");
} }
$remote = new CRemoteImage(); $remote = new CRemoteImage();
$cache = $this->saveFolder . "/remote/"; $cache = $this->saveFolder . "/remote/";
@@ -2242,7 +2242,7 @@ class CImage
if ($this->copyStrategy === self::RESIZE) { if ($this->copyStrategy === self::RESIZE) {
$copyStrat = "_rs"; $copyStrat = "_rs";
} }
$width = $this->newWidth ? '_' . $this->newWidth : null; $width = $this->newWidth ? '_' . $this->newWidth : null;
$height = $this->newHeight ? '_' . $this->newHeight : null; $height = $this->newHeight ? '_' . $this->newHeight : null;
@@ -2293,8 +2293,8 @@ class CImage
$subdir = ($subdir == '.') ? '_.' : $subdir; $subdir = ($subdir == '.') ? '_.' : $subdir;
$subdir .= '_'; $subdir .= '_';
} }
$file = $prefix . $subdir . $filename . $width . $height $file = $prefix . $subdir . $filename . $width . $height
. $offset . $crop . $cropToFit . $fillToFit . $offset . $crop . $cropToFit . $fillToFit
. $crop_x . $crop_y . $upscale . $crop_x . $crop_y . $upscale
. $quality . $filters . $sharpen . $emboss . $blur . $palette . $quality . $filters . $sharpen . $emboss . $blur . $palette
@@ -2364,7 +2364,7 @@ class CImage
if ($this->image === false) { if ($this->image === false) {
throw new Exception("Could not load image."); throw new Exception("Could not load image.");
} }
/* Removed v0.7.7 /* Removed v0.7.7
if (image_type_to_mime_type($this->fileType) == 'image/png') { if (image_type_to_mime_type($this->fileType) == 'image/png') {
$type = $this->getPngType(); $type = $this->getPngType();
@@ -2404,14 +2404,14 @@ class CImage
public function getPngType($filename = null) public function getPngType($filename = null)
{ {
$filename = $filename ? $filename : $this->pathToImage; $filename = $filename ? $filename : $this->pathToImage;
$pngType = ord(file_get_contents($filename, false, null, 25, 1)); $pngType = ord(file_get_contents($filename, false, null, 25, 1));
if ($this->verbose) { if ($this->verbose) {
$this->log("Checking png type of: " . $filename); $this->log("Checking png type of: " . $filename);
$this->log($this->getPngTypeAsString($pngType)); $this->log($this->getPngTypeAsString($pngType));
} }
return $pngType; return $pngType;
} }
@@ -2435,7 +2435,7 @@ class CImage
$index = imagecolortransparent($this->image); $index = imagecolortransparent($this->image);
$transparent = null; $transparent = null;
if ($index != -1) { if ($index != -1) {
$transparent = " (transparent)"; $transparent = " (transparent)";
} }
switch ($pngType) { switch ($pngType) {
@@ -3142,7 +3142,7 @@ class CImage
$index = $this->image $index = $this->image
? imagecolortransparent($this->image) ? imagecolortransparent($this->image)
: -1; : -1;
if ($index != -1) { if ($index != -1) {
imagealphablending($img, true); imagealphablending($img, true);
@@ -3210,8 +3210,8 @@ class CImage
return substr(image_type_to_extension($this->fileType), 1); return substr(image_type_to_extension($this->fileType), 1);
} }
} }
/** /**
* Save image. * Save image.
@@ -3364,7 +3364,7 @@ class CImage
$colorspace = $image->getImageColorspace(); $colorspace = $image->getImageColorspace();
$this->log(" Current colorspace: " . $colorspace); $this->log(" Current colorspace: " . $colorspace);
$profiles = $image->getImageProfiles('*', false); $profiles = $image->getImageProfiles('*', false);
$hasICCProfile = (array_search('icc', $profiles) !== false); $hasICCProfile = (array_search('icc', $profiles) !== false);
$this->log(" Has ICC color profile: " . ($hasICCProfile ? "YES" : "NO")); $this->log(" Has ICC color profile: " . ($hasICCProfile ? "YES" : "NO"));
@@ -3373,13 +3373,13 @@ class CImage
$sRGBicc = file_get_contents($iccFile); $sRGBicc = file_get_contents($iccFile);
$image->profileImage('icc', $sRGBicc); $image->profileImage('icc', $sRGBicc);
$image->transformImageColorspace(Imagick::COLORSPACE_SRGB); $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);
$image->writeImage($this->cacheFileName); $image->writeImage($this->cacheFileName);
return $this->cacheFileName; return $this->cacheFileName;
} }
} }
return false; return false;
} }
@@ -3502,7 +3502,7 @@ class CImage
$this->log("Content-type: " . $mime); $this->log("Content-type: " . $mime);
$this->log("Content-length: " . $size); $this->log("Content-length: " . $size);
$this->verboseOutput(); $this->verboseOutput();
if (is_null($this->verboseFileName)) { if (is_null($this->verboseFileName)) {
exit; exit;
} }
@@ -3554,7 +3554,7 @@ class CImage
$details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB" ; $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB" ;
$details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . " MB"; $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . " MB";
$details['memoryLimit'] = ini_get('memory_limit'); $details['memoryLimit'] = ini_get('memory_limit');
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) { if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
$details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s"; $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
} }

View File

@@ -1545,7 +1545,7 @@ class CImage
private function normalizeFileExtension($extension = null) private function normalizeFileExtension($extension = null)
{ {
$extension = strtolower($extension ? $extension : $this->extension); $extension = strtolower($extension ? $extension : $this->extension);
if ($extension == 'jpeg') { if ($extension == 'jpeg') {
$extension = 'jpg'; $extension = 'jpg';
} }
@@ -1567,7 +1567,7 @@ class CImage
if (!$this->isRemoteSourceOnWhitelist($src)) { if (!$this->isRemoteSourceOnWhitelist($src)) {
throw new Exception("Hostname is not on whitelist for remote sources."); throw new Exception("Hostname is not on whitelist for remote sources.");
} }
$remote = new CRemoteImage(); $remote = new CRemoteImage();
$cache = $this->saveFolder . "/remote/"; $cache = $this->saveFolder . "/remote/";
@@ -2242,7 +2242,7 @@ class CImage
if ($this->copyStrategy === self::RESIZE) { if ($this->copyStrategy === self::RESIZE) {
$copyStrat = "_rs"; $copyStrat = "_rs";
} }
$width = $this->newWidth ? '_' . $this->newWidth : null; $width = $this->newWidth ? '_' . $this->newWidth : null;
$height = $this->newHeight ? '_' . $this->newHeight : null; $height = $this->newHeight ? '_' . $this->newHeight : null;
@@ -2293,8 +2293,8 @@ class CImage
$subdir = ($subdir == '.') ? '_.' : $subdir; $subdir = ($subdir == '.') ? '_.' : $subdir;
$subdir .= '_'; $subdir .= '_';
} }
$file = $prefix . $subdir . $filename . $width . $height $file = $prefix . $subdir . $filename . $width . $height
. $offset . $crop . $cropToFit . $fillToFit . $offset . $crop . $cropToFit . $fillToFit
. $crop_x . $crop_y . $upscale . $crop_x . $crop_y . $upscale
. $quality . $filters . $sharpen . $emboss . $blur . $palette . $quality . $filters . $sharpen . $emboss . $blur . $palette
@@ -2364,7 +2364,7 @@ class CImage
if ($this->image === false) { if ($this->image === false) {
throw new Exception("Could not load image."); throw new Exception("Could not load image.");
} }
/* Removed v0.7.7 /* Removed v0.7.7
if (image_type_to_mime_type($this->fileType) == 'image/png') { if (image_type_to_mime_type($this->fileType) == 'image/png') {
$type = $this->getPngType(); $type = $this->getPngType();
@@ -2404,14 +2404,14 @@ class CImage
public function getPngType($filename = null) public function getPngType($filename = null)
{ {
$filename = $filename ? $filename : $this->pathToImage; $filename = $filename ? $filename : $this->pathToImage;
$pngType = ord(file_get_contents($filename, false, null, 25, 1)); $pngType = ord(file_get_contents($filename, false, null, 25, 1));
if ($this->verbose) { if ($this->verbose) {
$this->log("Checking png type of: " . $filename); $this->log("Checking png type of: " . $filename);
$this->log($this->getPngTypeAsString($pngType)); $this->log($this->getPngTypeAsString($pngType));
} }
return $pngType; return $pngType;
} }
@@ -2435,7 +2435,7 @@ class CImage
$index = imagecolortransparent($this->image); $index = imagecolortransparent($this->image);
$transparent = null; $transparent = null;
if ($index != -1) { if ($index != -1) {
$transparent = " (transparent)"; $transparent = " (transparent)";
} }
switch ($pngType) { switch ($pngType) {
@@ -3142,7 +3142,7 @@ class CImage
$index = $this->image $index = $this->image
? imagecolortransparent($this->image) ? imagecolortransparent($this->image)
: -1; : -1;
if ($index != -1) { if ($index != -1) {
imagealphablending($img, true); imagealphablending($img, true);
@@ -3210,8 +3210,8 @@ class CImage
return substr(image_type_to_extension($this->fileType), 1); return substr(image_type_to_extension($this->fileType), 1);
} }
} }
/** /**
* Save image. * Save image.
@@ -3364,7 +3364,7 @@ class CImage
$colorspace = $image->getImageColorspace(); $colorspace = $image->getImageColorspace();
$this->log(" Current colorspace: " . $colorspace); $this->log(" Current colorspace: " . $colorspace);
$profiles = $image->getImageProfiles('*', false); $profiles = $image->getImageProfiles('*', false);
$hasICCProfile = (array_search('icc', $profiles) !== false); $hasICCProfile = (array_search('icc', $profiles) !== false);
$this->log(" Has ICC color profile: " . ($hasICCProfile ? "YES" : "NO")); $this->log(" Has ICC color profile: " . ($hasICCProfile ? "YES" : "NO"));
@@ -3373,13 +3373,13 @@ class CImage
$sRGBicc = file_get_contents($iccFile); $sRGBicc = file_get_contents($iccFile);
$image->profileImage('icc', $sRGBicc); $image->profileImage('icc', $sRGBicc);
$image->transformImageColorspace(Imagick::COLORSPACE_SRGB); $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);
$image->writeImage($this->cacheFileName); $image->writeImage($this->cacheFileName);
return $this->cacheFileName; return $this->cacheFileName;
} }
} }
return false; return false;
} }
@@ -3502,7 +3502,7 @@ class CImage
$this->log("Content-type: " . $mime); $this->log("Content-type: " . $mime);
$this->log("Content-length: " . $size); $this->log("Content-length: " . $size);
$this->verboseOutput(); $this->verboseOutput();
if (is_null($this->verboseFileName)) { if (is_null($this->verboseFileName)) {
exit; exit;
} }
@@ -3554,7 +3554,7 @@ class CImage
$details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB" ; $details['memoryPeek'] = round(memory_get_peak_usage()/1024/1024, 3) . " MB" ;
$details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . " MB"; $details['memoryCurrent'] = round(memory_get_usage()/1024/1024, 3) . " MB";
$details['memoryLimit'] = ini_get('memory_limit'); $details['memoryLimit'] = ini_get('memory_limit');
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) { if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
$details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s"; $details['loadTime'] = (string) round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 3) . "s";
} }