From ce8275125c02fe25480e3fbe1db9b32a9bc07946 Mon Sep 17 00:00:00 2001 From: Christian Haschek Date: Sat, 7 Nov 2015 02:21:27 +0100 Subject: [PATCH] Added 9 new (instagram like) filters. Closes #3 --- .htaccess | 0 LICENSE | 0 README.md | 10 ++ backend.php | 0 classes/filter.php | 220 +++++++++++++++++++++++++++++++ classes/html.php | 0 classes/image.php | 9 ++ classes/model.php | 0 css/imgs/Thumbs.db | Bin css/imgs/bg.png | Bin css/imgs/content.png | Bin css/imgs/deleted.jpg | Bin css/imgs/footer.png | Bin css/imgs/header.png | Bin css/imgs/header_empty.png | Bin css/imgs/header_logo.png | Bin css/imgs/hs_logo.png | Bin css/main.css | 0 css/normalize.css | 0 css/pictshare.css | 0 inc/.gitignore | 0 inc/core.php | 0 inc/example.config.inc.php | 100 +++++++------- index.php | 0 js/helper.js | 0 js/jquery-2.1.0.min.js | 0 js/main.js | 0 js/plugins.js | 0 js/vendor/modernizr-2.6.2.min.js | 0 js/vendor/zepto.min.js | 0 models/pictsharemodel.php | 9 ++ template.php | 0 tmp/.gitignore | 0 tmp/.htaccess | 0 upload/.gitignore | 0 upload/.htaccess | 0 36 files changed, 298 insertions(+), 50 deletions(-) mode change 100644 => 100755 .htaccess mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 backend.php create mode 100644 classes/filter.php mode change 100644 => 100755 classes/html.php mode change 100644 => 100755 classes/image.php mode change 100644 => 100755 classes/model.php mode change 100644 => 100755 css/imgs/Thumbs.db mode change 100644 => 100755 css/imgs/bg.png mode change 100644 => 100755 css/imgs/content.png mode change 100644 => 100755 css/imgs/deleted.jpg mode change 100644 => 100755 css/imgs/footer.png mode change 100644 => 100755 css/imgs/header.png mode change 100644 => 100755 css/imgs/header_empty.png mode change 100644 => 100755 css/imgs/header_logo.png mode change 100644 => 100755 css/imgs/hs_logo.png mode change 100644 => 100755 css/main.css mode change 100644 => 100755 css/normalize.css mode change 100644 => 100755 css/pictshare.css mode change 100644 => 100755 inc/.gitignore mode change 100644 => 100755 inc/core.php mode change 100644 => 100755 inc/example.config.inc.php mode change 100644 => 100755 index.php mode change 100644 => 100755 js/helper.js mode change 100644 => 100755 js/jquery-2.1.0.min.js mode change 100644 => 100755 js/main.js mode change 100644 => 100755 js/plugins.js mode change 100644 => 100755 js/vendor/modernizr-2.6.2.min.js mode change 100644 => 100755 js/vendor/zepto.min.js mode change 100644 => 100755 models/pictsharemodel.php mode change 100644 => 100755 template.php mode change 100644 => 100755 tmp/.gitignore mode change 100644 => 100755 tmp/.htaccess mode change 100644 => 100755 upload/.gitignore mode change 100644 => 100755 upload/.htaccess diff --git a/.htaccess b/.htaccess old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index ac592a7..7ed1a39 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ PictShare is an multi lingual, open source image hosting service with a simple r UPDATES ======== +- Nov. 07: Added 9 new (instagram-like) filters - Nov. 06: Master delete code. One code to delete them all - Nov. 01: [Restricted uploads and option-use](#restriction-settings) - 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) 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) +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 diff --git a/backend.php b/backend.php old mode 100644 new mode 100755 diff --git a/classes/filter.php b/classes/filter.php new file mode 100644 index 0000000..1eeccc6 --- /dev/null +++ b/classes/filter.php @@ -0,0 +1,220 @@ +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; + } +} \ No newline at end of file diff --git a/classes/html.php b/classes/html.php old mode 100644 new mode 100755 diff --git a/classes/image.php b/classes/image.php old mode 100644 new mode 100755 index dd09cdc..66128da --- a/classes/image.php +++ b/classes/image.php @@ -205,6 +205,15 @@ class Image case 'contrast': imagefilter($im,IMG_FILTER_CONTRAST,$val); break; case 'pixelate': imagefilter($im,IMG_FILTER_PIXELATE,$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; } } } diff --git a/classes/model.php b/classes/model.php old mode 100644 new mode 100755 diff --git a/css/imgs/Thumbs.db b/css/imgs/Thumbs.db old mode 100644 new mode 100755 diff --git a/css/imgs/bg.png b/css/imgs/bg.png old mode 100644 new mode 100755 diff --git a/css/imgs/content.png b/css/imgs/content.png old mode 100644 new mode 100755 diff --git a/css/imgs/deleted.jpg b/css/imgs/deleted.jpg old mode 100644 new mode 100755 diff --git a/css/imgs/footer.png b/css/imgs/footer.png old mode 100644 new mode 100755 diff --git a/css/imgs/header.png b/css/imgs/header.png old mode 100644 new mode 100755 diff --git a/css/imgs/header_empty.png b/css/imgs/header_empty.png old mode 100644 new mode 100755 diff --git a/css/imgs/header_logo.png b/css/imgs/header_logo.png old mode 100644 new mode 100755 diff --git a/css/imgs/hs_logo.png b/css/imgs/hs_logo.png old mode 100644 new mode 100755 diff --git a/css/main.css b/css/main.css old mode 100644 new mode 100755 diff --git a/css/normalize.css b/css/normalize.css old mode 100644 new mode 100755 diff --git a/css/pictshare.css b/css/pictshare.css old mode 100644 new mode 100755 diff --git a/inc/.gitignore b/inc/.gitignore old mode 100644 new mode 100755 diff --git a/inc/core.php b/inc/core.php old mode 100644 new mode 100755 diff --git a/inc/example.config.inc.php b/inc/example.config.inc.php old mode 100644 new mode 100755 index a114d4a..e77e75b --- a/inc/example.config.inc.php +++ b/inc/example.config.inc.php @@ -1,51 +1,51 @@ -