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
|
<?php $docRoot = $_SERVER['DOCUMENT_ROOT']; //Set images folder. (optional parameter) define("FOLDER_IMAGES",$docRoot); //Set cache folder. (must parameter) define("FOLDER_CACHE","cache");
//Set jpeg quality define("JPEG_QUALITY","80"); //set image not found filepath. a must parameter. Output this image in case the image not found. define("FILEPATH_IMAGE_NOT_FOUND","images_system/image_not_found.jpg"); //-------------------------------------------------------------------- require_once 'get_image.class.php'; //set defines data $getImage = new GetImage(); $getImage->setImagesFolder(FOLDER_IMAGES); $getImage->setCacheFolder(FOLDER_CACHE); $getImage->setErrorImagePath(FILEPATH_IMAGE_NOT_FOUND); $getImage->setJpegQuality(JPEG_QUALITY); //validate "img" if(!isset($_GET["img"])){ echo "Image not found, please use format like: <b>getimage.php?img=pic.jpg</b>"; exit(); } //set image url $img = $_GET["img"]; //set widht and height $width = -1; $width = isset($_GET["w"])?$_GET["w"]:-1; $height = isset($_GET["h"])?$_GET["h"]:-1; //set type $type = ""; if(isset($_GET["exact"])) $type = GetImage::TYPE_EXACT; else if(isset($_GET["exacttop"])) $type = GetImage::TYPE_EXACT_TOP; //call show image function $getImage->showImage($img,$width,$height,$type); ?>
|