Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
@@ -385,6 +385,10 @@ class Gd extends Image
|
||||
public function flip(): void
|
||||
{
|
||||
imageflip( $this->image, IMG_FLIP_HORIZONTAL );
|
||||
|
||||
/* Set width/height */
|
||||
$this->width = imagesx( $this->image );
|
||||
$this->height = imagesy( $this->image );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+61
-21
@@ -148,35 +148,75 @@ abstract class Image
|
||||
if( static::exifSupported() AND $checkRotation )
|
||||
{
|
||||
$obj->setExifData( $contents );
|
||||
|
||||
|
||||
/* If the image is misoriented, attempt to automatically reorient */
|
||||
if ( $orientation = $obj->getImageOrientation() )
|
||||
$orientation = $obj->getImageOrientation();
|
||||
|
||||
/* Valid orientation values:
|
||||
1 = 0 degrees: the correct orientation, no adjustment is required.
|
||||
2 = 0 degrees, mirrored: image has been flipped back-to-front.
|
||||
3 = 180 degrees: image is upside down.
|
||||
4 = 180 degrees, mirrored: image has been flipped back-to-front and is upside down.
|
||||
5 = 90 degrees: image has been flipped back-to-front and is on its side.
|
||||
6 = 90 degrees, mirrored: image is on its side.
|
||||
7 = 270 degrees: image has been flipped back-to-front and is on its far side.
|
||||
8 = 270 degrees, mirrored: image is on its far side.*/
|
||||
|
||||
/* Differences in orientation between GD and ImageMagick can cause auto-reorient to not work properly
|
||||
GD rotates counter-clockwise; ImageMagick rotates clockwise */
|
||||
|
||||
if ( !( $obj instanceof Image\Imagemagick ) )
|
||||
{
|
||||
$mirrored = in_array( $orientation, [2,4,5,7] );
|
||||
$degrees = match ($orientation) {
|
||||
3,4 => 180,
|
||||
5,6 => 90,
|
||||
7,8 => -90,
|
||||
default => 0
|
||||
};
|
||||
|
||||
if ( $degrees !== 0 OR $mirrored )
|
||||
switch ( $orientation )
|
||||
{
|
||||
$obj->rotate( $degrees );
|
||||
if ( $mirrored )
|
||||
{
|
||||
$obj->flip();
|
||||
}
|
||||
case 3:
|
||||
case 4:
|
||||
$obj->rotate( 180 );
|
||||
$obj->hasBeenRotated = TRUE;
|
||||
break;
|
||||
|
||||
$obj->hasBeenRotated = true;
|
||||
case 5:
|
||||
case 6:
|
||||
$obj->rotate( -90 );
|
||||
$obj->hasBeenRotated = TRUE;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 8:
|
||||
$obj->rotate( 90 );
|
||||
$obj->hasBeenRotated = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* ImageMagick requires orientation be reset when rotated */
|
||||
if ( $degrees !== 0 OR $mirrored OR $obj instanceof Imagemagick )
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( $orientation )
|
||||
{
|
||||
$obj->setImageOrientation( 1 );
|
||||
case 3:
|
||||
case 4:
|
||||
$obj->rotate( 180 );
|
||||
$obj->hasBeenRotated = TRUE;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
$obj->rotate( 90 );
|
||||
$obj->hasBeenRotated = TRUE;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 8:
|
||||
$obj->rotate( -90 );
|
||||
$obj->hasBeenRotated = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Has the image been flipped? */
|
||||
if( in_array( $orientation, array( 2, 4, 5, 7 ) ) )
|
||||
{
|
||||
$obj->flip();
|
||||
}
|
||||
}
|
||||
|
||||
/* Return */
|
||||
|
||||
@@ -260,6 +260,9 @@ class Imagemagick extends Image
|
||||
public function flip(): void
|
||||
{
|
||||
$this->imagick->flopImage();
|
||||
|
||||
/* Set width/height */
|
||||
$this->setDimensions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user