-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.php
32 lines (24 loc) · 1.08 KB
/
images.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
<?php
include_once 'libs/wideimage/WideImage.php';
if(isset($_GET['name'])) {
$name = $_GET['name'];
$original_name = 'images/'.$name;
if(isset($_GET['width'])) {
$image_width = $_GET['width'];
$info = pathinfo($name);
$adjusted_name = 'thumbs/'.$info['dirname'].'/'.$info['filename'].'_'.$image_width.'.'.$info['extension'];
if(!file_exists($adjusted_name)||
filemtime($original_name)>filemtime($adjusted_name)) {
if(!is_dir('thumbs/'.$info['dirname']))
mkdir('thumbs/'.$info['dirname'],0775,true);
$image = WideImage::load($original_name);
$image = $image->resize($image_width,null);
$image->saveToFile($adjusted_name);
}
} else {
$adjusted_name = $original_name;
}
$image = WideImage::load($adjusted_name);
$image->output('jpg', 90);
}
?>