$original = $db->selectObject('imageworkshop_image', 'id=' . $_POST['id']);
if ($original) {
    $working = $db->selectObject('imageworkshop_imagetmp', 'original_id=' . $original->id);
    if ($working) {
        $original->file_id = $working->file_id;
    }
    $file = $db->selectObject('file', 'id=' . $original->file_id);
    $file->_path = BASE . $file->directory . '/' . $file->filename;
    $wfile = null;
    if ($working == null) {
        $working = imageworkshopmodule::createWorkingCopy($original, $file);
        $wfile = $working->_file;
        unset($working->_file);
    } else {
        $wfile = $db->selectObject('file', 'id=' . $working->file_id);
    }
    $wfile->_path = BASE . $wfile->directory . '/' . $wfile->filename;
    if (!defined('SYS_IMAGE')) {
        require_once BASE . 'subsystems/image.php';
    }
    $newimg = pathos_image_scaleManually($file->_path, $_POST['width'], $_POST['height']);
    if (is_resource($newimg)) {
        pathos_image_output($newimg, pathos_image_sizeinfo($file->_path), $wfile->_path);
        pathos_flow_redirect();
    } else {
        echo $newimg;
    }
} else {
    echo SITE_404_HTML;
}
// END PERM CHECK
Пример #2
0
function pathos_image_flip($filename, $is_horizontal)
{
    $sizeinfo = pathos_image_sizeinfo($filename);
    if (!is_array($sizeinfo)) {
        return $sizeinfo;
    }
    $original = pathos_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 = pathos_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;
}
Пример #3
0
    $info = pathos_image_sizeinfo(BASE . $current->_file->directory . '/' . $current->_file->filename);
    $current->_realname = substr($current->_file->filename, 14);
    $current->_width = $info[0];
    $current->_height = $info[1];
    #		$current->_imagetype = image_type_to_mime_type($info[2]);
    $current->_bitdepth = $info['bits'];
    $current->_filesize_bytes = filesize(BASE . $current->_file->directory . '/' . $current->_file->filename);
    $current->_filesize = pathos_files_bytesToHumanReadable($current->_filesize_bytes);
    $template->assign('current', $current);
    $tmp = $db->selectObject('imageworkshop_imagetmp', 'original_id=' . $current->id);
    if ($tmp == null) {
        $tmp = $current;
        $template->assign('nochange', 1);
    } else {
        $tmp->_file = $db->selectObject('file', 'id=' . $tmp->file_id);
        $info = pathos_image_sizeinfo(BASE . $tmp->_file->directory . '/' . $tmp->_file->filename);
        $tmp->_realname = substr($current->_file->filename, 14);
        #			$tmp->_imagetype = image_type_to_mime_type($info[2]);
        $tmp->_width = $info[0];
        $tmp->_height = $info[1];
        $tmp->_bitdepth = $info['bits'];
        $tmp->_filesize_bytes = filesize(BASE . $tmp->_file->directory . '/' . $tmp->_file->filename);
        $tmp->_filesize = pathos_files_bytesToHumanReadable($tmp->_filesize_bytes);
        $template->assign('nochange', 0);
        $template->assign('sizediff', round($tmp->_filesize_bytes / $current->_filesize_bytes * 100));
    }
    $template->assign('working', $tmp);
}
$template->output();
// END PERM CHECK
?>
Пример #4
0
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 = pathos_database_connect(DB_USER, DB_PASS, DB_HOST . ':' . DB_PORT, DB_NAME);
    $file_obj = $db->selectObject('file', 'id=' . $_GET['id']);
    $_GET['file'] = $file_obj->directory . '/' . $file_obj->filename;
}
$file = BASE . $_GET['file'];
$thumb = null;
if (isset($_GET['constraint'])) {
    $thumb = pathos_image_scaleToConstraint($file, $_GET['width'], $_GET['height']);
} else {
    if (isset($_GET['width'])) {
        $thumb = pathos_image_scaleToWidth($file, $_GET['width']);
    } else {
        if (isset($_GET['height'])) {
            $thumb = pathos_image_scaleToHeight($file, $_GET['height']);
        } else {
            if (isset($_GET['scale'])) {
                $thumb = pathos_image_scaleByPercent($file, $_GET['scale'] / 100);
            }
        }
    }
}
if (is_resource($thumb)) {
    pathos_image_output($thumb, pathos_image_sizeinfo($file));
} else {
    pathos_image_showFallbackPreviewImage(BASE, $thumb);
}