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


PHP vB_Image::fetch_thumbnail方法代码示例

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


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

示例1: switch

 /**
  * Attempt to resize file if the filesize is too large after an initial resize to max dimensions or the file is already within max dimensions but the filesize is too large
  *
  * @param	bool	Has the image already been resized once?
  * @param	bool	Attempt a resize
  */
 function fetch_best_resize(&$jpegconvert, $resize = true)
 {
     if (!$jpegconvert and $this->upload['filesize'] > $this->maxuploadsize and $resize and $this->image->is_valid_resize_type($this->imginfo[2])) {
         // Linear Regression
         switch ($this->registry->options['thumbquality']) {
             case 65:
                 // No Sharpen
                 // $magicnumber = round(379.421 + .00348171 * $this->maxuploadsize);
                 // Sharpen
                 $magicnumber = round(277.652 + 0.00428902 * $this->maxuploadsize);
                 break;
             case 85:
                 // No Sharpen
                 // $magicnumber = round(292.53 + .0027378 * $this-maxuploadsize);
                 // Sharpen
                 $magicnumber = round(189.939 + 0.00352439 * $this->maxuploadsize);
                 break;
             case 95:
                 // No Sharpen
                 // $magicnumber = round(188.11 + .0022561 * $this->maxuploadsize);
                 // Sharpen
                 $magicnumber = round(159.146 + 0.00234146 * $this->maxuploadsize);
                 break;
             default:
                 //75
                 // No Sharpen
                 // $magicnumber = round(328.415 + .00323415 * $this->maxuploadsize);
                 // Sharpen
                 $magicnumber = round(228.201 + 0.00396951 * $this->maxuploadsize);
         }
         $xratio = $this->imginfo[0] > $magicnumber ? $magicnumber / $this->imginfo[0] : 1;
         $yratio = $this->imginfo[1] > $magicnumber ? $magicnumber / $this->imginfo[1] : 1;
         if ($xratio > $yratio and $xratio != 1) {
             $new_width = round($this->imginfo[0] * $xratio);
             $new_height = round($this->imginfo[1] * $xratio);
         } else {
             $new_width = round($this->imginfo[0] * $yratio);
             $new_height = round($this->imginfo[1] * $yratio);
         }
         if ($new_width == $this->imginfo[0] and $new_height == $this->imginfo[1]) {
             // subtract one pixel so that requested size isn't the same as the image size
             $new_width--;
             $forceresize = false;
         } else {
             $forceresize = true;
         }
         $this->upload['resized'] = $this->image->fetch_thumbnail($this->upload['filename'], $this->upload['location'], $new_width, $new_height, $this->registry->options['thumbquality'], false, false, true, false);
         if (empty($this->upload['resized']['filedata'])) {
             if ($this->image->is_valid_thumbnail_extension(file_extension($this->upload['filename'])) and !empty($this->upload['resized']['imageerror']) and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
                 if (($error = $this->image->fetch_error()) !== false and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
                     $this->set_error('image_resize_failed_x', htmlspecialchars_uni($error));
                     return false;
                 } else {
                     $this->set_error($this->upload['resized']['imageerror']);
                     return false;
                 }
             } else {
                 $this->set_error('upload_file_exceeds_forum_limit', vb_number_format($this->upload['filesize'], 1, true), vb_number_format($this->maxuploadsize, 1, true));
                 #$this->set_error('upload_exceeds_dimensions', $this->maxwidth, $this->maxheight, $this->imginfo[0], $this->imginfo[1]);
                 return false;
             }
         } else {
             $jpegconvert = true;
         }
     }
     if (!$jpegconvert and $this->upload['filesize'] > $this->maxuploadsize) {
         $this->set_error('upload_file_exceeds_forum_limit', vb_number_format($this->upload['filesize'], 1, true), vb_number_format($this->maxuploadsize, 1, true));
         return false;
     } else {
         if ($jpegconvert and $this->upload['resized']['filesize'] and ($this->upload['resized']['filesize'] > $this->maxuploadsize or $forceresize)) {
             $ratio = $this->maxuploadsize / $this->upload['resized']['filesize'];
             $newwidth = $this->upload['resized']['width'] * sqrt($ratio);
             $newheight = $this->upload['resized']['height'] * sqrt($ratio);
             if ($newwidth > $this->imginfo[0]) {
                 $newwidth = $this->imginfo[0] - 1;
             }
             if ($newheight > $this->imginfo[1]) {
                 $newheight = $this->imginfo[1] - 1;
             }
             $this->upload['resized'] = $this->image->fetch_thumbnail($this->upload['filename'], $this->upload['location'], $newwidth, $newheight, $this->registry->options['thumbquality'], false, false, true, false);
             if (empty($this->upload['resized']['filedata'])) {
                 if (!empty($this->upload['resized']['imageerror']) and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
                     if (($error = $this->image->fetch_error()) !== false and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
                         $this->set_error('image_resize_failed_x', htmlspecialchars_uni($error));
                         return false;
                     } else {
                         $this->set_error($this->upload['resized']['imageerror']);
                         return false;
                     }
                 } else {
                     $this->set_error('upload_file_exceeds_forum_limit', vb_number_format($this->upload['filesize'], 1, true), vb_number_format($this->maxuploadsize, 1, true));
                     #$this->set_error('upload_exceeds_dimensions', $this->maxwidth, $this->maxheight, $this->imginfo[0], $this->imginfo[1]);
                     return false;
                 }
//.........这里部分代码省略.........
开发者ID:holandacz,项目名称:nb4,代码行数:101,代码来源:class_upload.php


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