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


PHP sfImage::getHeight方法代码示例

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


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

示例1: save

 public function save($conn = null)
 {
     $return = parent::save($conn);
     if ($this->getObject()->getPath() != '') {
         $uploadDir = sfConfig::get('sf_upload_dir') . '/photo/';
         $image = explode('.', $this->getObject()->getPath());
         $img = new sfImage($uploadDir . $image[0] . '.' . $image[1], swImageTransform::mime_content_type($uploadDir . $image[0] . '.' . $image[1]));
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(780, 518);
         } else {
             $img->resize(344, 518);
         }
         $img->setQuality(95);
         $img->overlay(new sfImage(sfConfig::get('sf_web_dir') . '/images/marcadagua.png', 'image/png'), 'bottom-right');
         $img->saveAs($uploadDir . $this->getObject()->getSlug() . '.' . $image[1]);
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(130, 86);
         } else {
             $img->resize(130, 196);
             $img->crop(0, 55, 130, 86);
         }
         $img->saveAs($uploadDir . 'thumb_' . $this->getObject()->getSlug() . '.' . $image[1]);
         unlink($uploadDir . $image[0] . '.' . $image[1]);
         $this->getObject()->setPath($this->getObject()->getSlug() . '.' . $image[1]);
         $this->getObject()->save();
     }
     return $return;
 }
开发者ID:kidh0,项目名称:tiagotrespach,代码行数:28,代码来源:PhotoForm.class.php

示例2: transform

 /**
  * Apply the opacity transformation to the sfImage object
  * 
  * @param sfImage
  * 
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $new_img = $image->getAdapter()->getTransparentImage($image->getWidth(), $image->getHeight());
     imagealphablending($new_img, false);
     imagesavealpha($new_img, true);
     $opacity = (int) round(127 - 127 / 100 * $this->getOpacity());
     // imagesavealpha($new_img, true);
     $width = $image->getWidth();
     $height = $image->getHeight();
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $rgb = imagecolorat($image->getAdapter()->getHolder(), $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $alpha = ($rgb & 0x7f000000) >> 24;
             $new_opacity = $alpha + (127 - $alpha) / 100 * $this->getOpacity();
             $colors[$alpha] = $new_opacity;
             $color = imagecolorallocatealpha($new_img, $r, $g, $b, $new_opacity);
             imagesetpixel($new_img, $x, $y, $color);
         }
     }
     $image->getAdapter()->setHolder($new_img);
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:32,代码来源:sfImageOpacityGD.class.php

示例3: image_cache_tag

function image_cache_tag($route, $format, $path, $image, $alt = null)
{
    $_formats = sfConfig::get('imagecache_formats');
    $_format = $_formats[$format];
    if (!isset($_format)) {
        throw new RuntimeException('Format not found');
    }
    $real_file_path = sfConfig::get('sf_upload_dir') . '/' . $path . '/' . $image;
    if (file_exists($real_file_path)) {
        $cache_file_path = sfConfig::get('sf_upload_dir') . '/cache/' . $format . '/' . $path . '/' . $image;
        $is_cached_file = file_exists($cache_file_path);
        $options = array('path' => $format . '/' . $path . '/' . $image);
        $url = urldecode(url_for($route, $options));
        if ($is_cached_file) {
            $cached_image = new sfImage($cache_file_path);
            $width = $cached_image->getWidth();
            $height = $cached_image->getHeight();
            return image_tag($url, array('size' => $width . 'x' . $height, 'alt' => $alt));
        } else {
            return image_tag($url, array('alt' => $alt));
        }
    } else {
        return '';
    }
}
开发者ID:GrifiS,项目名称:SyrexCMS,代码行数:25,代码来源:ImageCacheHelper.php

示例4: transform

 public function transform(sfImage $img)
 {
     $this->directory = dirname($img->getFilename());
     $arr = array_reverse(explode("/", $img->getFilename()));
     $this->fileName = $arr[0];
     $arr2 = explode(".", $this->fileName);
     if (count($arr2) == 1) {
         $this->fileName .= '.png';
     }
     $destDir = '/tmp';
     $ccFile = $destDir . DIRECTORY_SEPARATOR . 'cc_' . $this->fileName;
     $bwFile = $destDir . DIRECTORY_SEPARATOR . 'bw_' . $this->fileName;
     $ccSmallFile = $destDir . DIRECTORY_SEPARATOR . 'cc_s_' . $this->fileName;
     $bwSmallFile = $destDir . DIRECTORY_SEPARATOR . 'bw_s_' . $this->fileName;
     if (!file_exists($destDir)) {
         mkdir($destDir);
     }
     if ($img->getWidth() > IMG_MAX_WIDTH || $img->getHeight() > IMG_MAX_HEIGHT) {
         if ($img->getWidth() > $img->getHeight() * IMG_RATIO) {
             $img->resize(IMG_MAX_WIDTH, null);
         } else {
             $img->resize(null, IMG_MAX_HEIGHT);
         }
     }
     $img->saveAs($ccFile);
     $img->greyscale()->saveAs($bwFile);
     $smallImg = new sfImage($ccFile);
     if ($smallImg->getWidth() > IMG_SMALL_WIDTH || $smallImg->getHeight() > IMG_SMALL_WIDTH) {
         if ($smallImg->getWidth() > $img->getHeight() * IMG_RATIO) {
             $smallImg->resize(null, IMG_MAX_HEIGHT);
         } else {
             $smallImg->resize(IMG_MAX_WIDTH, null);
         }
     }
     if ($smallImg->getWidth() > IMG_SMALL_WIDTH || $smallImg->getHeight() > IMG_SMALL_HEIGHT) {
         if ($smallImg->getWidth() > $smallImg->getHeight() * IMG_RATIO) {
             $smallImg->resize(null, IMG_SMALL_HEIGHT);
         } else {
             $smallImg->resize(IMG_SMALL_WIDTH, null);
         }
     }
     $x1 = ($smallImg->getWidth() - IMG_SMALL_WIDTH) / 2;
     $y1 = ($smallImg->getHeight() - IMG_SMALL_HEIGHT) / 3;
     $smallImg->crop($x1, $y1, IMG_SMALL_WIDTH, IMG_SMALL_HEIGHT)->saveAs($ccSmallFile);
     $smallImg->greyscale()->saveAs($bwSmallFile);
 }
开发者ID:voota,项目名称:voota,代码行数:46,代码来源:sfImageVoota.php

示例5: save

 public function save($conn = null)
 {
     $return = parent::save($conn);
     if ($this->getObject()->getPicture() != '') {
         $uploadDir = sfConfig::get('sf_upload_dir') . '/news/';
         $image = $this->getObject()->getPicture();
         $img = new sfImage($uploadDir . $image, swImageTransform::mime_content_type($uploadDir . $image));
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(480, null);
         } else {
             $img->resize(null, 360);
         }
         $img->setQuality(95);
         $img->save();
         $img->resize(180, 128)->saveAs($uploadDir . 'thumb_' . $image);
     }
     return $return;
 }
开发者ID:kidh0,项目名称:swbrasil,代码行数:18,代码来源:NewsForm.class.php

示例6: save

 public function save($conn = null)
 {
     $return = parent::save($conn);
     if (!$this->isNew() and count($this->embeddedForms) != 0) {
         $uploadDir = sfConfig::get('sf_upload_dir') . '/gallery/';
         $image = $this->embeddedForms['photo']->getObject()->getPath();
         $img = new sfImage($uploadDir . $image, swImageTransform::mime_content_type($uploadDir . $image));
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(600, null);
         } else {
             $img->resize(null, 480);
         }
         $img->setQuality(95);
         $img->overlay(new sfImage(sfConfig::get('sf_web_dir') . '/images/marcadagua.png', 'image/png'), 'bottom-right');
         $img->save();
         $img->resize(null, 80)->saveAs($uploadDir . 'thumb_' . $image);
     }
     return $return;
 }
开发者ID:kidh0,项目名称:swbrasil,代码行数:19,代码来源:GalleryForm.class.php

示例7: getSize

/**
 * Cette funciton permet de récupérer les dimensions de l'image d'origine.
 * @param <string> $image_name : le nom de l’image donc généralement le $object->getImage(), pas de répertoire
 * @param <string> $folder : le nom du répertoire dans "uploads" où est stocké l’image 
 * @return <image_path>
 */
function getSize($image_name, $folder)
{
    $source_dir = 'uploads/' . $folder . '/';
    $source = $source_dir . $image_name;
    $exist = sfConfig::get('sf_web_dir') . '/' . $source;
    $img = new sfImage($source);
    $size['width'] = $img->getWidth();
    $size['height'] = $img->getHeight();
    return $size;
}
开发者ID:ndachez,项目名称:acb,代码行数:16,代码来源:ThumbHelper.php

示例8: showThumb

/**
 * Cette funciton utilise la pr?c?dente afin d'afficher directement l'image avec les balises et les options.
 * @param <string> $image_name : le nom de l'image donc g?n?ralement le $object->getImage(), pas de r?pertoire
 * @param <string> $folder : le nom du r?pertoire dans uploads o? est stock? l'image : uploads/object/source => $folder = object
 * @param <array> $options : les parametres ? passer ? l'image: width, height, alt, title, class, id...
 * @param <string> $resize : l'op?ration sur le thumb: "scale" pour garder les proportions, "center" pour tronquer l'image
 * @param <string> $default : l'image par d?faut si image_name n'existe pas
 * @return <image_path>
 */
function showThumb($image_name, $folder, $options = array(), $resize = 'scale', $default = 'default.jpg')
{
    if (empty($options['alt'])) {
        $options['alt'] = 'image ' . $image_name;
    }
    $image_path = doThumb($image_name, $folder, $options, $resize, $default);
    $img = new sfImage(sfConfig::get('sf_web_dir') . $image_path);
    //r�cupere les vraies dimensions de l'image du thumb et on �crase dans les options.
    $options['width'] = $img->getWidth();
    $options['height'] = $img->getHeight();
    return image_tag($image_path, $options);
}
开发者ID:ndachez,项目名称:dachez,代码行数:21,代码来源:ThumbHelper.php

示例9: transform

 /**
  * Apply the transformation to the image and returns the image thumbnail
  */
 protected function transform(sfImage $image)
 {
     $resource_w = $image->getWidth();
     $resource_h = $image->getHeight();
     $scale_w = $this->getWidth() / $resource_w;
     $scale_h = $this->getHeight() / $resource_h;
     switch ($this->getMethod()) {
         case 'deflate':
         case 'inflate':
             return $image->resize($this->getWidth(), $this->getHeight());
         case 'left':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop(0, (int) round(($image->getHeight() - $this->getHeight()) / 2), $this->getWidth(), $this->getHeight());
         case 'right':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop($image->getWidth() - $this->getWidth(), (int) round(($image->getHeight() - $this->getHeight()) / 2), $this->getWidth(), $this->getHeight());
         case 'top':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop((int) round(($image->getWidth() - $this->getWidth()) / 2), 0, $this->getWidth(), $this->getHeight());
         case 'bottom':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop((int) round(($image->getWidth() - $this->getWidth()) / 2), $image->getHeight() - $this->getHeight(), $this->getWidth(), $this->getHeight());
         case 'center':
             $image->scale(max($scale_w, $scale_h));
             $left = (int) round(($image->getWidth() - $this->getWidth()) / 2);
             $top = (int) round(($image->getHeight() - $this->getHeight()) / 2);
             return $image->crop($left, $top, $this->getWidth(), $this->getHeight());
         case 'scale':
             return $image->scale(min($scale_w, $scale_h));
         case 'fit':
         default:
             $img = clone $image;
             $image->create($this->getWidth(), $this->getHeight());
             // Set a background color if specified
             if (!is_null($this->getBackground()) && $this->getBackground() != '') {
                 $image->fill(0, 0, $this->getBackground());
             }
             $img->scale(min($this->getWidth() / $img->getWidth(), $this->getHeight() / $img->getHeight()));
             $image->overlay($img, 'center');
             return $image;
     }
 }
开发者ID:nageshwar545,项目名称:PluginsKit,代码行数:45,代码来源:sfImageThumbnailGeneric.php

示例10: transform

 /**
  * Apply the transformation to the image and returns the resized image
  */
 protected function transform(sfImage $image)
 {
     list($target_w, $target_h) = $this->computeTargetSize($image->getWidth(), $image->getHeight());
     return $image->resizeSimple($target_w, $target_h);
 }
开发者ID:runopencode,项目名称:diem-extended,代码行数:8,代码来源:sfResizeGeneric.php

示例11: updateRemoteImage

 protected function updateRemoteImage($image, Swift_Message $message, $templateName)
 {
     $fileName = dmOs::join(sfConfig::get('sf_web_dir'), 'cache/mail_templates', md5($image->src . $image->width . $image->height) . pathinfo($image->src, PATHINFO_EXTENSION));
     if (!file_exists($fileName)) {
         $imageData = file_get_contents($image->src);
         if (!$imageData) {
             $this->logError($templateName, 'remote', 'image', $image->src);
             $image->src = '';
             return $image;
         } else {
             $sfImage = new sfImage();
             $sfImage->loadString($imageData);
             $width = $sfImage->getWidth();
             $height = $sfImage->getHeight();
             if (isset($image->width) && strpos($image->width, '%') === false) {
                 $width = $image->width;
             }
             if (isset($image->height) && strpos($image->height, '%') === false) {
                 $width = $image->height;
             }
             $sfImage->setQuality(dmConfig::get('image_resize_quality'));
             $sfImage->thumbnail($width, $height, dmConfig::get('image_resize_method'), null);
             $fileSystem = $this->serviceContainer->getService('filesystem');
             if (!file_exists(dirname($fileName))) {
                 $fileSystem->mkdir(dirname($fileName));
             }
             $sfImage->saveAs($fileName);
             chmod($fileName, 0777);
         }
     }
     if (dmConfig::get('mail_template_embed_remote_images_as_attachments', true)) {
         $image->src = $message->embed(Swift_Image::fromPath($fileName));
     } else {
         $image->src = $this->basePath . str_replace(sfConfig::get('sf_web_dir'), '', $fileName);
     }
     return $image;
 }
开发者ID:runopencode,项目名称:diem-extended,代码行数:37,代码来源:dmMailTemplateRenderer.php

示例12: transform

 /**
  * Apply the transformation to the image and returns the resized image
  */
 protected function transform(sfImage $image)
 {
     $source_w = $image->getWidth();
     $source_h = $image->getHeight();
     $target_w = $this->width;
     $target_h = $this->height;
     if (is_numeric($this->width) && $this->width > 0 && $source_w > 0) {
         if (!$this->inflate && $target_w > $source_w) {
             $target_w = $source_w;
         }
         if ($this->proportional) {
             // Compute the new height in order to keep the aspect ratio
             // and clamp it to the maximum height
             $target_h = round($source_h / $source_w * $target_w);
             if (is_numeric($this->height) && $this->height < $target_h && $source_h > 0) {
                 $target_h = $this->height;
                 $target_w = round($source_w / $source_h * $target_h);
             }
         }
     }
     if (is_numeric($this->height) && $this->height > 0 && $source_h > 0) {
         if (!$this->inflate && $target_h > $source_h) {
             $target_h = $source_h;
         }
         if ($this->proportional) {
             // Compute the new width in order to keep the aspect ratio
             // and clamp it to the maximum width
             $target_w = round($source_w / $source_h * $target_h);
             if (is_numeric($this->width) && $this->width < $target_w && $source_w > 0) {
                 $target_w = $this->width;
                 $target_h = round($source_h / $source_w * $target_w);
             }
         }
     }
     return $image->resizeSimple($target_w, $target_h);
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:39,代码来源:sfResizeGeneric.php

示例13: transform

 /**
  * Apply the transformation to the image and returns the image thumbnail
  */
 protected function transform(sfImage $image)
 {
     // Work out where we need to draw to
     $offset = $this->getThickness() / 2;
     $mod = $this->getThickness() % 2;
     $x2 = $image->getWidth() - $offset - ($mod === 0 ? 1 : 0);
     $y2 = $image->getHeight() - $offset - ($mod === 0 ? 1 : 0);
     $image->rectangle($offset, $offset, $x2, $y2, $this->getThickness(), $this->getColor());
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:13,代码来源:sfImageBorderGeneric.php

示例14: showThumb_watermark

function showThumb_watermark($image_name, $folder, $options = array(), $resize = 'scale', $default = 'default.jpg', $watermark = 'images/watermark.png', $position = 'middle-center')
{
    if (empty($options['alt'])) {
        $options['alt'] = 'image ' . $image_name;
    }
    $image_path = doThumb_watermark($image_name, $folder, $options, $resize, $default, $watermark, $position);
    $img = new sfImage(sfConfig::get('sf_web_dir') . $image_path);
    //récupere les vraies dimensions de l'image du thumb et on écrase dans les options.
    $options['width'] = $img->getWidth();
    $options['height'] = $img->getHeight();
    return image_tag($image_path, $options);
}
开发者ID:ndachez,项目名称:emach,代码行数:12,代码来源:ThumbHelper.php

示例15: transformDefault

 protected function transformDefault(sfImage $image)
 {
     $w = $image->getWidth();
     $h = $image->getHeight();
     $resource = $image->getAdapter()->getHolder();
     $mask = $this->getMask()->getAdapter()->getHolder();
     imagealphablending($resource, true);
     $resource_transparent = imagecolorallocate($resource, 0, 0, 0);
     imagecolortransparent($resource, $resource_transparent);
     // Copy $mask over the top of $resource maintaining the Alpha transparency
     imagecopymerge($resource, $mask, 0, 0, 0, 0, $w, $h, 100);
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:12,代码来源:sfImageAlphaMaskGD.class.php


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