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