|
@@ -1,94 +1,94 @@
|
1
|
|
-<?php
|
2
|
|
- if(!defined('entry') || !entry) die('Not a valid page');
|
3
|
|
-header ("Content-type: image/jpeg");
|
4
|
|
-header('Cache-Control: max-age=172800, must-revalidate');
|
5
|
|
-header('Expires: ' . date('r', time()+120));
|
6
|
|
-
|
7
|
|
-JPEG / PNG Image Resizer
|
8
|
|
-Parameters (passed via URL):
|
9
|
|
-
|
10
|
|
-img = path / url of jpeg or png image file
|
11
|
|
-
|
12
|
|
-percent = if this is defined, image is resized by it's
|
13
|
|
- value in percent (i.e. 50 to divide by 50 percent)
|
14
|
|
-
|
15
|
|
-w = image width
|
16
|
|
-
|
17
|
|
-h = image height
|
18
|
|
-
|
19
|
|
-constrain = if this is parameter is passed and w and h are set
|
20
|
|
- to a size value then the size of the resulting image
|
21
|
|
- is constrained by whichever dimension is smaller
|
22
|
|
-
|
23
|
|
-Requires the PHP GD Extension
|
24
|
|
-
|
25
|
|
-Outputs the resulting image in JPEG Format
|
26
|
|
-
|
27
|
|
-By: Michael John G. Lopez - www.sydel.net
|
28
|
|
-Filename : imgsize.php
|
29
|
|
-*/
|
30
|
|
-
|
31
|
|
-$img = $_GET['img'];
|
32
|
|
-$percent = $_GET['percent'];
|
33
|
|
-$constrain = $_GET['constrain'];
|
34
|
|
-$w = $_GET['w'];
|
35
|
|
-$h = $_GET['h'];
|
36
|
|
-
|
37
|
|
-
|
38
|
|
-$x = @getimagesize($img);
|
39
|
|
-
|
40
|
|
-$sw = $x[0];
|
41
|
|
-
|
42
|
|
-$sh = $x[1];
|
43
|
|
-
|
44
|
|
-if ($percent > 0) {
|
45
|
|
-
|
46
|
|
- $percent = $percent * 0.01;
|
47
|
|
- $w = $sw * $percent;
|
48
|
|
- $h = $sh * $percent;
|
49
|
|
-} else {
|
50
|
|
- if (isset ($w) AND !isset ($h)) {
|
51
|
|
-
|
52
|
|
- $h = (100 / ($sw / $w)) * .01;
|
53
|
|
- $h = @round ($sh * $h);
|
54
|
|
- } elseif (isset ($h) AND !isset ($w)) {
|
55
|
|
-
|
56
|
|
- $w = (100 / ($sh / $h)) * .01;
|
57
|
|
- $w = @round ($sw * $w);
|
58
|
|
- } elseif (isset ($h) AND isset ($w) AND isset ($constrain)) {
|
59
|
|
-
|
60
|
|
-
|
61
|
|
- $hx = (100 / ($sw / $w)) * .01;
|
62
|
|
- $hx = @round ($sh * $hx);
|
63
|
|
-
|
64
|
|
- $wx = (100 / ($sh / $h)) * .01;
|
65
|
|
- $wx = @round ($sw * $wx);
|
66
|
|
-
|
67
|
|
- if ($hx < $h) {
|
68
|
|
- $h = (100 / ($sw / $w)) * .01;
|
69
|
|
- $h = @round ($sh * $h);
|
70
|
|
- } else {
|
71
|
|
- $w = (100 / ($sh / $h)) * .01;
|
72
|
|
- $w = @round ($sw * $w);
|
73
|
|
- }
|
74
|
|
- }
|
75
|
|
-}
|
76
|
|
-
|
77
|
|
-$im = @ImageCreateFromJPEG ($img) or
|
78
|
|
-$im = @ImageCreateFromPNG ($img) or
|
79
|
|
-$im = @ImageCreateFromGIF ($img) or
|
80
|
|
-$im = false;
|
81
|
|
-
|
82
|
|
-if (!$im) {
|
83
|
|
-
|
84
|
|
-
|
85
|
|
- readfile ($img);
|
86
|
|
-} else {
|
87
|
|
-
|
88
|
|
- $thumb = @ImageCreateTrueColor ($w, $h);
|
89
|
|
-
|
90
|
|
- @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh);
|
91
|
|
-
|
92
|
|
- @ImageJPEG ($thumb);
|
93
|
|
-}
|
94
|
|
-?>
|
|
1
|
+<?php
|
|
2
|
+ if(!defined('entry')) define('entry',true);
|
|
3
|
+header ("Content-type: image/jpeg");
|
|
4
|
+header('Cache-Control: max-age=172800, must-revalidate');
|
|
5
|
+header('Expires: ' . date('r', time()+120));
|
|
6
|
+
|
|
7
|
+JPEG / PNG Image Resizer
|
|
8
|
+Parameters (passed via URL):
|
|
9
|
+
|
|
10
|
+img = path / url of jpeg or png image file
|
|
11
|
+
|
|
12
|
+percent = if this is defined, image is resized by it's
|
|
13
|
+ value in percent (i.e. 50 to divide by 50 percent)
|
|
14
|
+
|
|
15
|
+w = image width
|
|
16
|
+
|
|
17
|
+h = image height
|
|
18
|
+
|
|
19
|
+constrain = if this is parameter is passed and w and h are set
|
|
20
|
+ to a size value then the size of the resulting image
|
|
21
|
+ is constrained by whichever dimension is smaller
|
|
22
|
+
|
|
23
|
+Requires the PHP GD Extension
|
|
24
|
+
|
|
25
|
+Outputs the resulting image in JPEG Format
|
|
26
|
+
|
|
27
|
+By: Michael John G. Lopez - www.sydel.net
|
|
28
|
+Filename : imgsize.php
|
|
29
|
+*/
|
|
30
|
+
|
|
31
|
+$img = $_GET['img'];
|
|
32
|
+$percent = $_GET['percent'];
|
|
33
|
+$constrain = $_GET['constrain'];
|
|
34
|
+$w = $_GET['w'];
|
|
35
|
+$h = $_GET['h'];
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+$x = @getimagesize($img);
|
|
39
|
+
|
|
40
|
+$sw = $x[0];
|
|
41
|
+
|
|
42
|
+$sh = $x[1];
|
|
43
|
+
|
|
44
|
+if ($percent > 0) {
|
|
45
|
+
|
|
46
|
+ $percent = $percent * 0.01;
|
|
47
|
+ $w = $sw * $percent;
|
|
48
|
+ $h = $sh * $percent;
|
|
49
|
+} else {
|
|
50
|
+ if (isset ($w) AND !isset ($h)) {
|
|
51
|
+
|
|
52
|
+ $h = (100 / ($sw / $w)) * .01;
|
|
53
|
+ $h = @round ($sh * $h);
|
|
54
|
+ } elseif (isset ($h) AND !isset ($w)) {
|
|
55
|
+
|
|
56
|
+ $w = (100 / ($sh / $h)) * .01;
|
|
57
|
+ $w = @round ($sw * $w);
|
|
58
|
+ } elseif (isset ($h) AND isset ($w) AND isset ($constrain)) {
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+ $hx = (100 / ($sw / $w)) * .01;
|
|
62
|
+ $hx = @round ($sh * $hx);
|
|
63
|
+
|
|
64
|
+ $wx = (100 / ($sh / $h)) * .01;
|
|
65
|
+ $wx = @round ($sw * $wx);
|
|
66
|
+
|
|
67
|
+ if ($hx < $h) {
|
|
68
|
+ $h = (100 / ($sw / $w)) * .01;
|
|
69
|
+ $h = @round ($sh * $h);
|
|
70
|
+ } else {
|
|
71
|
+ $w = (100 / ($sh / $h)) * .01;
|
|
72
|
+ $w = @round ($sw * $w);
|
|
73
|
+ }
|
|
74
|
+ }
|
|
75
|
+}
|
|
76
|
+
|
|
77
|
+$im = @ImageCreateFromJPEG ($img) or
|
|
78
|
+$im = @ImageCreateFromPNG ($img) or
|
|
79
|
+$im = @ImageCreateFromGIF ($img) or
|
|
80
|
+$im = false;
|
|
81
|
+
|
|
82
|
+if (!$im) {
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+ readfile ($img);
|
|
86
|
+} else {
|
|
87
|
+
|
|
88
|
+ $thumb = @ImageCreateTrueColor ($w, $h);
|
|
89
|
+
|
|
90
|
+ @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh);
|
|
91
|
+
|
|
92
|
+ @ImageJPEG ($thumb);
|
|
93
|
+}
|
|
94
|
+?>
|