( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
function filter($arr) {
global $link;
return array_map(array($link, 'real_escape_string'), $arr);
}
$_GET = filter($_GET);
$_POST = filter($_POST);
$mode=$_GET["mode"];
include("protect.php");
if (empty($page)) {
$page = 0;
}
include("includes/limittext.php");
include('Connections/videoondemand.php');
require("DbSql2.inc.php");
require("NewsSql2.inc.php");
$db = new NewsSQL();
$nani = $_SESSION["user"];
$rs_settings = mysqli_query($link,"select * from users where catalogid=$nani");
/** Check for correct params */
if ($_GET['image'] && $_GET['filter']) {
$mag = $_GET['mag'];
$id = substr($_GET['image'], 5, 1);
if (isset($_GET['image'])) {
gd_filter_image('v/uploads/raw/' . $_GET['image'], $_GET['filter']);
}
}
/** Apply and deliver the image and clean up */
function gd_filter_image($image_path, $photoFrame2_name)
{
$photoFrame2 = 'gd_filter_' . $photoFrame2_name;
if (function_exists($photoFrame2)) {
list($width, $height) = getimagesize($image_path);
$background = imagecreatetruecolor($width, $height);
$src = imagecreatefromjpeg($image_path);
imagecopyresampled($background, $src, 0, 0, 0, 0, $width, $height, $width, $height);
if (!empty($_GET['execute'])) {
imagejpeg($background,$image_path,100);
}
$background = $photoFrame2($background);
header('Content-type: image/jpeg');
imagejpeg($background, null, 100);
imagedestroy($background);
imagedestroy($src);
}
}
function gd_filter_heart2($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'heart2', 100);
return $background;
}
function gd_filter_leaf($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'leaf', 100);
return $background;
}
function gd_filter_corner($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'corner', 100);
return $background;
}
function gd_filter_love($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'love', 100);
return $background;
}
function gd_filter_pinkd($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'Pink-Diamond2', 100);
return $background;
}
function gd_filter_flower($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'flower', 100);
return $background;
}
function gd_filter_flower2($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'flower2', 100);
return $background;
}
function gd_filter_goldd($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'goldd', 100);
return $background;
}
function gd_filter_heart($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -30);
$background = gd_apply_overlay($background, 'heart', 100);
return $background;
}
/** Apply 'Cartoonise' preset */
function gd_filter_abstract($background)
{
/*
*/
imagefilter($background, IMG_FILTER_MEAN_REMOVAL);
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_CONTRAST, -40);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_SELECTIVE_BLUR);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 100);
imagefilter($background, IMG_FILTER_BRIGHTNESS, -100);
imagefilter($background, IMG_FILTER_CONTRAST, -100);
imagefilter($background, IMG_FILTER_SMOOTH, 3);
return $background;
}
/** Apply 'Cartoonise' preset */
function gd_filter_cartoon($background)
{
/*
*/
imagefilter($background, IMG_FILTER_EDGEDETECT);
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_CONTRAST, -40);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_SELECTIVE_BLUR);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 100);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 5);
$background = gd_apply_overlay($background, 'canvas', 100);
$matrix = array(
array(-1, -1, -1),
array(-1, 16, -1),
array(-1, -1, -1),
);
$divisor = array_sum(array_map('array_sum', $matrix));
$offset = 0;
imageconvolution($background, $matrix, $divisor, $offset);
imagefilter($background, IMG_FILTER_SMOOTH, 3);
return $background;
}
/** Apply 'Red' preset */
function gd_filter_yellow($background)
{
imagefilter($background, IMG_FILTER_COLORIZE ,0, -155, -255);
return $background;
}
/** Apply 'Purple' preset */
function gd_filter_purple($background)
{
imagefilter($background, IMG_FILTER_COLORIZE, 0, 0, 100);
return $background;
}
/** Apply 'Contrast' preset */
function gd_filter_contrast($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -20);
return $background;
}
function gd_filter_time($background)
{
$background = gd_apply_overlay($background, 'time', 100);
return $background;
}
/** Apply 'Blue Velvet' preset */
function gd_filter_velvet($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 5);
imagefilter($background, IMG_FILTER_CONTRAST, -25);
imagefilter($background, IMG_FILTER_COLORIZE, -10, 45, 65);
$background = gd_apply_overlay($background, 'noise', 45);
$background = gd_apply_overlay($background, 'vignette', 100);
return $background;
}
/** Apply 'Chrome' preset */
function gd_filter_chrome($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 15);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
imagefilter($background, IMG_FILTER_COLORIZE, -5, -10, -15);
$background = gd_apply_overlay($background, 'noise', 45);
$background = gd_apply_overlay($background, 'vignette', 100);
return $background;
}
/** Apply 'Lift' preset */
function gd_filter_lift($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -25);
/*imagefilter($background, IMG_FILTER_COLORIZE, 75, 0, 25);*/
$background = gd_apply_overlay($background, 'emulsion', 100);
return $background;
}
/** Apply 'Canvas' preset */
function gd_filter_canvas($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 25);
imagefilter($background, IMG_FILTER_CONTRAST, -25);
imagefilter($background, IMG_FILTER_COLORIZE, 50, 25, -35);
$background = gd_apply_overlay($background, 'canvas', 100);
return $background;
}
/** Apply 'Vintage 600' preset */
function gd_filter_vintage($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 15);
imagefilter($background, IMG_FILTER_CONTRAST, -25);
imagefilter($background, IMG_FILTER_COLORIZE, -10, -5, -15);
imagefilter($background, IMG_FILTER_SMOOTH, 7);
$background = gd_apply_overlay($background, 'scratch', 7);
return $background;
}
/** Apply 'Monopin' preset */
function gd_filter_monopin($background)
{
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
$background = gd_apply_overlay($background, 'vignette', 100);
return $background;
}
/** Apply 'Antique' preset */
function gd_filter_antique($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 0);
imagefilter($background, IMG_FILTER_CONTRAST, -30);
imagefilter($background, IMG_FILTER_COLORIZE, 75, 50, 25);
return $background;
}
/** Apply 'Black & White' preset */
function gd_filter_blackwhite($background)
{
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_CONTRAST, -20);
return $background;
}
/** Apply 'Colour Boost' preset */
function gd_filter_boost($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -35);
imagefilter($background, IMG_FILTER_COLORIZE, 25, 25, 25);
return $background;
}
/** Apply 'Sepia' preset */
function gd_filter_sepia($background)
{
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, -10);
imagefilter($background, IMG_FILTER_CONTRAST, -20);
imagefilter($background, IMG_FILTER_COLORIZE, 60, 30, -15);
return $background;
}
/** Apply 'Partial blur' preset */
function gd_filter_blur($background)
{
imagefilter($background, IMG_FILTER_SELECTIVE_BLUR);
imagefilter($background, IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
imagefilter($background, IMG_FILTER_SMOOTH, -2);
return $background;
}
/** Apply a PNG overlay */
function gd_apply_overlay($background, $brand, $amount)
{
$width = imagesx($background);
if($mag=="yes")
{
$height = 666;
}
else
{
$height = 514;
}
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$brand = 'filters/effects/' . $brand . '.png';
$photo2 = imagecreatefrompng($brand);
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0, 0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}