Created
October 15, 2013 14:31
-
-
Save webandphp/6992461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo <<<_END | |
<font face='Courier New' size='4'><pre> | |
<ul> | |
<b><u>PHP PICTURE PROCESSOR</u> | |
<form method='post' action='picproc.php' | |
enctype='multipart/form-data'> | |
UPLOAD : <input type='file' name='p' size='1'> | |
ACTION : <select name='a'> | |
<option value=0>No Action | |
<option value=1>Sharpen | |
<option value=2>Blur | |
<option value=3>Brighten | |
<option value=4>Darken | |
<option value=5>More Contrast | |
<option value=6>Less Contrast | |
<option value=7>Greyscale | |
<option value=8>Invert | |
<option value=9>Reder | |
<option value=10>Greener | |
<option value=11>Bluer | |
<option value=12>Edge Detect | |
<option value=13>Emboss | |
<option value=14>Sketchify | |
</select> | |
RESIZE : W <input type='text' name='w' | |
size='1'> H <input type='text' name='h' size='1'> | |
<input type='submit'></form></pre> | |
</ul> | |
_END; | |
$p = $_FILES['p']['name']; | |
$a = $_POST['a']; | |
$w = $_POST['w']; | |
$h = $_POST['h']; | |
$t = "pic.jpg"; | |
$rn = rand(0, 65535); | |
if ($p) | |
{ | |
move_uploaded_file($_FILES['p']['tmp_name'], $t); | |
switch($_FILES['p']['type']) | |
{ | |
case "image/gif": $s = imagecreatefromgif($t); break; | |
case "image/jpeg": $s = imagecreatefromjpeg($t); break; | |
case "image/png": $s = imagecreatefrompng($t); break; | |
} | |
@imagejpeg($s, $t); | |
} | |
else $s = @imagecreatefromjpeg($t); | |
switch($a) | |
{ | |
case 1: @imageconvolution($s, array(array(-1, -1, -1), | |
array(-1, 16, -1), array(-1, -1, -1)), 8, 0); break; | |
case 2: @imagefilter($s, IMG_FILTER_GAUSSIAN_BLUR); break; | |
case 3: @imagefilter($s, IMG_FILTER_BRIGHTNESS, 20); break; | |
case 4: @imagefilter($s, IMG_FILTER_BRIGHTNESS, -20); break; | |
case 5: @imagefilter($s, IMG_FILTER_CONTRAST, -20); break; | |
case 6: @imagefilter($s, IMG_FILTER_CONTRAST, 20); break; | |
case 7: @imagefilter($s, IMG_FILTER_GRAYSCALE); break; | |
case 8: @imagefilter($s, IMG_FILTER_NEGATE); break; | |
case 9: @imagefilter($s, IMG_FILTER_COLORIZE, 128, 0, 0, 50); break; | |
case 10: @imagefilter($s, IMG_FILTER_COLORIZE, 0, 128, 0, 50); break; | |
case 11: @imagefilter($s, IMG_FILTER_COLORIZE, 0, 0, 128, 50); break; | |
case 12: @imagefilter($s, IMG_FILTER_EDGEDETECT); break; | |
case 13: @imagefilter($s, IMG_FILTER_EMBOSS); break; | |
case 14: @imagefilter($s, IMG_FILTER_MEAN_REMOVAL); break; | |
} | |
if ($w) | |
{ | |
list($tw, $th) = getimagesize($t); | |
$s1 = imagecreatetruecolor($w, $h); | |
imagecopyresampled($s1, $s, 0, 0, 0, 0, $w, $h, $tw, $th); | |
imagejpeg($s1, $t); | |
imagedestroy($s1); | |
} | |
else @imagejpeg($s, $t); | |
@imagedestroy($s); | |
if (file_exists($t)) echo "<img src=$t?rn=$rn>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment