本文整理汇总了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;
}
}
示例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;
}
示例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;
}