本文整理汇总了PHP中Imagine\Image\ImageInterface::flipHorizontally方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageInterface::flipHorizontally方法的具体用法?PHP ImageInterface::flipHorizontally怎么用?PHP ImageInterface::flipHorizontally使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Imagine\Image\ImageInterface
的用法示例。
在下文中一共展示了ImageInterface::flipHorizontally方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: autoOrient
/**
* Re-orient an image using its embedded Exif profile orientation:
* 1. Read the embedded exif data inside the image to determine it's orientation.
* 2. Rotate and flip the image accordingly to re-orient it.
* 3. Strip the Exif data from the image so that there can be no attempt to 'correct' it again.
*
* @param string $path
* @param ImageInterface $image
* @return ImageInterface $image
*/
protected function autoOrient($path, ImageInterface $image)
{
$exif = exif_read_data($path);
if (isset($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 2:
$image->flipHorizontally();
break;
case 3:
$image->rotate(180);
break;
case 4:
$image->flipVertically();
break;
case 5:
$image->flipVertically()->rotate(90);
break;
case 6:
$image->rotate(90);
break;
case 7:
$image->flipHorizontally()->rotate(90);
break;
case 8:
$image->rotate(-90);
break;
}
}
return $image->strip();
}
示例3: applyFlipHorizontallyFilter
/**
* @param \Imagine\Image\ImageInterface $image
* @return \Imagine\Image\ImageInterface
*/
protected function applyFlipHorizontallyFilter(ImageInterface $image)
{
$image->flipHorizontally();
return $image;
}
示例4: apply
/**
* (non-PHPdoc)
* @see Imagine\Filter\FilterInterface::apply()
*/
public function apply(ImageInterface $image)
{
return $image->flipHorizontally();
}
示例5: autoOrient
/**
* Re-orient an image using its embedded Exif profile orientation:
* 1. Attempt to read the embedded exif data inside the image to determine it's orientation.
* if there is no exif data (i.e an exeption is thrown when trying to read it) then we'll
* just return the image as is.
* 2. If there is exif data, we'll rotate and flip the image accordingly to re-orient it.
* 3. Finally, we'll strip the exif data from the image so that there can be no attempt to 'correct' it again.
*
* @param string $path
* @param ImageInterface $image
*
* @return ImageInterface $image
*/
protected function autoOrient($path, ImageInterface $image)
{
if (function_exists('exif_read_data')) {
try {
$exif = exif_read_data($path);
} catch (ErrorException $e) {
return $image;
}
if (isset($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 2:
$image->flipHorizontally();
break;
case 3:
$image->rotate(180);
break;
case 4:
$image->flipVertically();
break;
case 5:
$image->flipVertically()->rotate(90);
break;
case 6:
$image->rotate(90);
break;
case 7:
$image->flipHorizontally()->rotate(90);
break;
case 8:
$image->rotate(-90);
break;
}
}
return $image->strip();
} else {
return $image;
}
}