Exemplo n.º 1
0
 /**
  * flagAdmin::resize_image() - create a new image, based on the height /width
  * 
  * @class flagAdmin
  * @param object | int $image contain all information about the image or the id
  * @param integer $width optional 
  * @param integer $height optional
  * @return string result code
  */
 static function resize_image($image, $width = 0, $height = 0)
 {
     global $flag;
     if (!class_exists('flag_Thumbnail')) {
         require_once flagGallery::graphic_library();
     }
     if (is_numeric($image)) {
         $image = flagdb::find_image($image);
     }
     if (!is_object($image)) {
         return __('Object didn\'t contain correct data', 'flag');
     }
     // before we start we import the meta data to database (required for uploads before V0.40)
     flagAdmin::maybe_import_meta($image->pid);
     // if no parameter is set, take global settings
     $width = $width == 0 ? $flag->options['imgWidth'] : $width;
     $height = $height == 0 ? $flag->options['imgHeight'] : $height;
     if (!is_writable($image->imagePath)) {
         return ' <strong>' . $image->filename . __(' is not writeable', 'flag') . '</strong>';
     }
     $file = new flag_Thumbnail($image->imagePath, TRUE);
     // skip if file is not there
     if (!$file->error) {
         $file->resize($width, $height, 4);
         $file->save($image->imagePath, $flag->options['imgQuality']);
         // read the new sizes
         $size = @getimagesize($image->imagePath);
         // add them to the database
         flagdb::update_image_meta($image->pid, array('width' => $size[0], 'height' => $size[1]));
         $file->destruct();
     } else {
         $file->destruct();
         return ' <strong>' . $image->filename . ' (Error : ' . $file->errmsg . ')</strong>';
     }
     return '1';
 }
Exemplo n.º 2
0
    die(__('Cheatin&#8217; uh?'));
}
if (!current_user_can('FlAG Manage gallery')) {
    die(__('Cheatin&#8217; uh?'));
}
global $wpdb;
$id = (int) $_GET['id'];
// let's get the image data
$picture = flagdb::find_image($id);
include_once flagGallery::graphic_library();
$flag_options = get_option('flag_options');
$thumb = new flag_Thumbnail($picture->imagePath, TRUE);
$thumb->resize(350, 350);
// we need the new dimension
$resizedPreviewInfo = $thumb->newDimensions;
$thumb->destruct();
$preview_image = FLAG_URLPATH . 'flagshow.php?pid=' . $picture->pid . '&amp;width=350&amp;height=350';
$imageInfo = @getimagesize($picture->imagePath);
$rr = round($imageInfo[0] / $resizedPreviewInfo['newWidth'], 2);
$WidthHtmlPrev = $flag_options['thumbWidth'];
$HeightHtmlPrev = $flag_options['thumbHeight'];
if ($flag_options['thumbFix'] == 1) {
    $WidthHtmlPrev = $flag_options['thumbWidth'];
    $HeightHtmlPrev = $flag_options['thumbHeight'];
} else {
    // H > W
    if ($imageInfo[1] > $imageInfo[0]) {
        $HeightHtmlPrev = $flag_options['thumbHeight'];
        $WidthHtmlPrev = round($imageInfo[0] / ($imageInfo[1] / $flag_options['thumbHeight']), 0);
    } else {
        $WidthtHtmlPrev = $flag_options['thumbWidth'];