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


PHP Imagine::setMetadataReader方法代码示例

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


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

示例1: fix_orientation

function fix_orientation($source, $name)
{
    $imginfo = getimagesize($source);
    $requiredMemory1 = ceil($imginfo[0] * $imginfo[1] * 5.35);
    $requiredMemory2 = ceil($imginfo[0] * $imginfo[1] * ($imginfo['bits'] / 8) * $imginfo['channels'] * 2.5);
    $requiredMemory = (int) max($requiredMemory1, $requiredMemory2);
    $mem_avail = elgg_get_ini_setting_in_bytes('memory_limit');
    $mem_used = memory_get_usage();
    $mem_avail = $mem_avail - $mem_used - 2097152;
    // 2 MB buffer
    if ($requiredMemory > $mem_avail) {
        // we don't have enough memory for any manipulation
        // @TODO - we should only throw an error if the image needs rotating...
        //register_error(elgg_echo('image_orientation:toolarge'));
        return false;
    }
    elgg_load_library('imagine');
    $name = uniqid() . $name;
    $tmp_location = elgg_get_config('dataroot') . 'image_orientation/' . $name;
    //@note - need to copy to a tmp_location as
    // imagine doesn't like images with no file extension
    copy($source, $tmp_location);
    try {
        $imagine = new Imagine();
        $imagine->setMetadataReader(new ExifMetadataReader());
        $autorotate = new Autorotate();
        $autorotate->apply($imagine->open($tmp_location))->save($tmp_location);
        copy($tmp_location, $source);
        unlink($tmp_location);
        return true;
    } catch (Imagine\Exception\Exception $exc) {
        // fail silently, we don't need to rotate it bad enough to kill the script
        return false;
    }
}
开发者ID:n8b,项目名称:VMN,代码行数:35,代码来源:start.php

示例2: createService

 /**
  * Create Service Factory
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @throws \DomainException
  * @return AbstractImagine
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (class_exists('Gmagick')) {
         $service = new Imagine\Gmagick\Imagine();
     } elseif (class_exists('Imagick')) {
         $service = new Imagine\Imagick\Imagine();
     } elseif (function_exists('gd_info')) {
         $service = new Imagine\Gd\Imagine();
     } else {
         throw new \DomainException('No image library available for Imagine. Gmagick, Imagick, or GD required');
     }
     /*
      * Grab as much info as possible
      */
     $service->setMetadataReader(new ChainedMetadataReader([new ExifMetadataReader(), new GpsMetadataReader(), new IptcMetadataReader()]));
     return $service;
 }
开发者ID:swiftchase,项目名称:swift-imagine,代码行数:25,代码来源:ImagineFactory.php

示例3: createImagine

 /**
  * @return \Imagine\Image\AbstractImagine
  * @throws \yii\base\NotSupportedException
  */
 private function createImagine()
 {
     $driver = null;
     while (!$driver && (list($index, $driverName) = each($this->drivers))) {
         if ($driverName === 'gmagick' && class_exists('Gmagick', false)) {
             $driver = new ImagineGmagick();
         } elseif ($driverName === 'imagick' && class_exists('Imagick', false)) {
             $driver = new ImagineImagick();
         } elseif ($driverName === 'gd' && function_exists('gd_info')) {
             $driver = new ImagineGd();
         }
     }
     if (!$driver) {
         throw new NotSupportedException();
     }
     /* @var $driver AbstractImagine */
     if (function_exists('exif_read_data')) {
         $driver->setMetadataReader(new ExifMetadataReader());
     }
     return $driver;
 }
开发者ID:phtamas,项目名称:yii2-imageprocessor,代码行数:25,代码来源:Component.php


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