Added 9 new (instagram like) filters. Closes #3
10
README.md
Normal file → Executable 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 | -100 to 100 | https://pictshare.net/contrast_40/b260e36b60.jpg | 
|
||||||
pixelate | 0 to 100 | https://pictshare.net/pixelate_10/b260e36b60.jpg | 
|
pixelate | 0 to 100 | https://pictshare.net/pixelate_10/b260e36b60.jpg | 
|
||||||
blur | -none- or 0 to 5 | https://pictshare.net/blur/b260e36b60.jpg | 
|
blur | -none- or 0 to 5 | https://pictshare.net/blur/b260e36b60.jpg | 
|
||||||
|
sepia | -none- | https://pictshare.net/sepia/b260e36b60.jpg | 
|
||||||
|
sharpen | -none- | https://pictshare.net/sharpen/b260e36b60.jpg | 
|
||||||
|
emboss | -none- | https://pictshare.net/emboss/b260e36b60.jpg | 
|
||||||
|
cool | -none- | https://pictshare.net/cool/b260e36b60.jpg | 
|
||||||
|
light | -none- | https://pictshare.net/light/b260e36b60.jpg | 
|
||||||
|
aqua | -none- | https://pictshare.net/aqua/b260e36b60.jpg | 
|
||||||
|
fuzzy | -none- | https://pictshare.net/fuzzy/b260e36b60.jpg | 
|
||||||
|
boost | -none- | https://pictshare.net/boost/b260e36b60.jpg | 
|
||||||
|
gray | -none- | https://pictshare.net/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
220
classes/filter.php
Normal 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
9
classes/image.php
Normal file → Executable 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
0
css/imgs/Thumbs.db
Normal file → Executable file
0
css/imgs/bg.png
Normal file → Executable file
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
0
css/imgs/content.png
Normal file → Executable file
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
0
css/imgs/deleted.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
0
css/imgs/footer.png
Normal file → Executable file
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
0
css/imgs/header.png
Normal file → Executable file
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
0
css/imgs/header_empty.png
Normal file → Executable 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
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
0
css/imgs/hs_logo.png
Normal file → Executable file
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
0
css/main.css
Normal file → Executable file
0
css/normalize.css
vendored
Normal file → Executable file
0
css/pictshare.css
Normal file → Executable file
0
inc/.gitignore
vendored
Normal file → Executable file
0
inc/core.php
Normal file → Executable file
0
inc/example.config.inc.php
Normal file → Executable file
0
js/helper.js
Normal file → Executable file
0
js/jquery-2.1.0.min.js
vendored
Normal file → Executable file
0
js/main.js
Normal file → Executable file
0
js/plugins.js
Normal file → Executable file
0
js/vendor/modernizr-2.6.2.min.js
vendored
Normal file → Executable file
0
js/vendor/zepto.min.js
vendored
Normal file → Executable file
9
models/pictsharemodel.php
Normal file → Executable 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;
|
||||||
|
|||||||