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


PHP imagick::getImageHeight方法代码示例

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


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

示例1: makethumb

function makethumb($srcFile, $dstFile, $dstW, $dstH, $imwf = false)
{
    $im = new imagick($srcFile);
    $source_w = $im->getImageWidth();
    $source_h = $im->getImageHeight();
    if ($dstW === 0 && $dstH === 0) {
        $dstW = $source_w;
        $dstH = $source_h;
    } else {
        // 取得縮在此範圍內的比例
        $percent = getResizePercent($source_w, $source_h, $dstW, $dstH);
        $dstW = $source_w * $percent;
        $dstH = $source_h * $percent;
    }
    $im->thumbnailImage($dstW, $dstH);
    $im->writeImage($dstFile);
    $watermarkFile = './logo.png';
    if ($imwf && is_file($watermarkFile) && is_file($dstFile)) {
        $image = new imagick($dstFile);
        $watermark = new imagick($watermarkFile);
        $iWidth = $image->getImageWidth();
        $iHeight = $image->getImageHeight();
        $wWidth = $watermark->getImageWidth();
        $wHeight = $watermark->getImageHeight();
        if ($iHeight < $wHeight || $iWidth < $wWidth) {
            $watermark->scaleImage($iWidth, $iHeight);
            $wWidth = $watermark->getImageWidth();
            $wHeight = $watermark->getImageHeight();
        }
        $x = ($iWidth - $wWidth) / 2;
        $y = ($iHeight - $wHeight) / 2;
        $image->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
        $image->writeImage($dstFile);
    }
}
开发者ID:FantasticThought,项目名称:tfsda,代码行数:35,代码来源:image_conver.php

示例2: generate

 private function generate()
 {
     $taken_seats_result = $this->seatbooking->get_taken_seats_ids();
     $taken_seats = array();
     foreach ($taken_seats_result as $seat) {
         $taken_seats[$seat] = 0;
     }
     $coords = $this->load_xmlconfig_to_array();
     $taken_seats_coords = array_intersect_key($coords, $taken_seats);
     $bg = new imagick($this->filename_bg);
     $marker = new imagick($this->filename_marker);
     $marker_width = $marker->getImageWidth();
     $marker_height = $marker->getImageHeight();
     foreach ($taken_seats_coords as $seat) {
         $x = $seat[0] - floor($marker_width / 2);
         $y = $seat[1] - floor($marker_width / 2);
         $bg->compositeImage($marker, imagick::COMPOSITE_OVER, $x, $y);
     }
     return $bg;
 }
开发者ID:bjornua,项目名称:dikulan-old,代码行数:20,代码来源:StatusImage.php

示例3: imagick

 }
 // не нравится мне расширение jpeg, пусть будет jpg
 if ($p[1] == 'jpeg') {
     $p[1] = 'jpg';
 }
 // полное имя файла изображения
 $image = './images/' . $image_name . '.' . $p[1];
 move_uploaded_file($tmp_image_name, $image);
 // Создаем новый объект imagick
 $im = new imagick($image);
 if ($p[1] != 'gif') {
     // Открываем watermark
     $watermark = new imagick('./img/watermark.png');
     // узнаем размеры оригинального изображения
     $im_width = $im->getImageWidth();
     $im_height = $im->getImageHeight();
     // узнаем размеры водяного знака
     $watermark_width = $watermark->getImageWidth();
     $watermark_height = $watermark->getImageHeight();
     // посчитать x и y
     $left = $im_width - $watermark_width - 10;
     $top = $im_height - $watermark_height - 10;
     // накладываем watermark на оригинальное изображение
     $im->compositeImage($watermark, imagick::COMPOSITE_OVER, $left, $top);
     // сохраняем оригинал
     $im->writeImage('./images/' . $image_name . '.' . $p[1]);
 } else {
     // сохраняем .gif с учетом анимации
     $im->writeImages('./images/' . $image_name . '.' . $p[1], true);
 }
 // Копируем объект для различных типов
开发者ID:iSkript,项目名称:Imgur-clone,代码行数:31,代码来源:upload.php

示例4: catch

            } catch (ImagickException $e) {
                // something went wrong, handle the problem
            }
            @unlink($tmpfile);
        }
    }
    // Print the output
    foreach ($image_list as $img) {
        if ($img['thumb'] != '') {
            $url = $img['url'];
            $title = $img['title'];
            $thumb = $img['thumb'];
            $subreddit = $img['subreddit'];
            $permalink = "http://reddit.com/" . $img['permalink'];
            $img = new imagick($thumb);
            $height = $img->getImageHeight();
            $img->clear();
            $img->destroy();
            $thumb = '/' . $thumb;
            $subreddit_text = '';
            if ($bSubreddit) {
                $subreddit_text = '<a class="cat" href="http://redditporn.com/r/' . $subreddit . '" style="color: #3BB9FF">' . $subreddit . '</a><br/>';
            }
            echo '<li id="mosaic1170" class="item_image" style="height: ' . ($height + 4) . 'px;">
				<div class="img">
					<a href="' . $url . '" target="_blank"><img src="' . $thumb . '" alt="' . $title . '" width="300" height="' . $height . '"/></a>
				</div>
				<div class="info">
					' . $subreddit_text . '
					<a href="' . $permalink . '" target="_blank">' . $title . '</a>
				</div>
开发者ID:ReillyKlevre,项目名称:redditporn,代码行数:31,代码来源:index.php

示例5: imagick

 function _resizeImagick(&$model, $field, $path, $size, $geometry, $thumbnailPath)
 {
     $srcFile = $path . $model->data[$model->alias][$field];
     $pathInfo = $this->_pathinfo($srcFile);
     $thumbnailType = $this->settings[$model->alias][$field]['thumbnailType'];
     $isMedia = $this->_isMedia($model, $this->runtime[$model->alias][$field]['type']);
     $image = new imagick();
     if ($isMedia) {
         $image->setResolution(300, 300);
         $srcFile = $srcFile . '[0]';
     }
     $image->readImage($srcFile);
     $height = $image->getImageHeight();
     $width = $image->getImageWidth();
     if (preg_match('/^\\[[\\d]+x[\\d]+\\]$/', $geometry)) {
         // resize with banding
         list($destW, $destH) = explode('x', substr($geometry, 1, strlen($geometry) - 2));
         $image->thumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+x[\\d]+$/', $geometry)) {
         // cropped resize (best fit)
         list($destW, $destH) = explode('x', $geometry);
         $image->cropThumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+w$/', $geometry)) {
         // calculate heigh according to aspect ratio
         $image->thumbnailImage((int) $geometry - 1, 0);
     } elseif (preg_match('/^[\\d]+h$/', $geometry)) {
         // calculate width according to aspect ratio
         $image->thumbnailImage(0, (int) $geometry - 1);
     } elseif (preg_match('/^[\\d]+l$/', $geometry)) {
         // calculate shortest side according to aspect ratio
         $destW = 0;
         $destH = 0;
         $destW = $width > $height ? (int) $geometry - 1 : 0;
         $destH = $width > $height ? 0 : (int) $geometry - 1;
         $imagickVersion = phpversion('imagick');
         $image->thumbnailImage($destW, $destH, !($imagickVersion[0] == 3));
     }
     if ($isMedia) {
         $thumbnailType = $this->settings[$model->alias][$field]['mediaThumbnailType'];
     }
     if (!$thumbnailType || !is_string($thumbnailType)) {
         try {
             $thumbnailType = $image->getImageFormat();
         } catch (Exception $e) {
             $thumbnailType = 'png';
         }
     }
     $fileName = str_replace(array('{size}', '{filename}'), array($size, $pathInfo['filename']), $this->settings[$model->alias][$field]['thumbnailName']);
     $destFile = "{$thumbnailPath}{$fileName}.{$thumbnailType}";
     $image->setImageCompressionQuality($this->settings[$model->alias][$field]['thumbnailQuality']);
     $image->setImageFormat($thumbnailType);
     if (!$image->writeImage($destFile)) {
         return false;
     }
     $image->clear();
     $image->destroy();
     return true;
 }
开发者ID:ryantology,项目名称:upload,代码行数:58,代码来源:upload.php

示例6: _resizeImagick

 public function _resizeImagick(Model $model, $field, $path, $size, $geometry, $thumbnailPath)
 {
     $srcFile = $path . $model->data[$model->alias][$field];
     $pathInfo = $this->_pathinfo($srcFile);
     $thumbnailType = $imageFormat = $this->settings[$model->alias][$field]['thumbnailType'];
     $isMedia = $this->_isMedia($model, $this->runtime[$model->alias][$field]['type']);
     $image = new imagick();
     if ($isMedia) {
         $image->setResolution(300, 300);
         $srcFile = $srcFile . '[0]';
     }
     $image->readImage($srcFile);
     $height = $image->getImageHeight();
     $width = $image->getImageWidth();
     if (preg_match('/^\\[[\\d]+x[\\d]+\\]$/', $geometry)) {
         // resize with banding
         list($destW, $destH) = explode('x', substr($geometry, 1, strlen($geometry) - 2));
         $image->thumbnailImage($destW, $destH, true);
         $imageGeometry = $image->getImageGeometry();
         $x = ($imageGeometry['width'] - $destW) / 2;
         $y = ($imageGeometry['height'] - $destH) / 2;
         $image->setGravity(Imagick::GRAVITY_CENTER);
         $image->extentImage($destW, $destH, $x, $y);
     } elseif (preg_match('/^[\\d]+x[\\d]+$/', $geometry)) {
         // cropped resize (best fit)
         list($destW, $destH) = explode('x', $geometry);
         $image->cropThumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+w$/', $geometry)) {
         // calculate heigh according to aspect ratio
         $image->thumbnailImage((int) $geometry - 1, 0);
     } elseif (preg_match('/^[\\d]+h$/', $geometry)) {
         // calculate width according to aspect ratio
         $image->thumbnailImage(0, (int) $geometry - 1);
     } elseif (preg_match('/^[\\d]+l$/', $geometry)) {
         // calculate shortest side according to aspect ratio
         $destW = 0;
         $destH = 0;
         $destW = $width > $height ? (int) $geometry - 1 : 0;
         $destH = $width > $height ? 0 : (int) $geometry - 1;
         $imagickVersion = phpversion('imagick');
         $image->thumbnailImage($destW, $destH, !($imagickVersion[0] == 3));
     }
     if ($isMedia) {
         $thumbnailType = $imageFormat = $this->settings[$model->alias][$field]['mediaThumbnailType'];
     }
     if (!$thumbnailType || !is_string($thumbnailType)) {
         try {
             $thumbnailType = $imageFormat = $image->getImageFormat();
             // Fix file casing
             while (true) {
                 $ext = false;
                 $pieces = explode('.', $srcFile);
                 if (count($pieces) > 1) {
                     $ext = end($pieces);
                 }
                 if (!$ext || !strlen($ext)) {
                     break;
                 }
                 $low = array('ext' => strtolower($ext), 'thumbnailType' => strtolower($thumbnailType));
                 if ($low['ext'] == 'jpg' && $low['thumbnailType'] == 'jpeg') {
                     $thumbnailType = $ext;
                     break;
                 }
                 if ($low['ext'] == $low['thumbnailType']) {
                     $thumbnailType = $ext;
                 }
                 break;
             }
         } catch (Exception $e) {
             $this->log($e->getMessage(), 'upload');
             $thumbnailType = $imageFormat = 'png';
         }
     }
     $fileName = str_replace(array('{size}', '{filename}', '{primaryKey}'), array($size, $pathInfo['filename'], $model->id), $this->settings[$model->alias][$field]['thumbnailName']);
     $destFile = "{$thumbnailPath}{$fileName}.{$thumbnailType}";
     $image->setImageCompressionQuality($this->settings[$model->alias][$field]['thumbnailQuality']);
     $image->setImageFormat($imageFormat);
     if (!$image->writeImage($destFile)) {
         return false;
     }
     $image->clear();
     $image->destroy();
     return true;
 }
开发者ID:ederdsr,项目名称:civisindicadores,代码行数:84,代码来源:UploadBehavior.php


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