-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththumb.php
More file actions
64 lines (53 loc) · 2 KB
/
thumb.php
File metadata and controls
64 lines (53 loc) · 2 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
<?php
##################################################
#
# Copyright (c) 2004-2006 OIC Group, Inc.
# Written and Designed by James Hunt
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (defined('EXPONENT')) return;
include_once('exponent_bootstrap.php');
// Initialize the Imaging Subsystem (this does not need the Exponent Framework to function)
include_once('subsystems/image.php');
if (isset($_GET['id'])) {
include_once('subsystems/config/load.php');
// Initialize the Database Subsystem
include_once(BASE.'subsystems/database.php');
$db = exponent_database_connect(DB_USER,DB_PASS,DB_HOST.':'.DB_PORT,DB_NAME);
$file_obj = $db->selectObject('file','id='. intval($_GET['id']));
$_GET['file'] = $file_obj->directory.'/'.$file_obj->filename;
}
$quality = isset($_GET['quality']) ? intval($_GET['quality']) : 75;
$file = BASE.$_GET['file'];
$thumb = null;
if (isset($_GET['constraint'])) {
$thumb = exponent_image_scaleToConstraint($file,$_GET['width'],$_GET['height']);
} else if (isset($_GET['width'])) {
$thumb = exponent_image_scaleToWidth($file,intval($_GET['width']));
} else if (isset($_GET['height'])) {
$thumb = exponent_image_scaleToHeight($file,intval($_GET['height']));
} else if (isset($_GET['scale'])) {
$thumb = exponent_image_scaleByPercent($file,intval($_GET['scale']) / 100);
} else if (isset($_GET['square'])) {
$thumb = exponent_image_scaleToSquare($file,intval($_GET['square']));
}
$mythumb = getimagesize($file);
if ($mythumb[0] > 0 && $mythumb[1] > 0)
{
if (is_resource($thumb)) {
exponent_image_output($thumb, exponent_image_sizeinfo($file), null, $quality);
} else {
exponent_image_showFallbackPreviewImage(BASE, $thumb);
}
}
?>