// 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; } $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); } } } } $mythumb = getimagesize($file); if ($mythumb[0] > 0 && $mythumb[1] > 0) { if (is_resource($thumb)) { exponent_image_output($thumb, exponent_image_sizeinfo($file)); } else { exponent_image_showFallbackPreviewImage(BASE, $thumb); } }
function exponent_image_flip($filename, $is_horizontal) { $sizeinfo = exponent_image_sizeinfo($filename); if (!is_array($sizeinfo)) { return $sizeinfo; } $original = exponent_image_createFromFile($filename, $sizeinfo); if (!is_resource($original)) { return $original; } // Horizontal - invert y coords // Vertical - invert x coords $w = $sizeinfo[0]; $h = $sizeinfo[1]; $new = exponent_image_create($w, $h); if ($is_horizontal) { // Copy column by column //$dest,$src,$dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) { for ($i = 0; $i < $w; $i++) { imagecopy($new, $original, $i, 0, $w - $i - 1, 0, 1, $h); //src_W, src_H } } else { // Copy row by row. //$dest,$src,$dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) { for ($i = 0; $i < $h; $i++) { imagecopy($new, $original, 0, $i, 0, $h - $i - 1, $w, 1); //src_W, src_H } } return $new; }