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


PHP SimpleImage::get_height方法代码示例

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


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

示例1: validateSponsorImage

 /**
  * Verify and validate the extension of the uploaded file.
  *
  * @param string $name
  * @param string $type
  * @return boolean
  */
 public function validateSponsorImage($name, $tmpName, $type)
 {
     $allowedExtensions = array("gif", "jpeg", "jpg", "png", "pdf", "GIF", "JPEG", "JPG", "PNG", "PDF");
     $temp = explode(".", $name);
     $extension = end($temp);
     if (($type === "image/gif" || $type === "image/jpeg" || $type === "image/jpg" || $type === "image/pjpeg" || $type === "image/x-png" || $type === "image/png" || $type === "application/pdf") && in_array($extension, $allowedExtensions)) {
         $img = new SimpleImage($tmpName);
         $img->fit_to_width(360);
         $img->invert();
         $img->crop(0, ($img->get_height() - 190) / 2, 360, ($img->get_height() - 190) / 2 + 190);
         $img->invert();
         $img->save("_temp/_img.png");
         return true;
     } else {
         return false;
     }
 }
开发者ID:KINOTO,项目名称:apymeco,代码行数:24,代码来源:SponsorModel.php

示例2: resizeImage

 function resizeImage($source_image, $target_image, $width = 0, $height = 0, $best_fit = false)
 {
     $SimpleImage = new SimpleImage($source_image);
     if ($best_fit) {
         $SimpleImage->best_fit($width, $height)->save($target_image, 100);
     } else {
         if (!$width && !$height) {
             $SimpleImage->save($target_image);
         } elseif ($SimpleImage->get_width() >= $width) {
             $SimpleImage->fit_to_width($width)->crop(0, 0, $width, $SimpleImage->get_height() > $height ? $height : $SimpleImage->get_height())->save($target_image);
         } elseif ($SimpleImage->get_height() >= $height) {
             $SimpleImage->fit_to_width($height)->crop(0, 0, $SimpleImage->get_width() > $width ? $width : $SimpleImage->get_width(), $height)->save($target_image);
         } else {
             $SimpleImage->best_fit($width, $height)->save($target_image);
         }
     }
 }
开发者ID:rizwan-devbatch,项目名称:SampleCode,代码行数:17,代码来源:common_model.php

示例3: resizeImage

 public static function resizeImage($file, $folder, $width = 120, $height = 120, $iparams = array(), $loc_ext_name_com = null)
 {
     global $ext_name, $ext_name_com;
     $loc_ext_name_com = !empty($loc_ext_name_com) ? $loc_ext_name_com : $ext_name_com;
     $params = JComponentHelper::getParams($loc_ext_name_com);
     if (!isset($iparams['displace'])) {
         $iparams['displace'] = $params->get('displace', 0);
     }
     if (!isset($iparams['watermark'])) {
         $iparams['watermark'] = $params->get('watermark', 0);
     }
     if (!isset($iparams['halign'])) {
         $iparams['halign'] = $params->get('halign', 'center');
     }
     if (!isset($iparams['valign'])) {
         $iparams['valign'] = $params->get('valign', 'middle');
     }
     $iparams['watermark_type'] = $params->get('watermark_type', 0);
     $iparams['watermark_valign'] = $params->get('watermark_valign', 'middle');
     $iparams['watermark_halign'] = $params->get('watermark_halign', 'center');
     $iparams['background_type'] = $params->get('background_type', 'file');
     natsort($iparams);
     $dst_file = basename($file);
     foreach ($iparams as $iparam) {
         $dst_file = JString::str_ireplace('/', '.', $iparam) . '-' . $dst_file;
     }
     if (!class_exists('SimpleImage')) {
         require dirname(__FILE__) . DS . '..' . DS . 'additional' . DS . 'simpleimage.php';
     }
     /*
             if($width == 0) {
                 $width = $params->get('thumb_width', 120);
             }*/
     if ($height == 0) {
         $height = $params->get('thumb_height', 120);
     }
     $dst_path_segments = array('media', $loc_ext_name_com, 'images', $folder, 'w' . $width . 'x' . 'h' . $height);
     $dst_path = JPATH_ROOT;
     foreach ($dst_path_segments as $v) {
         $dst_path .= DS . $v;
         if (!JFolder::exists($dst_path)) {
             JFolder::create($dst_path);
             chmod($dst_path, 0777);
         }
     }
     $file != '' ? $dst_filename = $dst_path . DS . $dst_file : ($dst_filename = $dst_path . DS . 'no.jpg');
     if (!JFile::exists($dst_filename)) {
         if ($file != '') {
             $src_filename = JPATH_ROOT . DS . 'media' . DS . $loc_ext_name_com . DS . 'images' . DS . $folder . DS . 'original' . DS . basename($file);
         } else {
             $src_filename = JPATH_ROOT . DS . 'media' . DS . $loc_ext_name_com . DS . 'images' . DS . $folder . DS . 'no.jpg';
         }
         if (!JFile::exists($src_filename)) {
             $src_filename = JPATH_ROOT . DS . 'media' . DS . $loc_ext_name_com . DS . 'images' . DS . $folder . DS . 'no.jpg';
         }
         $image = new SimpleImage($src_filename);
         if ($width == 0) {
             $ratio = $height / $image->get_height();
             $width = $image->get_width() * $ratio;
         }
         if ($image->get_width() > $width || $image->get_height() > $height) {
             $ratio_in = $image->get_width() / $image->get_height();
             if ($iparams['displace'] == 0) {
                 $ratio_out = $width / $height;
                 if ($ratio_in > $ratio_out) {
                     $image->resize((int) $width * $ratio_in, $height);
                 } else {
                     $image->resize($width, $width / $ratio_in);
                 }
                 $x1 = 0;
                 $y1 = 0;
                 switch ($iparams['halign']) {
                     case 'center':
                         $x1 = round($image->get_width() / 2 - $width / 2);
                         break;
                     case 'right':
                         $x1 = round($image->get_width() - $width);
                         break;
                 }
                 switch ($iparams['valign']) {
                     case 'middle':
                         $y1 = round($image->get_height() / 2 - $height / 2);
                         break;
                     case 'bottom':
                         $y1 = round($image->get_height() - $height);
                         break;
                 }
                 $image->crop($x1, $y1, $x1 + $width, $y1 + $height);
             } else {
                 if ($width / $ratio_in > $height) {
                     $image->resize($height * $ratio_in, $height);
                 } else {
                     $image->resize($width, $width / $ratio_in);
                 }
             }
         }
         if ($iparams['watermark'] == 1) {
             $watermark_image = $params->get('watermark_image', '');
             if (file_exists(JPATH_ROOT . DS . $watermark_image) && is_file(JPATH_ROOT . DS . $watermark_image)) {
                 $image->watermark(JPATH_ROOT . DS . $watermark_image, $iparams);
//.........这里部分代码省略.........
开发者ID:JexyRu,项目名称:Ksenmart,代码行数:101,代码来源:media.php


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