Code: Select all
}
Code: Select all
/*** BEGIN 2017-02-21
https://www.phpbb.com/community/viewtopic.php?f=556&t=2410601 ***/
function ImageOrient() {
if( preg_match( '#^j(p([eg]|eg)|fif)$#i', $this-> extension ) ) { // Only JPEG supported so far
$oDest= imagecreatefromjpeg( $this-> destination_file );
if( function_exists( 'exif_read_data' ) ) {
$aExif= exif_read_data( $this-> destination_file );
} else {
// http://php.net/manual/de/function.exif-read-data.php#117355
if( !preg_match( '#\x12\x01\x03\x00\x01\x00\x00\x00(.)\x00\x00\x00#', file_get_contents( $this-> destination_file ), $aMatch ) ) return;
$aExif= array( 'Orientation'=> ord( $aMatch[1] ) );
}
switch( $aExif['Orientation'] ) {
case 2: // Horizontal flip
case 4: // Vertical flip
case 5: // Vertical flip & 90° rotate clockwise
case 7: // Horizontal flip & 90° rotate counter clockwise
$bFlip= true;
break;
default:
$bFlip= false;
break;
}
switch( $aExif['Orientation'] ) {
case 3: // 180° rotate
case 4: // Vertical flip
$iRotate= 180;
break;
case 5: // Vertical flip & 90° rotate clockwise
case 8: // 90° rotate clockwise
$iRotate= 90;
break;
case 6: // 90° rotate counter clockwise
case 7: // Horizontal flip & 90° rotate counter clockwise
$iRotate= -90;
break;
default:
$iRotate= 0;
break;
}
if( $bFlip ) {
if( !function_exists( 'imageflip' )
|| !imageflip( $oImage, IMG_FLIP_HORIZONTAL )
) {
$this-> ImageFlip( $oDest );
}
}
if( $iRotate ) $oDest= imagerotate( $oDest, $iRotate, 0 );
imagejpeg( $oDest, $this-> destination_file, 100 );
}
}
// Fallback for PHP below 5.5
function ImageFlip( &$oImage, $iLeft= 0, $iTop= 0, $iWidth= 0, $iHeight= 0 ) {
if( $iWidth< 1 ) $iWidth= imagesx( $oImage );
if( $iHeight< 1 ) $iHeight= imagesy( $oImage );
if( function_exists( 'imageistruecolor' )
&& imageistruecolor( $oImage )
) {
$oNew= imagecreatetruecolor( 1, $iHeight );
} else {
$oNew = imagecreate( 1, $iHeight );
}
$iStripe= $iLeft+ $iWidth- 1;
for( $iX= (int)floor( ($iWidth- 1)/ 2 ); $iX>= 0; $iX-- ) {
// Backup right stripe.
imagecopy( $oNew, $oImage, 0, 0, $iStripe- $iX, $iTop, 1, $iHeight );
// Copy left stripe to the right.
imagecopy( $oImage, $oImage, $iStripe- $iX, $iTop, $iLeft+ $iX, $iTop, 1, $iHeight );
// Copy backuped right stripe to the left.
imagecopy( $oImage, $oNew, $iLeft+ $iX, $iTop, 0, 0, 1, $iHeight );
}
imagedestroy( $oNew );
}
/*** END 2017-02-21 ***/
Code: Select all
$this->filesystem->phpbb_chmod($this->destination_file, $chmod);
Code: Select all
/*** BEGIN 2017-02-21
https://www.phpbb.com/community/viewtopic.php?f=556&t=2410601 ***/
$this-> ImageOrient();
/*** END 2017-02-21 ***/
-1
and replace with 0
- worked for me.Code: Select all
/**
* Event to modify uploaded file before submit to the post
*
* @event core.modify_uploaded_file
* @var array filedata Array containing uploaded file data
* @var bool is_image Flag indicating if the file is an image
* @since 3.1.0-RC3
*/
$vars = array(
'filedata',
'is_image',
);