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


PHP sfImage::getMIMEType方法代码示例

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


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

示例1: createMask

 protected function createMask(sfImage $image, $w, $h)
 {
     // Create a mask png image of the area you want in the circle/ellipse (a 'magicpink' image with a black shape on it, with black set to the colour of alpha transparency) - $mask
     $mask = $image->getAdapter()->getTransparentImage($w, $h);
     // Set the masking colours
     if (false === $this->getColor() || 'image/png' == $image->getMIMEType()) {
         $mask_black = imagecolorallocate($mask, 0, 0, 0);
     } else {
         $mask_black = $image->getAdapter()->getColorByHex($mask, $this->getColor());
     }
     // Cannot use white as transparent mask if color is set to white
     if ($this->getColor() === '#FFFFFF' || $this->getColor() === false) {
         $mask_transparent = imagecolorallocate($mask, 255, 0, 0);
     } else {
         $mask_color = imagecolorsforindex($mask, imagecolorat($image->getAdapter()->getHolder(), 0, 0));
         $mask_transparent = imagecolorallocate($mask, $mask_color['red'], $mask_color['green'], $mask_color['blue']);
     }
     imagecolortransparent($mask, $mask_transparent);
     imagefill($mask, 0, 0, $mask_black);
     // Draw the rounded rectangle for the mask
     $this->imagefillroundedrect($mask, 0, 0, $w, $h, $this->getRadius(), $mask_transparent);
     $mask_image = clone $image;
     $mask_image->getAdapter()->setHolder($mask);
     return $mask_image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:25,代码来源:sfImageRoundedCornersGD.class.php

示例2: transform

 protected function transform(sfImage $image)
 {
     switch ($image->getMIMEType()) {
         case 'image/png':
             $this->transformAlpha($image);
             break;
         case 'image/gif':
         case 'image/jpg':
         default:
             $this->transformDefault($image);
     }
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:13,代码来源:sfImageAlphaMaskGD.class.php

示例3: importFavicon

 /**
  * saves the favicon of a communitiy
  *
  * @author Matthias Pfefferle
  *
  * @param Object $pCommunity
  * @return boolean true|false
  */
 public static function importFavicon($pCommunity, $pPath = self::PATH_TYPE_URL)
 {
     try {
         // try to get an image from websnapr
         $lImage = UrlUtils::getUrlContent($pCommunity->getFavicon());
         $lBasePath = DIRECTORY_SEPARATOR . 'favicons' . DIRECTORY_SEPARATOR . $pCommunity->getSlug() . '.png';
         // create folder structure and save the image to our local filesystem
         $path = sfConfig::get('sf_upload_dir') . $lBasePath;
         $fp = fopen($path, 'w+');
         fputs($fp, $lImage);
         fclose($fp);
         // get mime-type
         $lImgData = GetImageSize($path);
         if ($lImgData['mime'] != "image/png") {
             $lImg = new sfImage($path, $lImgData['mime'], 'GD');
             $lImg->getMIMEType();
             $lImg->setQuality(100);
             $lImg->saveAs($path, 'image/png');
         }
         unset($lImage);
         if ($pPath == self::PATH_TYPE_URL) {
             return DIRECTORY_SEPARATOR . sfConfig::get('sf_upload_dir_name') . $lBasePath;
         } else {
             return $path;
         }
     } catch (Exception $e) {
         sfContext::getInstance()->getLogger()->err("{ImageImporter} Exception: " . print_r($e, true));
         return null;
     }
 }
开发者ID:42medien,项目名称:spreadly,代码行数:38,代码来源:ImageImporter.class.php

示例4: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = imagesx($resource);
     $y = imagesy($resource);
     // If the width or height is not valid then enforce the aspect ratio
     if (!is_numeric($this->width) || $this->width < 1) {
         $this->width = round($x / $y * $this->height);
     } else {
         if (!is_numeric($this->height) || $this->height < 1) {
             $this->height = round($y / $x * $this->width);
         }
     }
     $dest_resource = $image->getAdapter()->getTransparentImage($this->width, $this->height);
     // Preserving transparency for alpha PNGs
     if ($image->getMIMEType() == 'image/png') {
         imagealphablending($dest_resource, false);
         imagesavealpha($dest_resource, true);
     }
     // Finally do our resizing
     imagecopyresampled($dest_resource, $resource, 0, 0, 0, 0, $this->width, $this->height, $x, $y);
     imagedestroy($resource);
     $image->getAdapter()->setHolder($dest_resource);
     return $image;
 }
开发者ID:vcgato29,项目名称:poff,代码行数:31,代码来源:sfImageResizeSimpleGD.class.php


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