Dit ooit es gemaakt, nooit echt gebruikt. Misschien heeft iemand er nog wat aan. Je hebt wel JPEG support en GD2 nodig in je PHP (is onder windows niet zo lastig, onder linux is GD2 compileren nogal rottig).
Helaas heb ik 'm niet ergens online staan.
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
| <? set_time_limit(0); // we don't want to timeout. if ((isset($image)) && (is_uploaded_file($image))) { // resize the image if ($HTTP_POST_FILES['image']['type'] != "image/pjpeg") die($HTTP_POST_FILES['image']['type'] . " is not a supported file type"); $inputImg = ImageCreateFromJPEG($image); $srcX = imagesx($inputImg); $srcY = imagesy($inputImg); $dstY = 72; // fixed Y for the image. always the same $maxX = 96; // max X for image, if image is smaller it will be centered $ratio = ($srcY / $dstY); $dstX = ($srcX / $ratio); $outputImg = ImageCreateTrueColor($maxX, $dstY); imagefill($outputImg, 0, 0, ImageColorAllocate($outputImg, 255, 255, 255)); imagecopyresampled($outputImg, $inputImg, (($maxX - $dstX) / 2),0,0,0, $dstX, $dstY, $srcX, $srcY); header("content-type: image/png"); imagepng($outputImg); } else // print the form { printf("<form enctype=\"multipart/form-data\" action=\"\" method=\"post\">"); printf("Resize image: <input name=\"image\" type=\"file\">"); printf("<input type=\"submit\" value=\"Submit Image\">"); printf("</form>"); } ?> |
Helaas heb ik 'm niet ergens online staan.