Added 9 new (instagram like) filters. Closes #3

This commit is contained in:
Christian Haschek
2015-11-07 02:21:27 +01:00
parent 741bb2a606
commit ce8275125c
36 changed files with 298 additions and 50 deletions

0
.htaccess Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

10
README.md Normal file → Executable file
View File

@@ -6,6 +6,7 @@ PictShare is an multi lingual, open source image hosting service with a simple r
UPDATES UPDATES
======== ========
- Nov. 07: Added 9 new (instagram-like) filters
- Nov. 06: Master delete code. One code to delete them all - Nov. 06: Master delete code. One code to delete them all
- Nov. 01: [Restricted uploads and option-use](#restriction-settings) - Nov. 01: [Restricted uploads and option-use](#restriction-settings)
- Oct. 30: [Rotations and filters](#smart-query-system) - Oct. 30: [Rotations and filters](#smart-query-system)
@@ -58,6 +59,15 @@ smooth | -10 to 2048 | https://pictshare.net/smooth_3/b260e36b60
contrast | -100 to 100 | https://pictshare.net/contrast_40/b260e36b60.jpg | ![contrast](https://pictshare.net/contrast_40/200/b260e36b60.jpg) contrast | -100 to 100 | https://pictshare.net/contrast_40/b260e36b60.jpg | ![contrast](https://pictshare.net/contrast_40/200/b260e36b60.jpg)
pixelate | 0 to 100 | https://pictshare.net/pixelate_10/b260e36b60.jpg | ![pixelate](https://pictshare.net/pixelate_10/200/b260e36b60.jpg) pixelate | 0 to 100 | https://pictshare.net/pixelate_10/b260e36b60.jpg | ![pixelate](https://pictshare.net/pixelate_10/200/b260e36b60.jpg)
blur | -none- or 0 to 5 | https://pictshare.net/blur/b260e36b60.jpg | ![pixelate](https://pictshare.net/blur/200/b260e36b60.jpg) blur | -none- or 0 to 5 | https://pictshare.net/blur/b260e36b60.jpg | ![pixelate](https://pictshare.net/blur/200/b260e36b60.jpg)
sepia | -none- | https://pictshare.net/sepia/b260e36b60.jpg | ![instagram filter sepia](https://pictshare.net/200/sepia/b260e36b60.jpg)
sharpen | -none- | https://pictshare.net/sharpen/b260e36b60.jpg | ![instagram filter sharpen](https://pictshare.net/200/sharpen/b260e36b60.jpg)
emboss | -none- | https://pictshare.net/emboss/b260e36b60.jpg | ![instagram filter emboss](https://pictshare.net/200/emboss/b260e36b60.jpg)
cool | -none- | https://pictshare.net/cool/b260e36b60.jpg | ![instagram filter cool](https://pictshare.net/200/cool/b260e36b60.jpg)
light | -none- | https://pictshare.net/light/b260e36b60.jpg | ![instagram filter light](https://pictshare.net/200/light/b260e36b60.jpg)
aqua | -none- | https://pictshare.net/aqua/b260e36b60.jpg | ![instagram filter aqua](https://pictshare.net/200/aqua/b260e36b60.jpg)
fuzzy | -none- | https://pictshare.net/fuzzy/b260e36b60.jpg | ![instagram filter fuzzy](https://pictshare.net/200/fuzzy/b260e36b60.jpg)
boost | -none- | https://pictshare.net/boost/b260e36b60.jpg | ![instagram filter boost](https://pictshare.net/200/boost/b260e36b60.jpg)
gray | -none- | https://pictshare.net/gray/b260e36b60.jpg | ![instagram filter gray](https://pictshare.net/200/gray/b260e36b60.jpg)
You can also combine as many options as you want. Even multiple times! Want your image to be negative, resized, grayscale , with increased brightness and negate it again? No problem: https://pictshare.net/500x500/grayscale/negative/brightness_100/negative/b260e36b60.jpg You can also combine as many options as you want. Even multiple times! Want your image to be negative, resized, grayscale , with increased brightness and negate it again? No problem: https://pictshare.net/500x500/grayscale/negative/brightness_100/negative/b260e36b60.jpg

0
backend.php Normal file → Executable file
View File

220
classes/filter.php Normal file
View File

@@ -0,0 +1,220 @@
<?php
class Filter
{
/**
* @var resource
*/
private $image;
/**
* Directory for image assets.
* @var string
*/
private $assetDirectory;
/**
* run constructor
* @param resource &$image GD image resource
*/
public function __construct(&$image)
{
$this->image = $image;
$this->assetDirectory = dirname(dirname(dirname(__FILE__))) . '/assets/';
}
/**
* Get the current image resource
*
* @return resource
*/
public function getImage()
{
return $this->image;
}
public function bubbles()
{
$dest = imagecreatefromjpeg($this->assetDirectory . "pattern4.jpg");
$x = imagesx($this->image);
$y = imagesy($this->image);
$x2 = imagesx($dest);
$y2 = imagesy($dest);
$thumb = imagecreatetruecolor($x, $y);
imagecopyresampled($thumb, $dest, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($this->image, $thumb, 0, 0, 0, 0, $x, $y, 20);
imagefilter($this->image, IMG_FILTER_BRIGHTNESS, 40);
imagefilter($this->image, IMG_FILTER_CONTRAST, -10);
return $this;
}
public function colorise()
{
$dest = imagecreatefromjpeg($this->assetDirectory . "pattern5.jpg");
$x = imagesx($this->image);
$y = imagesy($this->image);
$x2 = imagesx($dest);
$y2 = imagesy($dest);
$thumb = imagecreatetruecolor($x, $y);
imagecopyresampled($thumb, $dest, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($this->image, $thumb, 0, 0, 0, 0, $x, $y, 40);
imagefilter($this->image, IMG_FILTER_CONTRAST, -25);
return $this;
}
public function sepia()
{
imagefilter($this->image, IMG_FILTER_GRAYSCALE);
imagefilter($this->image, IMG_FILTER_COLORIZE, 100, 50, 0);
return $this;
}
public function sharpen()
{
$gaussian = array(
array(1.0, 1.0, 1.0),
array(1.0, -7.0, 1.0),
array(1.0, 1.0, 1.0)
);
imageconvolution($this->image, $gaussian, 1, 4);
return $this;
}
public function emboss()
{
$gaussian = array(
array(-2.0, -1.0, 0.0),
array(-1.0, 1.0, 1.0),
array(0.0, 1.0, 2.0)
);
imageconvolution($this->image, $gaussian, 1, 5);
return $this;
}
public function cool()
{
imagefilter($this->image, IMG_FILTER_MEAN_REMOVAL);
imagefilter($this->image, IMG_FILTER_CONTRAST, -50);
return $this;
}
public function old2()
{
$dest = imagecreatefromjpeg($this->assetDirectory . "pattern1.jpg");
$x = imagesx($this->image);
$y = imagesy($this->image);
$x2 = imagesx($dest);
$y2 = imagesy($dest);
$thumb = imagecreatetruecolor($x, $y);
imagecopyresampled($thumb, $dest, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($this->image, $thumb, 0, 0, 0, 0, $x, $y, 40);
return $this;
}
public function old3()
{
imagefilter($this->image, IMG_FILTER_CONTRAST, -30);
$dest = imagecreatefromjpeg($this->assetDirectory . "pattern3.jpg");
$x = imagesx($this->image);
$y = imagesy($this->image);
$x2 = imagesx($dest);
$y2 = imagesy($dest);
$thumb = imagecreatetruecolor($x, $y);
imagecopyresampled($thumb, $dest, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($this->image, $thumb, 0, 0, 0, 0, $x, $y, 50);
return $this;
}
public function old()
{
$dest = imagecreatefromjpeg($this->assetDirectory . "bg1.jpg");
$x = imagesx($this->image);
$y = imagesy($this->image);
$x2 = imagesx($dest);
$y2 = imagesy($dest);
$thumb = imagecreatetruecolor($x, $y);
imagecopyresampled($thumb, $dest, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($this->image, $thumb, 0, 0, 0, 0, $x, $y, 30);
return $this;
}
public function light()
{
imagefilter($this->image, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($this->image, IMG_FILTER_COLORIZE, 100, 50, 0, 10);
return $this;
}
public function aqua()
{
imagefilter($this->image, IMG_FILTER_COLORIZE, 0, 70, 0, 30);
return $this;
}
public function fuzzy()
{
$gaussian = array(
array(1.0, 1.0, 1.0),
array(1.0, 1.0, 1.0),
array(1.0, 1.0, 1.0)
);
imageconvolution($this->image, $gaussian, 9, 20);
return $this;
}
public function boost()
{
imagefilter($this->image, IMG_FILTER_CONTRAST, -35);
imagefilter($this->image, IMG_FILTER_BRIGHTNESS, 10);
return $this;
}
public function gray()
{
imagefilter($this->image, IMG_FILTER_CONTRAST, -60);
imagefilter($this->image, IMG_FILTER_GRAYSCALE);
return $this;
}
}

0
classes/html.php Normal file → Executable file
View File

9
classes/image.php Normal file → Executable file
View File

@@ -205,6 +205,15 @@ class Image
case 'contrast': imagefilter($im,IMG_FILTER_CONTRAST,$val); break; case 'contrast': imagefilter($im,IMG_FILTER_CONTRAST,$val); break;
case 'pixelate': imagefilter($im,IMG_FILTER_PIXELATE,$val); break; case 'pixelate': imagefilter($im,IMG_FILTER_PIXELATE,$val); break;
case 'blur': $this->blur($im,$val); break; case 'blur': $this->blur($im,$val); break;
case 'sepia': (new Filter($im))->sepia()->getImage();break;
case 'sharpen':(new Filter($im))->sharpen()->getImage();break;
case 'emboss':(new Filter($im))->emboss()->getImage();break;
case 'cool':(new Filter($im))->cool()->getImage();break;
case 'light':(new Filter($im))->light()->getImage();break;
case 'aqua':(new Filter($im))->aqua()->getImage();break;
case 'fuzzy':(new Filter($im))->fuzzy()->getImage();break;
case 'boost':(new Filter($im))->boost()->getImage();break;
case 'gray':(new Filter($im))->gray()->getImage();break;
} }
} }
} }

0
classes/model.php Normal file → Executable file
View File

0
css/imgs/Thumbs.db Normal file → Executable file
View File

0
css/imgs/bg.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

0
css/imgs/content.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
css/imgs/deleted.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

0
css/imgs/footer.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

0
css/imgs/header.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

0
css/imgs/header_empty.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

0
css/imgs/header_logo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
css/imgs/hs_logo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
css/main.css Normal file → Executable file
View File

0
css/normalize.css vendored Normal file → Executable file
View File

0
css/pictshare.css Normal file → Executable file
View File

0
inc/.gitignore vendored Normal file → Executable file
View File

0
inc/core.php Normal file → Executable file
View File

0
inc/example.config.inc.php Normal file → Executable file
View File

0
index.php Normal file → Executable file
View File

0
js/helper.js Normal file → Executable file
View File

0
js/jquery-2.1.0.min.js vendored Normal file → Executable file
View File

0
js/main.js Normal file → Executable file
View File

0
js/plugins.js Normal file → Executable file
View File

0
js/vendor/modernizr-2.6.2.min.js vendored Normal file → Executable file
View File

0
js/vendor/zepto.min.js vendored Normal file → Executable file
View File

9
models/pictsharemodel.php Normal file → Executable file
View File

@@ -126,6 +126,15 @@ class PictshareModel extends Model
case 'smooth': case 'smooth':
case 'contrast': case 'contrast':
case 'blur': case 'blur':
case 'sepia':
case 'sharpen':
case 'emboss':
case 'cool':
case 'light':
case 'aqua':
case 'fuzzy':
case 'boost':
case 'gray':
case 'pixelate': return true; case 'pixelate': return true;
default: return false; default: return false;

0
template.php Normal file → Executable file
View File

0
tmp/.gitignore vendored Normal file → Executable file
View File

0
tmp/.htaccess Normal file → Executable file
View File

0
upload/.gitignore vendored Normal file → Executable file
View File

0
upload/.htaccess Normal file → Executable file
View File