Esempio n. 1
0
/**
 * Creates a thumbnail out of the given File/Image
 *
 * This function creates a thumbimage out of the File/Image given in $imagePath
 * The settings which are given in $settings are applied during creation. Finaly
 * the new image is saved in the $thumbPath-Folder with the Name $imageName.
 * If it is not possible to create a thumbnail out of $imagePath, a Icon is used
 * and transformed according the $settings.
 *
 * @param string $imagePath Image/File
 * @param string $imageName Name of the Image/File which is created, inclusive extension
 * @param string $thumbPath Path to the folder in which the created file is saved
 * @param array $settings   Settings array with the configuration of the uploadclass
 * @return boolean
 */
function FG_createThumb($imagePath, $imageName, $thumbPath, $settings)
{
    $handle = new upload(DirectoryHandler::DecodePath($imagePath));
    if (!$handle->file_is_image) {
        switch ($handle->file_src_mime) {
            case 'application/x-shockwave-flash':
                $handle = new upload(WB_PATH . '/modules/foldergallery/images/swf_icon.png');
                break;
            case 'video/quicktime':
                $handle = new upload(WB_PATH . '/modules/foldergallery/images/quicktime_icon.png');
                break;
            default:
                $handle = new upload(WB_PATH . '/modules/foldergallery/images/unknown_icon.png');
        }
    }
    if ($handle->file_is_image) {
        FG_appendThumbSettings($handle, $settings, DirectoryHandler::DecodePath($imageName));
        $handle->process(DirectoryHandler::DecodePath($thumbPath));
        if ($handle->processed) {
            return true;
        }
    }
    return false;
}
Esempio n. 2
0
 $categorie = $query2->fetchRow();
 if ($categorie['parent'] != "-1") {
     $parent = $categorie['parent'] . '/' . $categorie['categorie'];
 } else {
     $parent = '';
 }
 $full_file_link = $url . $root_dir . $parent . '/' . $bildfilename;
 $full_file = $path . $root_dir . $parent . '/' . $bildfilename;
 $thumbFolder = $path . $root_dir . $parent . $thumbdir . '/';
 $thumb_file = $thumbFolder . $bildfilename;
 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
     //Löscht das bisherige Thumbnail
     deleteFile($thumb_file);
     //Create the new Thumb
     $handle = new upload(DirectoryHandler::DecodePath($full_file));
     FG_appendThumbSettings($handle, $settings['tbSettings'], DirectoryHandler::DecodePath($bildfilename));
     $topCrop = floor($_POST['y1']);
     $rightCrop = floor($handle->image_src_x - $_POST['x2']);
     $bottomCrop = floor($handle->image_src_y - $_POST['y2']);
     $leftCrop = floor($_POST['x1']);
     $handle->image_precrop = "{$topCrop} {$rightCrop} {$bottomCrop} {$leftCrop}";
     $handle->process(DirectoryHandler::DecodePath($thumbFolder));
     if ($handle->processed) {
         $admin->print_success($MOD_FOLDERGALLERY['UPDATED_THUMB'], WB_URL . '/modules/foldergallery/admin/modify_cat.php?page_id=' . $page_id . '&section_id=' . $section_id . '&cat_id=' . $cat_id);
     } else {
         $admin->print_error("Could not create a new thumbnail!", WB_URL . '/modules/foldergallery/admin/modify_cat.php?page_id=' . $page_id . '&section_id=' . $section_id . '&cat_id=' . $cat_id);
     }
 } else {
     list($width, $height, $type, $attr) = getimagesize(DirectoryHandler::DecodePath($full_file));
     $previewWidth = $settings['tbSettings']['image_x'];
     $previewHeight = $settings['tbSettings']['image_y'];