本文整理匯總了PHP中Imagine\Image\ImageInterface::metadata方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImageInterface::metadata方法的具體用法?PHP ImageInterface::metadata怎麽用?PHP ImageInterface::metadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagine\Image\ImageInterface
的用法示例。
在下文中一共展示了ImageInterface::metadata方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: transform
public function transform(ImageInterface $image, ImagineInterface $imagine)
{
// Imagine comes with a built-in Autorotate filter, but it seems to be simpler to reimplement it
// without bothering with the color.
$metadata = $image->metadata();
if (!isset($metadata['ifd0.Orientation'])) {
return;
}
$orientation = $metadata['ifd0.Orientation'];
if ($orientation == 3) {
$image->rotate(180);
} elseif ($orientation == 6) {
$image->rotate(90);
} elseif ($orientation == 8) {
$image->rotate(-90);
}
}
示例2: apply
/**
* {@inheritdoc}
*/
public function apply(ImageInterface $image)
{
$metadata = $image->metadata();
switch (isset($metadata['ifd0.Orientation']) ? $metadata['ifd0.Orientation'] : null) {
case 3:
$image->rotate(180, $this->getColor($image));
break;
case 6:
$image->rotate(90, $this->getColor($image));
break;
case 8:
$image->rotate(-90, $this->getColor($image));
break;
default:
break;
}
return $image;
}
示例3: apply
/**
* {@inheritdoc}
*/
public function apply(ImageInterface $image)
{
$metadata = $image->metadata();
switch (isset($metadata['ifd0.Orientation']) ? $metadata['ifd0.Orientation'] : null) {
case 1:
// top-left
break;
case 2:
// top-right
$image->flipHorizontally();
break;
case 3:
// bottom-right
$image->rotate(180, $this->getColor($image));
break;
case 4:
// bottom-left
$image->flipHorizontally();
$image->rotate(180, $this->getColor($image));
break;
case 5:
// left-top
$image->flipHorizontally();
$image->rotate(-90, $this->getColor($image));
break;
case 6:
// right-top
$image->rotate(90, $this->getColor($image));
break;
case 7:
// right-bottom
$image->flipHorizontally();
$image->rotate(90, $this->getColor($image));
break;
case 8:
// left-bottom
$image->rotate(-90, $this->getColor($image));
break;
default:
// Invalid orientation
break;
}
return $image;
}
示例4: isLandscapeOrient
/**
* @param ImageInterface $file
* @return bool
*/
public function isLandscapeOrient(ImageInterface $file)
{
$retval = true;
/** @var MetadataBag $metadata */
$metadata = $file->metadata();
$orientation = $metadata->offsetGet('ifd0.Orientation');
switch ($orientation) {
case 6:
case 8:
$retval = false;
break;
default:
break;
}
return $retval;
}