-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.php
95 lines (82 loc) · 2.51 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/*
PHP IMPROCS Library
dev: Bilal Onur Eskili
cont@ct: onur@bilalonureskili.com
Includes:
Blur Effect => blurEf($url,$level) ~ 05.09.2021
Horizontal Edge Detection => horizontalEdge($url) ~ 06.09.2021
Vertical Edge Detection => verticalEdge($url) ~ 06.09.2021
Laplacian Edge (Outline) => laplacianEdge($url) ~ 06.09.2021
Gray Scale => grayscale($url) ~ 24.03.2023
Resize => resize($url, $width, $height) ~ 24.03.2023
Brightness Adjustment => brightness($url, $level) ~ 24.03.2023
*/
function blurEf($url,$level) {
$image = imagecreatefrompng($url);
if ($level > 1){
for ($i = 1; $i <= $level; $i++) {
$emboss = array(array(0.0625, 0.125, 0.0625), array(0.125, 0.25, 0.125), array(0.0625, 0.125, 0.0625));
imageconvolution($image, $emboss, 1, 0);
}
}
header('Content-Type: image/png');
imagepng($image, null, 9);
}
function horizontalEdge($url) {
$image = imagecreatefrompng($url);
for ($i = 1; $i <= 2; $i++) {
$emboss = array(array(1, 1, 1), array(0, 0, 0), array(-1, -1, -1));
imageconvolution($image, $emboss, 1, 0);
}
header('Content-Type: image/png');
imagepng($image, null, 9);
}
function verticalEdge($url) {
$image = imagecreatefrompng($url);
for ($i = 1; $i <= 2; $i++) {
$emboss = array(array(1, 0, -1), array(1, 0, -1), array(1, 0, -1));
imageconvolution($image, $emboss, 1, 0);
}
header('Content-Type: image/png');
imagepng($image, null, 9);
}
function laplacianEdge($url) {
$image = imagecreatefrompng($url);
for ($i = 1; $i <= 2; $i++) {
$emboss = array(array(-1, -1, -1), array(-1, 8, -1), array(-1, -1, -1));
imageconvolution($image, $emboss, 1, 0);
}
header('Content-Type: image/png');
imagepng($image, null, 9);
}
function grayscale($url) {
$image = imagecreatefrompng($url);
imagefilter($image, IMG_FILTER_GRAYSCALE);
header('Content-Type: image/png');
imagepng($image, null, 9);
}
function resize($url, $w, $h) {
#https://stackoverflow.com/a/14649689
$image = imagecreatefrompng($url);
list($width, $height) = getimagesize($url);
$r = $width / $height;
if ($w/$h > $r) {
$newwidth = $h*$r;
$newheight = $h;
} else {
$newheight = $w/$r;
$newwidth = $w;
}
$dst = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($dst, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
header('Content-Type: image/png');
imagepng($dst, null, 9);
}
function brightness($url, $level) {
$image = imagecreatefrompng($url);
imagefilter($image, IMG_FILTER_BRIGHTNESS, $level);
header('Content-Type: image/png');
imagepng($image, null, 9);
}
?>