當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。