summaryrefslogtreecommitdiff
path: root/includes/media/Jpeg.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
commit08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch)
tree577a29fb579188d16003a209ce2a2e9c5b0aa2bd /includes/media/Jpeg.php
parentcacc939b34e315b85e2d72997811eb6677996cc1 (diff)
Update to MediaWiki 1.21.1
Diffstat (limited to 'includes/media/Jpeg.php')
-rw-r--r--includes/media/Jpeg.php35
1 files changed, 33 insertions, 2 deletions
diff --git a/includes/media/Jpeg.php b/includes/media/Jpeg.php
index a15b6524..8b5d6513 100644
--- a/includes/media/Jpeg.php
+++ b/includes/media/Jpeg.php
@@ -37,7 +37,7 @@ class JpegHandler extends ExifBitmapHandler {
$meta = BitmapMetadataHandler::Jpeg( $filename );
if ( !is_array( $meta ) ) {
// This should never happen, but doesn't hurt to be paranoid.
- throw new MWException('Metadata array is not an array');
+ throw new MWException( 'Metadata array is not an array' );
}
$meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
return serialize( $meta );
@@ -59,5 +59,36 @@ class JpegHandler extends ExifBitmapHandler {
}
}
-}
+ /**
+ * @param $file File
+ * @param array $params Rotate parameters.
+ * 'rotation' clockwise rotation in degrees, allowed are multiples of 90
+ * @since 1.21
+ * @return bool
+ */
+ public function rotate( $file, $params ) {
+ global $wgJpegTran;
+
+ $rotation = ( $params[ 'rotation' ] + $this->getRotation( $file ) ) % 360;
+ if( $wgJpegTran && is_file( $wgJpegTran ) ){
+ $cmd = wfEscapeShellArg( $wgJpegTran ) .
+ " -rotate " . wfEscapeShellArg( $rotation ) .
+ " -outfile " . wfEscapeShellArg( $params[ 'dstPath' ] ) .
+ " " . wfEscapeShellArg( $params[ 'srcPath' ] ) . " 2>&1";
+ wfDebug( __METHOD__ . ": running jpgtran: $cmd\n" );
+ wfProfileIn( 'jpegtran' );
+ $retval = 0;
+ $err = wfShellExec( $cmd, $retval, $env );
+ wfProfileOut( 'jpegtran' );
+ if ( $retval !== 0 ) {
+ $this->logErrorForExternalProcess( $retval, $err, $cmd );
+ return new MediaTransformError( 'thumbnail_error', 0, 0, $err );
+ }
+ return false;
+ } else {
+ return parent::rotate( $file, $params );
+ }
+ }
+
+}