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


PHP Image::height方法代码示例

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


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

示例1: limitToImageBoundaries

 public function limitToImageBoundaries(Image $image, array $coordinates)
 {
     if ($coordinates[0] > $image->width() - $coordinates[2]) {
         $coordinates[0] = $image->width() - $coordinates[2];
     }
     if ($coordinates[1] > $image->height() - $coordinates[3]) {
         $coordinates[1] = $image->height() - $coordinates[3];
     }
     return $coordinates;
 }
开发者ID:placers,项目名称:imgproxy,代码行数:10,代码来源:Crop.php

示例2: get

 /**
  * Resolve the dimension.
  * @param  string $value The dimension value.
  * @return double The resolved dimension.
  */
 public function get($value)
 {
     if (is_numeric($value) and $value > 0) {
         return (double) $value * $this->dpr;
     }
     if (preg_match('/^(\\d{1,2}(?!\\d)|100)(w|h)$/', $value, $matches)) {
         if ($matches[2] === 'h') {
             return (double) $this->image->height() * ($matches[1] / 100);
         }
         return (double) $this->image->width() * ($matches[1] / 100);
     }
 }
开发者ID:mambax7,项目名称:glide,代码行数:17,代码来源:Dimension.php

示例3: get

 /**
  * Resolve the dimension.
  * @param  string $value The dimension value.
  * @return double The resolved dimension.
  */
 public function get($value)
 {
     if (is_numeric($value) and $value > 0) {
         return (double) $value * $this->dpr;
     }
     if (preg_match('/^(\\d{1,2}(?!\\d)|100)(w|h)$/', $value)) {
         $type = substr($value, -1);
         $value = substr($value, 0, -1);
         if ($type === 'w') {
             return (double) $this->image->width() * ($value / 100);
         }
         if ($type === 'h') {
             return (double) $this->image->height() * ($value / 100);
         }
     }
 }
开发者ID:whismat,项目名称:glide,代码行数:21,代码来源:Dimension.php

示例4: checkHeight

 /**
  * Check height first in resizing
  *
  * @param  \Intervention\Image\Image  $image
  * @param  integer  $height
  *
  * @return integer
  */
 private function checkHeight($image, $height)
 {
     if ($image->height() < $height) {
         return $image->height();
     }
     return $height;
 }
开发者ID:jayaregalinada,项目名称:portfolio-legacy,代码行数:15,代码来源:ImageProcessor.php

示例5: run

 public function run(Image $image)
 {
     $color = (new Color($this->bg))->formatted();
     if ($color) {
         $new = $image->getDriver()->newImage($image->width(), $image->height(), $color);
         $new->mime = $image->mime;
         $image = $new->insert($image, 'top-left', 0, 0);
     }
     return $image;
 }
开发者ID:placers,项目名称:imgproxy,代码行数:10,代码来源:Background.php

示例6: watermark

 /**
  * Watermark
  *
  * @param string  $path
  * @param integer $opacity
  *
  * @return Imagine
  */
 public function watermark($path, $position = 'center', $opacity = null)
 {
     if ($this->isImage($path)) {
         $watermark = $this->manager->make($path);
         $width = $this->image->width();
         $height = $this->image->height();
         if ($watermark->width() > $width || $watermark->height() > $height) {
             $watermark->resize($width, $height, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             });
         }
         if (!is_null($opacity) && $opacity >= 0 && $opacity <= 100) {
             $watermark->opacity($opacity);
         }
         $this->image->insert($watermark, $position);
     }
     return $this;
 }
开发者ID:naturalweb,项目名称:nwlaravel,代码行数:27,代码来源:Imagine.php

示例7: make

 /**
  * Save file to database and to our filesystem.
  */
 public static function make(Picture $picture, Image $image, $identifier)
 {
     $file = new self();
     $file->picture_id = $picture->id;
     $file->identifier = $identifier;
     $file->mime = $image->mime();
     $file->extension = $image->extension;
     $file->width = $image->width();
     $file->height = $image->height();
     self::checkDirPermission();
     $image->save($file->getFilePath());
     $file->save();
 }
开发者ID:faltastic,项目名称:Syria-On-The-Move,代码行数:16,代码来源:File.php

示例8: apply

 public function apply(Image $image)
 {
     $iHeight = $image->height();
     $iWidth = $image->width();
     if ($iHeight == $height && $iWidth == $width) {
         return $image;
     }
     $iRatio = $iWidth / $iHeight;
     $Ratio = $width / $height;
     if ($iRatio > $Ratio) {
         $image->resize($width, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
     } else {
         $image->resize(null, $height, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
     }
     return $image;
 }
开发者ID:igaster,项目名称:laravel-image-versions,代码行数:22,代码来源:Thumbnail.php

示例9: resolveCropOffset

 /**
  * Resolve the crop offset.
  * @param  Image $image The source image.
  * @param  integer $width The width.
  * @param  integer $height The height.
  * @return array   The crop offset.
  */
 public function resolveCropOffset(Image $image, $width, $height)
 {
     list($offset_percentage_x, $offset_percentage_y) = $this->getCrop();
     $offset_x = (int) ($image->width() * $offset_percentage_x / 100 - $width / 2);
     $offset_y = (int) ($image->height() * $offset_percentage_y / 100 - $height / 2);
     $max_offset_x = $image->width() - $width;
     $max_offset_y = $image->height() - $height;
     if ($offset_x < 0) {
         $offset_x = 0;
     }
     if ($offset_y < 0) {
         $offset_y = 0;
     }
     if ($offset_x > $max_offset_x) {
         $offset_x = $max_offset_x;
     }
     if ($offset_y > $max_offset_y) {
         $offset_y = $max_offset_y;
     }
     return [$offset_x, $offset_y];
 }
开发者ID:kleisauke,项目名称:imagesweserv,代码行数:28,代码来源:Size.php

示例10: getInfo

 public function getInfo()
 {
     return ['mime' => $this->image->mime(), 'width' => $this->image->width(), 'height' => $this->image->height(), 'extension' => $this->image->extension, 'filename' => $this->image->filename, 'filesize' => $this->image->filesize()];
 }
开发者ID:bhutanio,项目名称:laravel-utilities,代码行数:4,代码来源:Imager.php

示例11: resolveMissingDimensions

 /**
  * Resolve missing image dimensions.
  * @param  Image       $image  The source image.
  * @param  double|null $width  The image width.
  * @param  double|null $height The image height.
  * @return double[]    The resolved width and height.
  */
 public function resolveMissingDimensions(Image $image, $width, $height)
 {
     if (!$width and !$height) {
         $width = $image->width();
         $height = $image->height();
     }
     if (!$width) {
         $width = $height * ($image->width() / $image->height());
     }
     if (!$height) {
         $height = $width / ($image->width() / $image->height());
     }
     return [(double) $width, (double) $height];
 }
开发者ID:whismat,项目名称:glide,代码行数:21,代码来源:Size.php

示例12: runShrink

 public function runShrink(Image $image, $width, $color)
 {
     return $image->resize($image->width() - $width * 2, $image->height() - $width * 2)->resizeCanvas($width * 2, $width * 2, 'center', true, $color);
 }
开发者ID:placers,项目名称:imgproxy,代码行数:4,代码来源:Border.php

示例13: getHeight

 /**
  * @return int
  */
 public function getHeight()
 {
     return $this->intervention->height();
 }
开发者ID:tippingcanoe,项目名称:imager,代码行数:7,代码来源:ImageData.php

示例14: execute

 /**
  * Fills image with color or pattern
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $filling = $this->argument(0)->value();
     $x = $this->argument(1)->type('digit')->value();
     $y = $this->argument(2)->type('digit')->value();
     $width = $image->width();
     $height = $image->height();
     $filling = $this->decodeFilling($filling);
     // flood fill if coordinates are set
     if (is_int($x) && is_int($y)) {
         // flood fill with texture
         if ($filling instanceof Image) {
             foreach ($image as $frame) {
                 // create tile
                 $tile = clone $frame->getCore()->getImage();
                 $alpha = false;
                 if ($tile->getImageAlphaChannel() !== \Imagick::ALPHACHANNEL_UNDEFINED) {
                     // clone alpha channel
                     $alpha = clone $frame->getCore()->getImage();
                 }
                 // mask away color at position
                 $tile->transparentPaintImage($tile->getImagePixelColor($x, $y), 0, 0, false);
                 // fill canvas with texture
                 $canvas = $frame->getCore()->textureImage($filling->getCore());
                 // merge canvas and tile
                 $canvas->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0);
                 if ($alpha) {
                     // restore alpha channel of original image
                     $canvas->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
                 }
                 // replace image core
                 $frame->getCore()->setImage($canvas);
                 $tile->clear();
                 $canvas->clear();
             }
             // flood fill with color
         } elseif ($filling instanceof Color) {
             // create filling
             $fill = new \Imagick();
             $fill->newImage($width, $height, 'none', 'png');
             $draw = new \ImagickDraw();
             $draw->setFillColor($filling->getPixel());
             $draw->rectangle(0, 0, $width, $height);
             $fill->drawImage($draw);
             foreach ($image as $frame) {
                 // create tile
                 $tile = clone $frame->getCore()->getImage();
                 $alpha = false;
                 if ($tile->getImageAlphaChannel() !== \Imagick::ALPHACHANNEL_UNDEFINED) {
                     // clone alpha channel
                     $alpha = clone $frame->getCore()->getImage();
                 }
                 // mask away color at position
                 $tile->transparentPaintImage($tile->getImagePixelColor($x, $y), 0, 0, false);
                 // fill canvas with texture
                 $canvas = $frame->getCore()->textureImage($fill);
                 // merge canvas and tile
                 $canvas->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0);
                 if ($alpha) {
                     // restore alpha channel of original image
                     $canvas->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
                 }
                 // replace image core
                 $frame->getCore()->setImage($canvas);
                 $tile->clear();
                 $canvas->clear();
             }
         }
     } else {
         if ($filling instanceof Image) {
             // fill each frame with texture
             foreach ($image as $frame) {
                 $filled = $frame->getCore()->textureImage($filling->getCore());
                 $frame->getCore()->setImage($filled);
             }
         } elseif ($filling instanceof Color) {
             // setup draw object
             $draw = new \ImagickDraw();
             $draw->setFillColor($filling->getPixel());
             $draw->rectangle(0, 0, $width, $height);
             // fill each frame with color
             foreach ($image as $frame) {
                 $frame->getCore()->drawImage($draw);
             }
         }
     }
     return true;
 }
开发者ID:EdgarPost,项目名称:image,代码行数:94,代码来源:FillCommand.php

示例15: resizeBoxInImg

 /**
  * Указанная рамка должна помещаться внутрь конечного изображения
  * Т.е. если заказываем 100 на 400 а картинка 2000 на 1000
  * То картинка будет уменьшаться до тех пор пока ее высота меньше указанного
  * или ширина меньше указанного
  *
  * @param \Intervention\Image\Image $img
  * @param                           $w
  * @param                           $h
  *
  * @return \Intervention\Image\Image
  */
 static function resizeBoxInImg(\Intervention\Image\Image $img, $w, $h)
 {
     $ratio_image = $img->width() / $img->height();
     $ratio_box = $w / $h;
     if ($ratio_box < $ratio_image) {
         $_h = $h;
         $_w = null;
     } else {
         $_w = $w;
         $_h = null;
     }
     return $img->resize($_w, $_h, function ($constraint) {
         $constraint->aspectRatio();
     });
 }
开发者ID:larakit,项目名称:lk,代码行数:27,代码来源:HelperImage.php


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