-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveBase.php
More file actions
executable file
·32 lines (29 loc) · 1.07 KB
/
Copy pathsaveBase.php
File metadata and controls
executable file
·32 lines (29 loc) · 1.07 KB
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
<?php
// Save the base image to disk so that we can use it throughout the
// application. This state only happens once.
// Get the details about the base image. We'll use these details later in the javascript.
list($w, $h, $type, $ignored) = getimagesize($_FILES['baseImage']['tmp_name']);
$baseFile = $_SESSION['dataDir']."base";
$base = new Image();
$base->height = $h;
$base->width = $w;
// Store the image url in a session variable and save the image to the data directory.
switch($type) {
case IMAGETYPE_GIF:
$base->url = $baseFile.".gif";
$base->worldFileUrl = $baseFile.".gfw";
imagegif(imagecreatefromgif($_FILES['baseImage']['tmp_name']), $base->url);
break;
case IMAGETYPE_JPEG:
$base->url = $baseFile.".jpg";
$base->worldFileUrl = $baseFile.".jgw";
imagejpeg(imagecreatefromjpeg($_FILES['baseImage']['tmp_name']), $base->url);
break;
case IMAGETYPE_PNG:
$base->url = $baseFile.".png";
$base->worldFileUrl = $baseFile.".pgw";
imagepng(imagecreatefrompng($_FILES['baseImage']['tmp_name']), $base->url);
break;
}
$_SESSION['baseImage'] = $base;
?>