summary refs log tree commit diff stats
path: root/thumb.php
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2008-11-19 17:27:03 -0500
committerStarla Insigna <hatkirby@fourisland.com>2008-11-19 17:27:03 -0500
commit24503e3abe705acde2df159aeae61be0d009f92e (patch)
tree8debbd53dcd0db2f5934c5e2af4e697e3787781d /thumb.php
downloadfourisland-24503e3abe705acde2df159aeae61be0d009f92e.tar.gz
fourisland-24503e3abe705acde2df159aeae61be0d009f92e.tar.bz2
fourisland-24503e3abe705acde2df159aeae61be0d009f92e.zip
Imported sources
Diffstat (limited to 'thumb.php')
-rw-r--r--thumb.php147
1 files changed, 147 insertions, 0 deletions
diff --git a/thumb.php b/thumb.php new file mode 100644 index 0000000..ba9c645 --- /dev/null +++ b/thumb.php
@@ -0,0 +1,147 @@
1<?php
2/*
3 444444444
4 4::::::::4
5 4:::::::::4
6 4::::44::::4
7 4::::4 4::::4 Four Island
8 4::::4 4::::4
9 4::::4 4::::4 Written and maintained by Starla Insigna
104::::444444::::444
114::::::::::::::::4 thumb.php
124444444444:::::444
13 4::::4 Please do not use, reproduce or steal the
14 4::::4 contents of this file without explicit
15 4::::4 permission from Hatkirby.
16 44::::::44
17 4::::::::4
18 4444444444
19*/
20
21require('headerproc.php');
22
23if ($_GET['mode'] != 'scalegif')
24{
25 header('Content-type: image/png');
26} else {
27 header('Content-type: image/gif');
28}
29
30$filename = $_GET['file'];
31
32switch ($_GET['mode'])
33{
34 case 'scale':
35 $mode = 'scale';
36 $side = $_GET['side'];
37 $by = $_GET['by'];
38 if (file_exists($filename)) {
39 $im2 = imagecreatefrompng($filename);
40 list($width, $height, $type, $attr) = getimagesize($filename);
41 if ($side == 0) {
42 if ($by < $width)
43 {
44 $width2 = $by;
45 } else {
46 $width2 = $width;
47 }
48 } else {
49 if ($by < $height)
50 {
51 $width2 = ($width/100)*($height/$by*100);
52 } else {
53 $width2 = $width;
54 }
55 }
56 if ($side == 1) {
57 if ($by < $height)
58 {
59 $height2 = $by;
60 } else {
61 $height2 = $height;
62 }
63 } else {
64 if ($by < $width)
65 {
66 $height2 = ($height/100)*($by/$width*100);
67 } else {
68 $height2 = $height;
69 }
70 }
71 $im = imagecreatetruecolor($width2,$height2);
72 $b = imagecopyresized($im,$im2,0,0,0,0,$width2,$height2,$width,$height);
73 imagepng($im);
74 imagedestroy($im);
75 exit;
76 }
77 case 'scalegif':
78 $mode = 'scalegif';
79 $side = $_GET['side'];
80 $by = $_GET['by'];
81 if (file_exists($filename)) {
82 $im2 = imagecreatefromgif($filename);
83 list($width, $height, $type, $attr) = getimagesize($filename);
84 if ($side == 0) {
85 if ($by < $width)
86 {
87 $width2 = $by;
88 } else {
89 $width2 = $width;
90 }
91 } else {
92 if ($by < $height)
93 {
94 $width2 = ($width/100)*($height/$by*100);
95 } else {
96 $width2 = $width;
97 }
98 }
99 if ($side == 1) {
100 if ($by < $height)
101 {
102 $height2 = $by;
103 } else {
104 $height2 = $height;
105 }
106 } else {
107 if ($by < $width)
108 {
109 $height2 = ($height/100)*($by/$width*100);
110 } else {
111 $height2 = $height;
112 }
113 }
114 $im = imagecreatetruecolor($width2,$height2);
115 $b = imagecopyresized($im,$im2,0,0,0,0,$width2,$height2,$width,$height);
116 imagegif($im);
117 imagedestroy($im);
118 exit;
119 }
120 case 'percent':
121 $mode = 'percent';
122 $by = $_GET['by'];
123 if (file_exists($filename)) {
124 $im2 = imagecreatefrompng($filename);
125 list($width, $height, $type, $attr) = getimagesize($filename);
126 $width2 = ($width/100)*$by;
127 $height2 = ($height/100)*$by;
128 $im = imagecreatetruecolor($width2,$height2);
129 $b = imagecopyresized($im,$im2,0,0,0,0,$width2,$height2,$width,$height);
130 imagepng($im);
131 imagedestroy($im);
132 exit;
133 }
134 default:
135 $string = 'An error was encountered.';
136 $im2 = imagecreatefrompng("images/blue.png");
137 $im = imagecreate(200,30);
138 $b = imagecopyresized($im,$im2,0,0,0,0,400,400,1,1);
139 $orange = imagecolorallocate($im, 220, 210, 60);
140 $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
141 imagestring($im, 3, $px, 9, $string, $orange);
142 imagepng($im);
143 imagedestroy($im);
144 exit;
145}
146
147?>