本文整理匯總了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;
}