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


PHP WideImage_Image::getHeight方法代码示例

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


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

示例1: execute

 /**
  * Returns a cropped image
  *
  * @param WideImage_Image $img
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param smart_coordinate $width
  * @param smart_coordinate $height
  * @return WideImage_Image
  */
 function execute($img, $left, $top, $width, $height)
 {
     $width = WideImage_Coordinate::fix($width, $img->getWidth(), $width);
     $height = WideImage_Coordinate::fix($height, $img->getHeight(), $height);
     $left = WideImage_Coordinate::fix($left, $img->getWidth(), $width);
     $top = WideImage_Coordinate::fix($top, $img->getHeight(), $height);
     if ($left < 0) {
         $width = $left + $width;
         $left = 0;
     }
     if ($width > $img->getWidth() - $left) {
         $width = $img->getWidth() - $left;
     }
     if ($top < 0) {
         $height = $top + $height;
         $top = 0;
     }
     if ($height > $img->getHeight() - $top) {
         $height = $img->getHeight() - $top;
     }
     if ($width <= 0 || $height <= 0) {
         throw new WideImage_Exception("Can't crop outside of an image.");
     }
     $new = $img->doCreate($width, $height);
     if ($img->isTransparent() || $img instanceof WideImage_PaletteImage) {
         $new->copyTransparencyFrom($img);
         imagecopyresized($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height);
     } else {
         $new->alphaBlending(false);
         $new->saveAlpha(true);
         imagecopyresampled($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height);
     }
     return $new;
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:44,代码来源:Crop.php

示例2: execute

 /**
  * Returns an image with a resized canvas
  * 
  * The image is filled with $color. Use $scale to determine, when to resize.
  *
  * @param WideImage_Image $img
  * @param smart_coordinate $width
  * @param smart_coordinate $height
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param int $color
  * @param string $scale 'up', 'down', 'any'
  * @return WideImage_Image
  */
 function execute($img, $width, $height, $left, $top, $color, $scale)
 {
     $new_width = WideImage_Coordinate::fix($width, $img->getWidth());
     $new_height = WideImage_Coordinate::fix($width, $img->getHeight());
     if ($scale == 'down') {
         $new_width = min($new_width, $img->getWidth());
         $new_height = min($new_height, $img->getHeight());
     } elseif ($scale == 'up') {
         $new_width = max($new_width, $img->getWidth());
         $new_height = max($new_height, $img->getHeight());
     }
     $new = WideImage::createTrueColorImage($new_width, $new_height);
     if ($img->isTrueColor()) {
         if ($color === null) {
             $color = $new->allocateColorAlpha(0, 0, 0, 127);
         }
     } else {
         imagepalettecopy($new->getHandle(), $img->getHandle());
         if ($color === null) {
             if ($img->isTransparent()) {
                 $new->copyTransparencyFrom($img);
                 $tc_rgb = $img->getTransparentColorRGB();
                 $color = $new->allocateColorAlpha($tc_rgb);
             } else {
                 $color = $new->allocateColorAlpha(255, 0, 127, 127);
             }
             imagecolortransparent($new->getHandle(), $color);
         }
     }
     $new->fill(0, 0, $color);
     $x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth());
     $y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight());
     $img->copyTo($new, $x, $y);
     return $new;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:49,代码来源:ResizeCanvas.php

示例3: execute

 /**
  * Applies a mask on the copy of source image
  *
  * @param WideImage_Image $image
  * @param WideImage_Image $mask
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @return WideImage_Image
  */
 function execute($image, $mask, $left = 0, $top = 0)
 {
     $left = WideImage_Coordinate::fix($image->getWidth(), $left);
     $top = WideImage_Coordinate::fix($image->getHeight(), $top);
     $width = $image->getWidth();
     if ($width > $mask->getWidth()) {
         $width = $mask->getWidth();
     }
     $height = $image->getHeight();
     if ($height > $mask->getHeight()) {
         $height = $mask->getHeight();
     }
     $result = $image->asTrueColor();
     $result->alphaBlending(false);
     $result->saveAlpha(true);
     $srcTransparentColor = $image->getTransparentColor();
     if ($srcTransparentColor >= 0) {
         $trgb = $image->getColorRGB($srcTransparentColor);
         $trgb['alpha'] = 127;
         $destTransparentColor = $result->allocateColorAlpha($trgb);
         $result->setTransparentColor($destTransparentColor);
     } else {
         $destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
     }
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             if ($left + $x < $image->getWidth() && $top + $y < $image->getHeight()) {
                 $srcColor = $image->getColorAt($left + $x, $top + $y);
                 if ($srcColor == $srcTransparentColor) {
                     $destColor = $destTransparentColor;
                 } else {
                     $maskRGB = $mask->getRGBAt($x, $y);
                     if ($maskRGB['red'] == 0) {
                         $destColor = $destTransparentColor;
                     } elseif ($srcColor >= 0) {
                         $imageRGB = $image->getRGBAt($left + $x, $top + $y);
                         $level = $maskRGB['red'] / 255 * (1 - $imageRGB['alpha'] / 127);
                         $imageRGB['alpha'] = 127 - round($level * 127);
                         if ($imageRGB['alpha'] == 127) {
                             $destColor = $destTransparentColor;
                         } else {
                             $destColor = $result->allocateColorAlpha($imageRGB);
                         }
                     } else {
                         $destColor = $destTransparentColor;
                     }
                 }
                 $result->setColorAt($left + $x, $top + $y, $destColor);
             }
         }
     }
     return $result;
 }
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:62,代码来源:ApplyMask.php

示例4: execute

 /**
  * Applies a mask on the copy of source image
  *
  * @param WideImage_Image $image
  * @param WideImage_Image $mask
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @return WideImage_Image
  */
 function execute($image, $mask, $left = 0, $top = 0)
 {
     $left = WideImage_Coordinate::fix($left, $image->getWidth(), $mask->getWidth());
     $top = WideImage_Coordinate::fix($top, $image->getHeight(), $mask->getHeight());
     $width = $image->getWidth();
     $mask_width = $mask->getWidth();
     $height = $image->getHeight();
     $mask_height = $mask->getHeight();
     $result = $image->asTrueColor();
     $result->alphaBlending(false);
     $result->saveAlpha(true);
     $srcTransparentColor = $result->getTransparentColor();
     if ($srcTransparentColor >= 0) {
         # this was here. works without.
         #$trgb = $image->getColorRGB($srcTransparentColor);
         #$trgb['alpha'] = 127;
         #$destTransparentColor = $result->allocateColorAlpha($trgb);
         #$result->setTransparentColor($destTransparentColor);
         $destTransparentColor = $srcTransparentColor;
     } else {
         $destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
     }
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $mx = $x - $left;
             $my = $y - $top;
             if ($mx >= 0 && $mx < $mask_width && $my >= 0 && $my < $mask_height) {
                 $srcColor = $image->getColorAt($x, $y);
                 if ($srcColor == $srcTransparentColor) {
                     $destColor = $destTransparentColor;
                 } else {
                     $maskRGB = $mask->getRGBAt($mx, $my);
                     if ($maskRGB['red'] == 0) {
                         $destColor = $destTransparentColor;
                     } elseif ($srcColor >= 0) {
                         $imageRGB = $image->getRGBAt($x, $y);
                         $level = $maskRGB['red'] / 255 * (1 - $imageRGB['alpha'] / 127);
                         $imageRGB['alpha'] = 127 - round($level * 127);
                         if ($imageRGB['alpha'] == 127) {
                             $destColor = $destTransparentColor;
                         } else {
                             $destColor = $result->allocateColorAlpha($imageRGB);
                         }
                     } else {
                         $destColor = $destTransparentColor;
                     }
                 }
                 $result->setColorAt($x, $y, $destColor);
             }
         }
     }
     return $result;
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:62,代码来源:ApplyMask.php

示例5: prepareDimensions

 /**
  * Prepares and corrects smart coordinates
  *
  * @param WideImage_Image $img
  * @param smart_coordinate $width
  * @param smart_coordinate $height
  * @param string $fit
  * @return array
  */
 protected function prepareDimensions($img, $width, $height, $fit)
 {
     if ($width === null && $height === null) {
         return array('width' => $img->getWidth(), 'height' => $img->getHeight());
     }
     if ($width !== null) {
         $width = WideImage_Coordinate::fix($width, $img->getWidth());
         $rx = $img->getWidth() / $width;
     } else {
         $rx = null;
     }
     if ($height !== null) {
         $height = WideImage_Coordinate::fix($height, $img->getHeight());
         $ry = $img->getHeight() / $height;
     } else {
         $ry = null;
     }
     if ($rx === null && $ry !== null) {
         $rx = $ry;
         $width = round($img->getWidth() / $rx);
     }
     if ($ry === null && $rx !== null) {
         $ry = $rx;
         $height = round($img->getHeight() / $ry);
     }
     if ($width === 0 || $height === 0) {
         return array('width' => 0, 'height' => 0);
     }
     if ($fit == null) {
         $fit = 'inside';
     }
     $dim = array();
     if ($fit == 'fill') {
         $dim['width'] = $width;
         $dim['height'] = $height;
     } elseif ($fit == 'inside' || $fit == 'outside') {
         if ($fit == 'inside') {
             $ratio = $rx > $ry ? $rx : $ry;
         } else {
             $ratio = $rx < $ry ? $rx : $ry;
         }
         $dim['width'] = round($img->getWidth() / $ratio);
         $dim['height'] = round($img->getHeight() / $ratio);
     } else {
         throw new WideImage_Operation_InvalidFitMethodException("{$fit} is not a valid resize-fit method.");
     }
     return $dim;
 }
开发者ID:ehazell,项目名称:AWPF,代码行数:57,代码来源:Resize.php

示例6: execute

 /**
  * Returns a mask
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $width = $image->getWidth();
     $height = $image->getHeight();
     $mask = WideImage_TrueColorImage::create($width, $height);
     $mask->setTransparentColor(-1);
     $mask->alphaBlending(false);
     $mask->saveAlpha(false);
     for ($i = 0; $i <= 255; $i++) {
         $greyscale[$i] = ImageColorAllocate($mask->getHandle(), $i, $i, $i);
     }
     imagefilledrectangle($mask->getHandle(), 0, 0, $width, $height, $greyscale[255]);
     $transparentColor = $image->getTransparentColor();
     $alphaToGreyRatio = 255 / 127;
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $color = $image->getColorAt($x, $y);
             if ($color == $transparentColor) {
                 $rgba['alpha'] = 127;
             } else {
                 $rgba = $image->getColorRGB($color);
             }
             imagesetpixel($mask->getHandle(), $x, $y, $greyscale[255 - round($rgba['alpha'] * $alphaToGreyRatio)]);
         }
     }
     return $mask;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:33,代码来源:GetMask.php

示例7: execute

 /**
  * Returns a merged image
  *
  * @param WideImage_Image $base
  * @param WideImage_Image $overlay
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param numeric $pct
  * @return WideImage_Image
  */
 function execute($base, $overlay, $left, $top, $pct)
 {
     $x = WideImage_Coordinate::fix($base->getWidth(), $left);
     $y = WideImage_Coordinate::fix($base->getHeight(), $top);
     $result = $base->asTrueColor();
     $result->alphaBlending(true);
     $result->saveAlpha(true);
     if ($pct == 0) {
         return $result;
     }
     if ($pct < 100) {
         imagecopymerge($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight(), $pct);
     } else {
         imagecopy($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight());
     }
     return $result;
 }
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:27,代码来源:Merge.php

示例8: execute

 /**
  * Returns an image with a resized canvas
  * 
  * The image is filled with $color. Use $scale to determine, when to resize.
  *
  * @param WideImage_Image $img
  * @param smart_coordinate $width
  * @param smart_coordinate $height
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param int $color
  * @param string $scale 'up', 'down', 'any'
  * @param boolean $merge
  * @return WideImage_Image
  */
 function execute($img, $width, $height, $left, $top, $color, $scale, $merge)
 {
     $new_width = WideImage_Coordinate::fix($width, $img->getWidth());
     $new_height = WideImage_Coordinate::fix($height, $img->getHeight());
     if ($scale == 'down') {
         $new_width = min($new_width, $img->getWidth());
         $new_height = min($new_height, $img->getHeight());
     } elseif ($scale == 'up') {
         $new_width = max($new_width, $img->getWidth());
         $new_height = max($new_height, $img->getHeight());
     }
     $new = WideImage::createTrueColorImage($new_width, $new_height);
     if ($img->isTrueColor()) {
         if ($color === null) {
             $color = $new->allocateColorAlpha(0, 0, 0, 127);
         }
     } else {
         imagepalettecopy($new->getHandle(), $img->getHandle());
         if ($img->isTransparent()) {
             $new->copyTransparencyFrom($img);
             $tc_rgb = $img->getTransparentColorRGB();
             $t_color = $new->allocateColorAlpha($tc_rgb);
         }
         if ($color === null) {
             if ($img->isTransparent()) {
                 $color = $t_color;
             } else {
                 $color = $new->allocateColorAlpha(255, 0, 127, 127);
             }
             imagecolortransparent($new->getHandle(), $color);
         }
     }
     $new->fill(0, 0, $color);
     $x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth());
     $y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight());
     // blending for truecolor images
     if ($img->isTrueColor()) {
         $new->alphaBlending($merge);
     }
     // not-blending for palette images
     if (!$merge && !$img->isTrueColor() && isset($t_color)) {
         $new->getCanvas()->filledRectangle($x, $y, $x + $img->getWidth(), $y + $img->getHeight(), $t_color);
     }
     $img->copyTo($new, $x, $y);
     return $new;
 }
开发者ID:mjrouser,项目名称:cityapi,代码行数:61,代码来源:WideImage_Operation_ResizeCanvas.php

示例9: execute

 /**
  * Returns a mirrored image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $new = $image->copy();
     $width = $image->getWidth();
     $height = $image->getHeight();
     for ($x = 0; $x < $width; $x++) {
         imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height);
     }
     return $new;
 }
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:16,代码来源:Mirror.php

示例10: execute

 /**
  * Returns a flipped image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $new = $image->copy();
     $width = $image->getWidth();
     $height = $image->getHeight();
     for ($y = 0; $y < $height; $y++) {
         imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1);
     }
     return $new;
 }
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:16,代码来源:Flip.php

示例11:

 /**
  * Apply the manipulation with the setup options to the passed in image.
  * This does not do any memory manipulation
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 public function &apply(WideImage_Image &$image)
 {
     if (!$this->isSetup()) {
         throw new RokGallery_Manipulation_Exception(rc__('ROKGALLERY_MANIPULATION_WAS_NOT_SETUP_PRIOR_TO_APPLYING'));
     }
     if ($this->left == 0 && $this->top == 0 && $this->width == 0 && $this->height == 0) {
         $this->width = $image->getWidth();
         $this->height = $image->getHeight();
     }
     $return_image = $image->crop($this->left, $this->top, $this->width, $this->height);
     return $return_image;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:19,代码来源:Crop.php

示例12: execute

 /**
  * Returns a merged image.
  *
  * @param WideImage_Image  $base
  * @param WideImage_Image  $overlay
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param numeric          $pct
  *
  * @return WideImage_Image
  */
 public function execute($base, $overlay, $left, $top, $pct)
 {
     $x = WideImage_Coordinate::fix($left, $base->getWidth(), $overlay->getWidth());
     $y = WideImage_Coordinate::fix($top, $base->getHeight(), $overlay->getHeight());
     $result = $base->asTrueColor();
     $result->alphaBlending(true);
     $result->saveAlpha(true);
     if ($pct <= 0) {
         return $result;
     }
     if ($pct < 100) {
         if (!imagecopymerge($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight(), $pct)) {
             throw new WideImage_GDFunctionResultException('imagecopymerge() returned false');
         }
     } else {
         if (!imagecopy($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight())) {
             throw new WideImage_GDFunctionResultException('imagecopy() returned false');
         }
     }
     return $result;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:32,代码来源:Merge.php

示例13: execute

 /**
  * Returns a mirrored image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $new = $image->copy();
     $width = $image->getWidth();
     $height = $image->getHeight();
     if ($new->isTransparent()) {
         imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
     }
     for ($x = 0; $x < $width; $x++) {
         imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height);
     }
     return $new;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:19,代码来源:Mirror.php

示例14: execute

 /**
  * Returns a flipped image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $new = $image->copy();
     $width = $image->getWidth();
     $height = $image->getHeight();
     if ($new->isTransparent()) {
         imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
     }
     for ($y = 0; $y < $height; $y++) {
         imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1);
     }
     return $new;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:19,代码来源:Flip.php

示例15: execute

 /**
  * Returns a mirrored image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $new = $image->copy();
     $width = $image->getWidth();
     $height = $image->getHeight();
     if ($new->isTransparent()) {
         imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
     }
     for ($x = 0; $x < $width; $x++) {
         if (!imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height)) {
             throw new WideImage_GDFunctionResultException("imagecopy() returned false");
         }
     }
     return $new;
 }
开发者ID:ehazell,项目名称:AZDWR,代码行数:21,代码来源:Mirror.php


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