当前位置: 首页>>代码示例>>PHP>>正文


PHP nggGallery::graphic_library方法代码示例

本文整理汇总了PHP中nggGallery::graphic_library方法的典型用法代码示例。如果您正苦于以下问题:PHP nggGallery::graphic_library方法的具体用法?PHP nggGallery::graphic_library怎么用?PHP nggGallery::graphic_library使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nggGallery的用法示例。


在下文中一共展示了nggGallery::graphic_library方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createNewThumb

function createNewThumb()
{
    global $ngg;
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    include_once nggGallery::graphic_library();
    $id = (int) $_POST['id'];
    $picture = nggdb::find_image($id);
    $x = round($_POST['x'] * $_POST['rr'], 0);
    $y = round($_POST['y'] * $_POST['rr'], 0);
    $w = round($_POST['w'] * $_POST['rr'], 0);
    $h = round($_POST['h'] * $_POST['rr'], 0);
    $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
    $thumb->crop($x, $y, $w, $h);
    // Note : the routine is a bit different to create_thumbnail(), due to rounding it's resized in the other way
    if ($ngg->options['thumbfix']) {
        // check for portrait format
        if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
            // first resize to the wanted height, here changed to create_thumbnail()
            $thumb->resize(0, $ngg->options['thumbheight']);
            // get optimal y startpos
            $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
            $thumb->crop(0, $ypos, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
        } else {
            // first resize to the wanted width, here changed to create_thumbnail()
            $thumb->resize($ngg->options['thumbwidth'], 0);
            //
            // get optimal x startpos
            $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
            $thumb->crop($xpos, 0, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
        }
        //this create a thumbnail but keep ratio settings
    } else {
        $thumb->resize($ngg->options['thumbwidth'], $ngg->options['thumbheight']);
    }
    if ($thumb->save($picture->thumbPath, 100)) {
        //read the new sizes
        $new_size = @getimagesize($picture->thumbPath);
        $size['width'] = $new_size[0];
        $size['height'] = $new_size[1];
        // add them to the database
        nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    exit;
}
开发者ID:jhersonn20,项目名称:myportal,代码行数:55,代码来源:ajax.php

示例2: createNewThumb

function createNewThumb()
{
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    require_once dirname(dirname(__FILE__)) . '/ngg-config.php';
    include_once nggGallery::graphic_library();
    $ngg_options = get_option('ngg_options');
    $id = (int) $_POST['id'];
    $picture = nggdb::find_image($id);
    $x = round($_POST['x'] * $_POST['rr'], 0);
    $y = round($_POST['y'] * $_POST['rr'], 0);
    $w = round($_POST['w'] * $_POST['rr'], 0);
    $h = round($_POST['h'] * $_POST['rr'], 0);
    $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
    $thumb->crop($x, $y, $w, $h);
    if ($ngg_options['thumbfix']) {
        if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
            $thumb->resize($ngg_options['thumbwidth'], 0);
        } else {
            $thumb->resize(0, $ngg_options['thumbheight']);
        }
    } else {
        $thumb->resize($ngg_options['thumbwidth'], $ngg_options['thumbheight'], $ngg_options['thumbResampleMode']);
    }
    if ($thumb->save($picture->thumbPath, 100)) {
        //read the new sizes
        $new_size = @getimagesize($picture->thumbPath);
        $size['width'] = $new_size[0];
        $size['height'] = $new_size[1];
        // add them to the database
        nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    exit;
}
开发者ID:alx,项目名称:SimplePress,代码行数:44,代码来源:ajax.php

示例3: set_watermark

 /**
  * nggAdmin::set_watermark() - set the watermark for the image
  * 
  * @class nggAdmin
  * @param object | int $image contain all information about the image or the id
  * @return string result code
  */
 function set_watermark($image)
 {
     global $ngg;
     if (!class_exists('ngg_Thumbnail')) {
         require_once nggGallery::graphic_library();
     }
     if (is_numeric($image)) {
         $image = nggdb::find_image($image);
     }
     if (!is_object($image)) {
         return __('Object didn\'t contain correct data', 'nggallery');
     }
     // before we start we import the meta data to database (required for uploads before V1.4.0)
     nggAdmin::maybe_import_meta($image->pid);
     if (!is_writable($image->imagePath)) {
         return ' <strong>' . $image->filename . __(' is not writeable', 'nggallery') . '</strong>';
     }
     $file = new ngg_Thumbnail($image->imagePath, TRUE);
     // skip if file is not there
     if (!$file->error) {
         // If required save a backup copy of the file
         if ($ngg->options['imgBackup'] == 1 && !file_exists($image->imagePath . '_backup')) {
             @copy($image->imagePath, $image->imagePath . '_backup');
         }
         if ($ngg->options['wmType'] == 'image') {
             $file->watermarkImgPath = $ngg->options['wmPath'];
             $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
         }
         if ($ngg->options['wmType'] == 'text') {
             $file->watermarkText = $ngg->options['wmText'];
             $file->watermarkCreateText($ngg->options['wmColor'], $ngg->options['wmFont'], $ngg->options['wmSize'], $ngg->options['wmOpaque']);
             $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
         }
         $file->save($image->imagePath, $ngg->options['imgQuality']);
     }
     $file->destruct();
     if (!empty($file->errmsg)) {
         return ' <strong>' . $image->filename . ' (Error : ' . $file->errmsg . ')</strong>';
     }
     return '1';
 }
开发者ID:ahsaeldin,项目名称:projects,代码行数:48,代码来源:functions.php

示例4: dirname

 jCrop : Kelly Hallman <khallman@wrack.org> | http://deepliquid.com/content/Jcrop.html
 
**/
require_once dirname(dirname(__FILE__)) . '/ngg-config.php';
require_once NGGALLERY_ABSPATH . '/lib/image.php';
if (!is_user_logged_in()) {
    die(__('Cheatin&#8217; uh?'));
}
if (!current_user_can('NextGEN Manage gallery')) {
    die(__('Cheatin&#8217; uh?'));
}
global $wpdb;
$id = (int) $_GET['id'];
// let's get the image data
$picture = nggdb::find_image($id);
include_once nggGallery::graphic_library();
$ngg_options = get_option('ngg_options');
$thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
$thumb->resize(350, 350);
// we need the new dimension
$resizedPreviewInfo = $thumb->newDimensions;
$thumb->destruct();
$preview_image = NGGALLERY_URLPATH . 'nggshow.php?pid=' . $picture->pid . '&amp;width=350&amp;height=350';
$imageInfo = @getimagesize($picture->imagePath);
$rr = round($imageInfo[0] / $resizedPreviewInfo['newWidth'], 2);
if ($ngg_options['thumbfix'] == 1) {
    $WidthHtmlPrev = $ngg_options['thumbwidth'];
    $HeightHtmlPrev = $ngg_options['thumbheight'];
} else {
    // H > W
    if ($imageInfo[1] > $imageInfo[0]) {
开发者ID:ahsaeldin,项目名称:projects,代码行数:31,代码来源:edit-thumbnail.php

示例5: cached_singlepic_file

 /**
  * This function creates a cache for all singlepics to reduce the CPU load
  * 
  * @param int $width
  * @param int $height
  * @param string $mode could be watermark | web20 | crop
  * @return the url for the image or false if failed 
  */
 function cached_singlepic_file($width = '', $height = '', $mode = '')
 {
     $ngg_options = get_option('ngg_options');
     include_once nggGallery::graphic_library();
     // cache filename should be unique
     $cachename = $this->pid . '_' . $mode . '_' . $width . 'x' . $height . '_' . $this->filename;
     $cachefolder = WINABSPATH . $ngg_options['gallerypath'] . 'cache/';
     $cached_url = site_url() . '/' . $ngg_options['gallerypath'] . 'cache/' . $cachename;
     $cached_file = $cachefolder . $cachename;
     // check first for the file
     if (file_exists($cached_file)) {
         return $cached_url;
     }
     // create folder if needed
     if (!file_exists($cachefolder)) {
         if (!wp_mkdir_p($cachefolder)) {
             return false;
         }
     }
     $thumb = new ngg_Thumbnail($this->imagePath, TRUE);
     // echo $thumb->errmsg;
     if (!$thumb->error) {
         if ($mode == 'crop') {
             // calculates the new dimentions for a downsampled image
             list($ratio_w, $ratio_h) = wp_constrain_dimensions($thumb->currentDimensions['width'], $thumb->currentDimensions['height'], $width, $height);
             // check ratio to decide which side should be resized
             $ratio_h < $height || $ratio_w == $width ? $thumb->resize(0, $height) : $thumb->resize($width, 0);
             // get the best start postion to crop from the middle
             $ypos = ($thumb->currentDimensions['height'] - $height) / 2;
             $thumb->crop(0, $ypos, $width, $height);
         } else {
             $thumb->resize($width, $height);
         }
         if ($mode == 'watermark') {
             if ($ngg_options['wmType'] == 'image') {
                 $thumb->watermarkImgPath = $ngg_options['wmPath'];
                 $thumb->watermarkImage($ngg_options['wmPos'], $ngg_options['wmXpos'], $ngg_options['wmYpos']);
             }
             if ($ngg_options['wmType'] == 'text') {
                 $thumb->watermarkText = $ngg_options['wmText'];
                 $thumb->watermarkCreateText($ngg_options['wmColor'], $ngg_options['wmFont'], $ngg_options['wmSize'], $ngg_options['wmOpaque']);
                 $thumb->watermarkImage($ngg_options['wmPos'], $ngg_options['wmXpos'], $ngg_options['wmYpos']);
             }
         }
         if ($mode == 'web20') {
             $thumb->createReflection(40, 40, 50, false, '#a4a4a4');
         }
         // save the new cache picture
         $thumb->save($cached_file, $ngg_options['imgQuality']);
     }
     $thumb->destruct();
     // check again for the file
     if (file_exists($cached_file)) {
         return $cached_url;
     }
     return false;
 }
开发者ID:jhersonn20,项目名称:myportal,代码行数:65,代码来源:image.php

示例6: cached_singlepic_file

 function cached_singlepic_file($width = '', $height = '', $mode = '')
 {
     // This function creates a cache for all singlepics to reduce the CPU load
     $ngg_options = get_option('ngg_options');
     include_once nggGallery::graphic_library();
     // cache filename should be unique
     $cachename = $this->pid . '_' . $mode . '_' . $width . 'x' . $height . '_' . $this->filename;
     $cachefolder = WINABSPATH . $ngg_options['gallerypath'] . 'cache/';
     $cached_url = get_option('siteurl') . '/' . $ngg_options['gallerypath'] . 'cache/' . $cachename;
     $cached_file = $cachefolder . $cachename;
     // check first for the file
     if (file_exists($cached_file)) {
         return $cached_url;
     }
     // create folder if needed
     if (!file_exists($cachefolder)) {
         if (!wp_mkdir_p($cachefolder)) {
             return false;
         }
     }
     $thumb = new ngg_Thumbnail($this->imagePath, TRUE);
     // echo $thumb->errmsg;
     if (!$thumb->error) {
         $thumb->resize($width, $height);
         if ($mode == 'watermark') {
             if ($ngg_options['wmType'] == 'image') {
                 $thumb->watermarkImgPath = $ngg_options['wmPath'];
                 $thumb->watermarkImage($ngg_options['wmPos'], $ngg_options['wmXpos'], $ngg_options['wmYpos']);
             }
             if ($ngg_options['wmType'] == 'text') {
                 $thumb->watermarkText = $ngg_options['wmText'];
                 $thumb->watermarkCreateText($ngg_options['wmColor'], $ngg_options['wmFont'], $ngg_options['wmSize'], $ngg_options['wmOpaque']);
                 $thumb->watermarkImage($ngg_options['wmPos'], $ngg_options['wmXpos'], $ngg_options['wmYpos']);
             }
         }
         if ($mode == 'web20') {
             $thumb->createReflection(40, 40, 50, false, '#a4a4a4');
         }
         // save the new cache picture
         $thumb->save($cached_file, $ngg_options['imgQuality']);
     }
     $thumb->destruct();
     // check again for the file
     if (file_exists($cached_file)) {
         return $cached_url;
     }
     return false;
 }
开发者ID:pravinhirmukhe,项目名称:flow1,代码行数:48,代码来源:image.php

示例7: array

<?php

require_once '../config.php';
require_once nggGallery::graphic_library();
// Pull the image from the NextGen DB
$pictureID = $_REQUEST['pictureID'];
$pic = nggdb::find_image($pictureID);
// If Processing the Crop
if (!empty($_POST['ngg_crop'])) {
    $image = new ngg_Thumbnail($pic->imagePath, TRUE);
    // Create backup
    @copy($image->fileName, $image->fileName . '_backup');
    $image->crop($_POST['ngg_crop']['x1'], $_POST['ngg_crop']['y1'], $_POST['ngg_crop']['cropwidth'], $_POST['ngg_crop']['cropheight']);
    $image->save($image->fileName);
    // Save the new MetaData
    nggdb::update_image_meta($pictureID, array('width' => $_POST['ngg_crop']['cropwidth'], 'height' => $_POST['ngg_crop']['cropheight']));
    exit;
}
echo '<div class="ngg_crop">';
echo '<form class="ngg_crop_form" action="' . $nggcropobj->plugin_path . 'ajax/imagecrop.php" method="post">';
echo '<input type="hidden" id="pictureID" name="pictureID" value="' . $pictureID . '">';
echo '<input type="hidden" id="cropprocess" name="ngg_crop[cropprocess]" value="1">';
echo '<input type="hidden" id="x1" name="ngg_crop[x1]" />';
echo '<input type="hidden" id="y1" name="ngg_crop[y1]" />';
echo '<input type="hidden" id="x2" name="ngg_crop[x2]" />';
echo '<input type="hidden" id="y2" name="ngg_crop[y2]" />';
echo '<table cellspacing="3">';
echo '<tr>';
echo '<td class="ngg_crop_image">';
echo '<img src="' . $pic->imageURL . '?' . rand(0, 10000) . '" id="cropthis" style="display: none">';
echo '</td>';
开发者ID:gopi158,项目名称:Sample,代码行数:31,代码来源:imagecrop.php

示例8: set_watermark

 /**
  * nggAdmin::set_watermark() - set the watermarl for the image
  * 
  * @param object | int $image contain all information about the image or the id
  * @return string result code
  */
 function set_watermark($image)
 {
     global $ngg;
     if (!class_exists('ngg_Thumbnail')) {
         require_once nggGallery::graphic_library();
     }
     if (is_numeric($image)) {
         $image = nggdb::find_image($image);
     }
     if (!is_object($image)) {
         return __('Object didn\'t contain correct data', 'nggallery');
     }
     if (!is_writable($image->imagePath)) {
         return ' <strong>' . $image->filename . __(' is not writeable', 'nggallery') . '</strong>';
     }
     $file = new ngg_Thumbnail($image->imagePath, TRUE);
     // skip if file is not there
     if (!$file->error) {
         if ($ngg->options['wmType'] == 'image') {
             $file->watermarkImgPath = $ngg->options['wmPath'];
             $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
         }
         if ($ngg->options['wmType'] == 'text') {
             $file->watermarkText = $ngg->options['wmText'];
             $file->watermarkCreateText($ngg->options['wmColor'], $ngg->options['wmFont'], $ngg->options['wmSize'], $ngg->options['wmOpaque']);
             $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
         }
         $file->save($image->imagePath, $ngg->options['imgQuality']);
     }
     $file->destruct();
     if (!empty($file->errmsg)) {
         return ' <strong>' . $image->filename . ' (Error : ' . $file->errmsg . ')</strong>';
     }
     return '1';
 }
开发者ID:pravinhirmukhe,项目名称:flow1,代码行数:41,代码来源:functions.php


注:本文中的nggGallery::graphic_library方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。