-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathimage-edit.php
More file actions
123 lines (122 loc) · 5.26 KB
/
image-edit.php
File metadata and controls
123 lines (122 loc) · 5.26 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
$fieldname = 'image';
$savepath = $_SERVER['DOCUMENT_ROOT'] . '/images/avatars';
$savename = isset($_GET['savename']) ? $_GET['savename'] : '';
if (empty($savename)) {
$savename = isset($_POST['savename']) ? $_POST['savename'] : '';
}
$config = array(
'savepath' => $savepath,
'savename' => $savename
);
/*----*/
$step = 1;
require 'ImageEdit.php';
$imageEdit = new ImageEdit($config);
$imageEdit->run();
$vals = $imageEdit->getValues();
if ($vals['has_img']) {
$step = 2;
}
if ($vals['saved']) {
$step = 3;
}
?>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Image Editor</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-jasny.min.css">
<link rel="stylesheet" href="css/jquery.Jcrop.min.css">
<link rel="stylesheet" href="css/style.min.css">
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<?php if ($step == 1): ?>
<h1>Step 1: Choose image</h1>
<?php if(!empty($vals['errors'])): ?>
<?php foreach($vals['errors'] as $error): ?>
<p class="alert alert-error"><?php echo $error; ?></p>
<?php endforeach; ?>
<?php endif; ?>
<form id="upload_form" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" id="savename" name="savename" value="<?php echo $savename; ?>" />
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;"><img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" /></div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Select image</span><span class="fileupload-exists">Change</span><input type="file" name="<?php echo $fieldname; ?>" id="fileinput" /></span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload" id="remove">Remove</a>
<button type="submit" class="btn" id="btn-next">Next</button>
</div>
</div>
</form>
<?php elseif ($step == 2): ?>
<h1>Step 2: Edit Image</h1>
<?php if(!empty($vals['errors'])): ?>
<?php foreach($vals['errors'] as $error): ?>
<p class="alert alert-error"><?php echo $error; ?></p>
<?php endforeach; ?>
<?php endif; ?>
<form id="edit_form" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" id="cache_id" name="cache_id" value="<?php echo $vals['cache_id']; ?>" />
<input type="hidden" id="ext" name="ext" value="<?php echo $vals['ext']; ?>" />
<input type="hidden" id="max_version" name="max_version" value="<?php echo $vals['max_version']; ?>" />
<input type="hidden" id="savename" name="savename" value="<?php echo $savename; ?>" />
<input type="hidden" id="version" name="version" value="<?php echo $vals['version']; ?>" />
<input type="hidden" id="x" name="x">
<input type="hidden" id="y" name="y">
<input type="hidden" id="w" name="w">
<input type="hidden" id="h" name="h">
<input type="hidden" id="action" name="action">
<div id="toolbar" class="btn-toolbar">
<div class="btn-group btn-toolbar">
<button type="submit" class="btn btn-primary btn-small" id="btn-undo" data-action="undo"><i class="icon-undo"></i> Undo</button>
<button type="submit" class="btn btn-primary btn-small" id="btn-redo" data-action="redo"><i class="icon-redo"></i> Redo</button>
</div>
<div class="btn-group btn-toolbar">
<button type="submit" class="btn btn-primary btn-small btn-small" id="btn-anticlockwise" data-action="anticlockwise"><i class="icon-anticlockwise"></i> Rotate Anticlockwise</button>
<button type="submit" class="btn btn-primary btn-small" id="btn-clockwise" data-action="clockwise"><i class="icon-clockwise"></i> Rotate Clockwise</button>
</div>
<div class="btn-group btn-toolbar">
<button type="submit" class="btn btn-primary btn-small" id="btn-greyscale" data-action="greyscale"><i class="icon-greyscale"></i> Greyscale</button>
<button type="submit" class="btn btn-primary btn-small" id="btn-sepia" data-action="sepia"><i class="icon-greyscale"></i> Sepia</button>
</div>
<div class="btn-group btn-toolbar">
<button type="submit" class="btn btn-primary btn-small" id="btn-crop" data-action="crop"><i class="icon-crop"></i> Crop</button>
</div>
<div class="btn-group btn-toolbar">
<button type="submit" class="btn btn-success btn-small" id="btn-save" data-action="save"><i class="icon-save"></i> Save</button>
</div>
</div>
<div><img src="<?php echo $vals['current_img']; ?>" id="editor" /></div>
</form>
<?php elseif ($step == 3): ?>
<h1>Step 3: Done!</h1>
<p class="alert alert-success">Image successfully saved. All done!</p>
<?php endif; ?>
</div>
</div>
<?php /*
<div class="container-fluid">
<div class="row-fluid">
<?php
echo "<pre>\n";var_dump($vals);echo "</pre>\n";
if (isset($_POST)) {
echo "<pre>\n"; var_dump($_POST); echo "</pre>\n";
if (isset($_FILES)) {
echo "<pre>\n"; var_dump($_FILES); echo "</pre>\n";
}
}
?>
</div>
</div>
*/ ?>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.Jcrop.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>