2007-04-20 12:31:36 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2012-05-03 20:13:10 +00:00
|
|
|
* Generic handler for bitmap images.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-15 17:27:41 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Media
|
|
|
|
|
*/
|
2007-04-20 12:31:36 +00:00
|
|
|
|
2007-04-24 06:53:31 +00:00
|
|
|
/**
|
2010-08-15 17:27:41 +00:00
|
|
|
* Generic handler for bitmap images
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Media
|
2007-04-24 06:53:31 +00:00
|
|
|
*/
|
2014-07-09 20:03:31 +00:00
|
|
|
class BitmapHandler extends TransformationalImageHandler {
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-01-07 22:12:05 +00:00
|
|
|
/**
|
2011-04-28 20:18:32 +00:00
|
|
|
* Returns which scaler type should be used. Creates parent directories
|
2011-01-07 22:12:05 +00:00
|
|
|
* for $dstPath and returns 'client' on error
|
2011-04-28 20:18:32 +00:00
|
|
|
*
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param string $dstPath
|
|
|
|
|
* @param bool $checkDstPath
|
2014-07-09 20:03:31 +00:00
|
|
|
* @return string|Callable One of client, im, custom, gd, imext or an array( object, method )
|
2011-01-07 22:12:05 +00:00
|
|
|
*/
|
2014-07-09 20:03:31 +00:00
|
|
|
protected function getScalerType( $dstPath, $checkDstPath = true ) {
|
2011-01-07 22:12:05 +00:00
|
|
|
global $wgUseImageResize, $wgUseImageMagick, $wgCustomConvertCommand;
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-01-07 22:12:05 +00:00
|
|
|
if ( !$dstPath && $checkDstPath ) {
|
|
|
|
|
# No output path available, client side scaling only
|
|
|
|
|
$scaler = 'client';
|
|
|
|
|
} elseif ( !$wgUseImageResize ) {
|
|
|
|
|
$scaler = 'client';
|
2011-03-12 22:51:45 +00:00
|
|
|
} elseif ( $wgUseImageMagick ) {
|
2011-01-07 22:12:05 +00:00
|
|
|
$scaler = 'im';
|
|
|
|
|
} elseif ( $wgCustomConvertCommand ) {
|
|
|
|
|
$scaler = 'custom';
|
|
|
|
|
} elseif ( function_exists( 'imagecreatetruecolor' ) ) {
|
|
|
|
|
$scaler = 'gd';
|
2011-03-12 22:51:45 +00:00
|
|
|
} elseif ( class_exists( 'Imagick' ) ) {
|
2011-03-12 19:32:39 +00:00
|
|
|
$scaler = 'imext';
|
2011-01-07 22:12:05 +00:00
|
|
|
} else {
|
|
|
|
|
$scaler = 'client';
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2011-01-07 22:12:05 +00:00
|
|
|
return $scaler;
|
|
|
|
|
}
|
2010-10-30 19:11:30 +00:00
|
|
|
|
2016-02-23 23:47:02 +00:00
|
|
|
public function makeParamString( $params ) {
|
2016-01-14 02:13:11 +00:00
|
|
|
$res = parent::makeParamString( $params );
|
|
|
|
|
if ( isset( $params['interlace'] ) && $params['interlace'] ) {
|
|
|
|
|
return "interlaced-{$res}";
|
|
|
|
|
} else {
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 23:47:02 +00:00
|
|
|
public function parseParamString( $str ) {
|
2016-01-14 02:13:11 +00:00
|
|
|
$remainder = preg_replace( '/^interlaced-/', '', $str );
|
|
|
|
|
$params = parent::parseParamString( $remainder );
|
|
|
|
|
if ( $params === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$params['interlace'] = $str !== $remainder;
|
|
|
|
|
return $params;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 23:47:02 +00:00
|
|
|
public function validateParam( $name, $value ) {
|
2016-02-04 16:01:44 +00:00
|
|
|
if ( $name === 'interlace' ) {
|
|
|
|
|
return $value === false || $value === true;
|
|
|
|
|
} else {
|
|
|
|
|
return parent::validateParam( $name, $value );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-14 02:13:11 +00:00
|
|
|
/**
|
|
|
|
|
* @param File $image
|
2017-08-11 00:23:16 +00:00
|
|
|
* @param array &$params
|
2016-01-14 02:13:11 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2019-02-25 09:16:30 +00:00
|
|
|
public function normaliseParams( $image, &$params ) {
|
2016-01-14 02:13:11 +00:00
|
|
|
global $wgMaxInterlacingAreas;
|
|
|
|
|
if ( !parent::normaliseParams( $image, $params ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$mimeType = $image->getMimeType();
|
|
|
|
|
$interlace = isset( $params['interlace'] ) && $params['interlace']
|
|
|
|
|
&& isset( $wgMaxInterlacingAreas[$mimeType] )
|
|
|
|
|
&& $this->getImageArea( $image ) <= $wgMaxInterlacingAreas[$mimeType];
|
|
|
|
|
$params['interlace'] = $interlace;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 16:26:48 +00:00
|
|
|
/**
|
|
|
|
|
* Get ImageMagick subsampling factors for the target JPEG pixel format.
|
|
|
|
|
*
|
|
|
|
|
* @param string $pixelFormat one of 'yuv444', 'yuv422', 'yuv420'
|
|
|
|
|
* @return array of string keys
|
|
|
|
|
*/
|
|
|
|
|
protected function imageMagickSubsampling( $pixelFormat ) {
|
|
|
|
|
switch ( $pixelFormat ) {
|
2017-12-11 03:07:50 +00:00
|
|
|
case 'yuv444':
|
|
|
|
|
return [ '1x1', '1x1', '1x1' ];
|
|
|
|
|
case 'yuv422':
|
|
|
|
|
return [ '2x1', '1x1', '1x1' ];
|
|
|
|
|
case 'yuv420':
|
|
|
|
|
return [ '2x2', '1x1', '1x1' ];
|
|
|
|
|
default:
|
|
|
|
|
throw new MWException( 'Invalid pixel format for JPEG output' );
|
2016-04-27 16:26:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 19:04:26 +00:00
|
|
|
/**
|
|
|
|
|
* Transform an image using ImageMagick
|
2010-10-30 19:11:30 +00:00
|
|
|
*
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $image File associated with this thumbnail
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $params Array with scaler params
|
2010-10-30 19:11:30 +00:00
|
|
|
*
|
2017-08-07 14:55:20 +00:00
|
|
|
* @return MediaTransformError|bool Error object if error occurred, false (=no error) otherwise
|
2010-10-30 19:04:26 +00:00
|
|
|
*/
|
|
|
|
|
protected function transformImageMagick( $image, $params ) {
|
2010-10-30 19:11:30 +00:00
|
|
|
# use ImageMagick
|
2013-12-05 10:05:05 +00:00
|
|
|
global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
|
2018-04-19 17:00:16 +00:00
|
|
|
$wgImageMagickTempDir, $wgImageMagickConvertCommand, $wgJpegPixelFormat,
|
|
|
|
|
$wgJpegQuality;
|
2010-10-30 19:11:30 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$quality = [];
|
|
|
|
|
$sharpen = [];
|
2010-10-30 19:11:30 +00:00
|
|
|
$scene = false;
|
2016-02-17 09:09:32 +00:00
|
|
|
$animation_pre = [];
|
|
|
|
|
$animation_post = [];
|
|
|
|
|
$decoderHint = [];
|
2016-04-27 16:26:48 +00:00
|
|
|
$subsampling = [];
|
2016-01-14 02:13:11 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
if ( $params['mimeType'] == 'image/jpeg' ) {
|
2014-07-21 12:47:42 +00:00
|
|
|
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
|
2018-04-19 17:00:16 +00:00
|
|
|
$quality = [ '-quality', $qualityVal ?: (string)$wgJpegQuality ]; // 80% by default
|
2016-01-14 02:13:11 +00:00
|
|
|
if ( $params['interlace'] ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$animation_post = [ '-interlace', 'JPEG' ];
|
2016-01-14 02:13:11 +00:00
|
|
|
}
|
2017-02-20 22:44:19 +00:00
|
|
|
# Sharpening, see T8193
|
2010-10-30 19:11:30 +00:00
|
|
|
if ( ( $params['physicalWidth'] + $params['physicalHeight'] )
|
2013-12-05 10:05:05 +00:00
|
|
|
/ ( $params['srcWidth'] + $params['srcHeight'] )
|
|
|
|
|
< $wgSharpenReductionThreshold
|
|
|
|
|
) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$sharpen = [ '-sharpen', $wgSharpenParameter ];
|
2010-10-30 19:11:30 +00:00
|
|
|
}
|
2011-12-08 18:07:26 +00:00
|
|
|
if ( version_compare( $this->getMagickVersion(), "6.5.6" ) >= 0 ) {
|
2011-12-08 16:18:18 +00:00
|
|
|
// JPEG decoder hint to reduce memory, available since IM 6.5.6-2
|
2016-02-17 09:09:32 +00:00
|
|
|
$decoderHint = [ '-define', "jpeg:size={$params['physicalDimensions']}" ];
|
2011-12-08 16:18:18 +00:00
|
|
|
}
|
2016-04-27 16:26:48 +00:00
|
|
|
if ( $wgJpegPixelFormat ) {
|
|
|
|
|
$factors = $this->imageMagickSubsampling( $wgJpegPixelFormat );
|
|
|
|
|
$subsampling = [ '-sampling-factor', implode( ',', $factors ) ];
|
|
|
|
|
}
|
2016-01-14 02:13:11 +00:00
|
|
|
} elseif ( $params['mimeType'] == 'image/png' ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$quality = [ '-quality', '95' ]; // zlib 9, adaptive filtering
|
2016-01-14 02:13:11 +00:00
|
|
|
if ( $params['interlace'] ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$animation_post = [ '-interlace', 'PNG' ];
|
2016-01-14 02:13:11 +00:00
|
|
|
}
|
|
|
|
|
} elseif ( $params['mimeType'] == 'image/webp' ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$quality = [ '-quality', '95' ]; // zlib 9, adaptive filtering
|
2010-10-30 19:11:30 +00:00
|
|
|
} elseif ( $params['mimeType'] == 'image/gif' ) {
|
2011-11-28 04:40:31 +00:00
|
|
|
if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) {
|
2010-10-30 19:11:30 +00:00
|
|
|
// Extract initial frame only; we're so big it'll
|
|
|
|
|
// be a total drag. :P
|
|
|
|
|
$scene = 0;
|
|
|
|
|
} elseif ( $this->isAnimatedImage( $image ) ) {
|
2017-02-20 22:44:19 +00:00
|
|
|
// Coalesce is needed to scale animated GIFs properly (T3017).
|
2016-02-17 09:09:32 +00:00
|
|
|
$animation_pre = [ '-coalesce' ];
|
2010-10-30 19:11:30 +00:00
|
|
|
// We optimize the output, but -optimize is broken,
|
2017-02-20 22:44:19 +00:00
|
|
|
// use optimizeTransparency instead (T13822)
|
2010-10-30 19:11:30 +00:00
|
|
|
if ( version_compare( $this->getMagickVersion(), "6.3.5" ) >= 0 ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$animation_post = [ '-fuzz', '5%', '-layers', 'optimizeTransparency' ];
|
2008-10-13 21:50:16 +00:00
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2016-01-14 02:13:11 +00:00
|
|
|
if ( $params['interlace'] && version_compare( $this->getMagickVersion(), "6.3.4" ) >= 0
|
|
|
|
|
&& !$this->isAnimatedImage( $image ) ) { // interlacing animated GIFs is a bad idea
|
|
|
|
|
$animation_post[] = '-interlace';
|
|
|
|
|
$animation_post[] = 'GIF';
|
|
|
|
|
}
|
2011-12-27 00:46:44 +00:00
|
|
|
} elseif ( $params['mimeType'] == 'image/x-xcf' ) {
|
2014-07-04 04:46:10 +00:00
|
|
|
// Before merging layers, we need to set the background
|
|
|
|
|
// to be transparent to preserve alpha, as -layers merge
|
|
|
|
|
// merges all layers on to a canvas filled with the
|
|
|
|
|
// background colour. After merging we reset the background
|
|
|
|
|
// to be white for the default background colour setting
|
|
|
|
|
// in the PNG image (which is used in old IE)
|
2016-02-17 09:09:32 +00:00
|
|
|
$animation_pre = [
|
2014-07-04 04:46:10 +00:00
|
|
|
'-background', 'transparent',
|
|
|
|
|
'-layers', 'merge',
|
|
|
|
|
'-background', 'white',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\suppressWarnings();
|
2014-06-07 21:29:18 +00:00
|
|
|
$xcfMeta = unserialize( $image->getMetadata() );
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\restoreWarnings();
|
2014-06-07 21:29:18 +00:00
|
|
|
if ( $xcfMeta
|
|
|
|
|
&& isset( $xcfMeta['colorType'] )
|
|
|
|
|
&& $xcfMeta['colorType'] === 'greyscale-alpha'
|
|
|
|
|
&& version_compare( $this->getMagickVersion(), "6.8.9-3" ) < 0
|
|
|
|
|
) {
|
2017-02-20 22:44:19 +00:00
|
|
|
// T68323 - Greyscale images not rendered properly.
|
2014-06-07 21:29:18 +00:00
|
|
|
// So only take the "red" channel.
|
2016-02-17 09:09:32 +00:00
|
|
|
$channelOnly = [ '-channel', 'R', '-separate' ];
|
2014-07-20 14:44:50 +00:00
|
|
|
$animation_pre = array_merge( $animation_pre, $channelOnly );
|
2014-06-07 21:29:18 +00:00
|
|
|
}
|
2010-10-30 19:11:30 +00:00
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
// Use one thread only, to avoid deadlock bugs on OOM
|
2016-02-17 09:09:32 +00:00
|
|
|
$env = [ 'OMP_NUM_THREADS' => 1 ];
|
2010-10-30 19:11:30 +00:00
|
|
|
if ( strval( $wgImageMagickTempDir ) !== '' ) {
|
|
|
|
|
$env['MAGICK_TMPDIR'] = $wgImageMagickTempDir;
|
|
|
|
|
}
|
2011-07-25 22:01:19 +00:00
|
|
|
|
2014-11-13 10:26:15 +00:00
|
|
|
$rotation = isset( $params['disableRotation'] ) ? 0 : $this->getRotation( $image );
|
2011-07-15 15:13:18 +00:00
|
|
|
list( $width, $height ) = $this->extractPreRotationDimensions( $params, $rotation );
|
2008-11-02 16:45:52 +00:00
|
|
|
|
2018-06-08 02:58:35 +00:00
|
|
|
$cmd = wfEscapeShellArg( ...array_merge(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $wgImageMagickConvertCommand ],
|
2014-01-27 21:49:30 +00:00
|
|
|
$quality,
|
2010-10-30 19:11:30 +00:00
|
|
|
// Specify white background color, will be used for transparent images
|
|
|
|
|
// in Internet Explorer/Windows instead of default black.
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '-background', 'white' ],
|
2014-01-27 21:49:30 +00:00
|
|
|
$decoderHint,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $this->escapeMagickInput( $params['srcPath'], $scene ) ],
|
2014-01-27 21:49:30 +00:00
|
|
|
$animation_pre,
|
2010-10-30 19:11:30 +00:00
|
|
|
// For the -thumbnail option a "!" is needed to force exact size,
|
|
|
|
|
// or ImageMagick may decide your ratio is wrong and slice off
|
|
|
|
|
// a pixel.
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '-thumbnail', "{$width}x{$height}!" ],
|
2010-11-24 22:50:46 +00:00
|
|
|
// Add the source url as a comment to the thumb, but don't add the flag if there's no comment
|
2010-11-25 12:34:21 +00:00
|
|
|
( $params['comment'] !== ''
|
2016-02-17 09:09:32 +00:00
|
|
|
? [ '-set', 'comment', $this->escapeMagickProperty( $params['comment'] ) ]
|
|
|
|
|
: [] ),
|
2015-08-12 19:47:36 +00:00
|
|
|
// T108616: Avoid exposure of local file path
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '+set', 'Thumb::URI' ],
|
|
|
|
|
[ '-depth', 8 ],
|
2014-01-27 21:49:30 +00:00
|
|
|
$sharpen,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '-rotate', "-$rotation" ],
|
2016-04-27 16:26:48 +00:00
|
|
|
$subsampling,
|
2014-01-27 21:49:30 +00:00
|
|
|
$animation_post,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $this->escapeMagickOutput( $params['dstPath'] ) ] ) );
|
2010-10-30 19:11:30 +00:00
|
|
|
|
|
|
|
|
wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" );
|
|
|
|
|
$retval = 0;
|
2013-09-12 01:40:56 +00:00
|
|
|
$err = wfShellExecWithStderr( $cmd, $retval, $env );
|
2010-10-30 19:11:30 +00:00
|
|
|
|
|
|
|
|
if ( $retval !== 0 ) {
|
|
|
|
|
$this->logErrorForExternalProcess( $retval, $err, $cmd );
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-09-28 21:35:41 +00:00
|
|
|
return $this->getMediaTransformError( $params, "$err\nError code: $retval" );
|
2010-10-30 19:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false; # No error
|
2010-10-30 19:04:26 +00:00
|
|
|
}
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-03-12 19:32:39 +00:00
|
|
|
/**
|
|
|
|
|
* Transform an image using the Imagick PHP extension
|
2011-04-28 20:18:32 +00:00
|
|
|
*
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $image File associated with this thumbnail
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $params Array with scaler params
|
2011-03-12 19:32:39 +00:00
|
|
|
*
|
2017-08-07 14:55:20 +00:00
|
|
|
* @return MediaTransformError Error|bool object if error occurred, false (=no error) otherwise
|
2011-03-12 19:32:39 +00:00
|
|
|
*/
|
|
|
|
|
protected function transformImageMagickExt( $image, $params ) {
|
2016-01-14 02:13:11 +00:00
|
|
|
global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
|
2018-04-19 17:00:16 +00:00
|
|
|
$wgJpegPixelFormat, $wgJpegQuality;
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-03-12 19:32:39 +00:00
|
|
|
try {
|
|
|
|
|
$im = new Imagick();
|
|
|
|
|
$im->readImage( $params['srcPath'] );
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-03-12 19:32:39 +00:00
|
|
|
if ( $params['mimeType'] == 'image/jpeg' ) {
|
2017-02-20 22:44:19 +00:00
|
|
|
// Sharpening, see T8193
|
2011-03-12 19:32:39 +00:00
|
|
|
if ( ( $params['physicalWidth'] + $params['physicalHeight'] )
|
2013-12-05 10:05:05 +00:00
|
|
|
/ ( $params['srcWidth'] + $params['srcHeight'] )
|
|
|
|
|
< $wgSharpenReductionThreshold
|
|
|
|
|
) {
|
2014-12-12 08:41:27 +00:00
|
|
|
// Hack, since $wgSharpenParameter is written specifically for the command line convert
|
2011-03-12 19:32:39 +00:00
|
|
|
list( $radius, $sigma ) = explode( 'x', $wgSharpenParameter );
|
|
|
|
|
$im->sharpenImage( $radius, $sigma );
|
|
|
|
|
}
|
2014-07-21 12:47:42 +00:00
|
|
|
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
|
2018-04-19 17:00:16 +00:00
|
|
|
$im->setCompressionQuality( $qualityVal ?: $wgJpegQuality );
|
2016-01-14 02:13:11 +00:00
|
|
|
if ( $params['interlace'] ) {
|
|
|
|
|
$im->setInterlaceScheme( Imagick::INTERLACE_JPEG );
|
|
|
|
|
}
|
2016-04-27 16:26:48 +00:00
|
|
|
if ( $wgJpegPixelFormat ) {
|
|
|
|
|
$factors = $this->imageMagickSubsampling( $wgJpegPixelFormat );
|
|
|
|
|
$im->setSamplingFactors( $factors );
|
|
|
|
|
}
|
2013-04-20 21:11:46 +00:00
|
|
|
} elseif ( $params['mimeType'] == 'image/png' ) {
|
2011-03-12 19:32:39 +00:00
|
|
|
$im->setCompressionQuality( 95 );
|
2016-01-14 02:13:11 +00:00
|
|
|
if ( $params['interlace'] ) {
|
|
|
|
|
$im->setInterlaceScheme( Imagick::INTERLACE_PNG );
|
|
|
|
|
}
|
2011-03-12 19:32:39 +00:00
|
|
|
} elseif ( $params['mimeType'] == 'image/gif' ) {
|
2011-11-28 04:40:31 +00:00
|
|
|
if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) {
|
2011-03-12 19:32:39 +00:00
|
|
|
// Extract initial frame only; we're so big it'll
|
|
|
|
|
// be a total drag. :P
|
|
|
|
|
$im->setImageScene( 0 );
|
|
|
|
|
} elseif ( $this->isAnimatedImage( $image ) ) {
|
2017-02-20 22:44:19 +00:00
|
|
|
// Coalesce is needed to scale animated GIFs properly (T3017).
|
2011-03-12 19:32:39 +00:00
|
|
|
$im = $im->coalesceImages();
|
|
|
|
|
}
|
2016-01-14 02:13:11 +00:00
|
|
|
// GIF interlacing is only available since 6.3.4
|
|
|
|
|
$v = Imagick::getVersion();
|
|
|
|
|
preg_match( '/ImageMagick ([0-9]+\.[0-9]+\.[0-9]+)/', $v['versionString'], $v );
|
|
|
|
|
|
|
|
|
|
if ( $params['interlace'] && version_compare( $v[1], '6.3.4' ) >= 0 ) {
|
|
|
|
|
$im->setInterlaceScheme( Imagick::INTERLACE_GIF );
|
|
|
|
|
}
|
2011-03-12 19:32:39 +00:00
|
|
|
}
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2014-11-13 10:26:15 +00:00
|
|
|
$rotation = isset( $params['disableRotation'] ) ? 0 : $this->getRotation( $image );
|
2011-07-15 15:13:18 +00:00
|
|
|
list( $width, $height ) = $this->extractPreRotationDimensions( $params, $rotation );
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-03-12 19:32:39 +00:00
|
|
|
$im->setImageBackgroundColor( new ImagickPixel( 'white' ) );
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-03-12 19:32:39 +00:00
|
|
|
// Call Imagick::thumbnailImage on each frame
|
|
|
|
|
foreach ( $im as $i => $frame ) {
|
|
|
|
|
if ( !$frame->thumbnailImage( $width, $height, /* fit */ false ) ) {
|
|
|
|
|
return $this->getMediaTransformError( $params, "Error scaling frame $i" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$im->setImageDepth( 8 );
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2019-03-29 20:12:24 +00:00
|
|
|
if ( $rotation && !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) {
|
|
|
|
|
return $this->getMediaTransformError( $params, "Error rotating $rotation degrees" );
|
2011-03-12 19:32:39 +00:00
|
|
|
}
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-03-12 19:32:39 +00:00
|
|
|
if ( $this->isAnimatedImage( $image ) ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": Writing animated thumbnail\n" );
|
|
|
|
|
// This is broken somehow... can't find out how to fix it
|
|
|
|
|
$result = $im->writeImages( $params['dstPath'], true );
|
|
|
|
|
} else {
|
|
|
|
|
$result = $im->writeImage( $params['dstPath'] );
|
|
|
|
|
}
|
|
|
|
|
if ( !$result ) {
|
2011-04-28 20:18:32 +00:00
|
|
|
return $this->getMediaTransformError( $params,
|
2011-03-12 19:32:39 +00:00
|
|
|
"Unable to write thumbnail to {$params['dstPath']}" );
|
|
|
|
|
}
|
|
|
|
|
} catch ( ImagickException $e ) {
|
2011-04-28 20:18:32 +00:00
|
|
|
return $this->getMediaTransformError( $params, $e->getMessage() );
|
2011-03-12 19:32:39 +00:00
|
|
|
}
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-03-12 19:32:39 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2010-10-30 19:11:30 +00:00
|
|
|
|
2010-10-30 19:04:26 +00:00
|
|
|
/**
|
|
|
|
|
* Transform an image using a custom command
|
2010-10-30 19:11:30 +00:00
|
|
|
*
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $image File associated with this thumbnail
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $params Array with scaler params
|
2010-10-30 19:11:30 +00:00
|
|
|
*
|
2017-08-07 14:55:20 +00:00
|
|
|
* @return MediaTransformError Error|bool object if error occurred, false (=no error) otherwise
|
2010-10-30 19:04:26 +00:00
|
|
|
*/
|
|
|
|
|
protected function transformCustom( $image, $params ) {
|
2010-10-30 19:11:30 +00:00
|
|
|
# Use a custom convert command
|
|
|
|
|
global $wgCustomConvertCommand;
|
|
|
|
|
|
|
|
|
|
# Variables: %s %d %w %h
|
|
|
|
|
$src = wfEscapeShellArg( $params['srcPath'] );
|
|
|
|
|
$dst = wfEscapeShellArg( $params['dstPath'] );
|
|
|
|
|
$cmd = $wgCustomConvertCommand;
|
|
|
|
|
$cmd = str_replace( '%s', $src, str_replace( '%d', $dst, $cmd ) ); # Filenames
|
2014-01-27 21:49:30 +00:00
|
|
|
$cmd = str_replace( '%h', wfEscapeShellArg( $params['physicalHeight'] ),
|
|
|
|
|
str_replace( '%w', wfEscapeShellArg( $params['physicalWidth'] ), $cmd ) ); # Size
|
2010-10-30 19:11:30 +00:00
|
|
|
wfDebug( __METHOD__ . ": Running custom convert command $cmd\n" );
|
|
|
|
|
$retval = 0;
|
2013-09-12 01:40:56 +00:00
|
|
|
$err = wfShellExecWithStderr( $cmd, $retval );
|
2010-10-30 19:11:30 +00:00
|
|
|
|
|
|
|
|
if ( $retval !== 0 ) {
|
|
|
|
|
$this->logErrorForExternalProcess( $retval, $err, $cmd );
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
return $this->getMediaTransformError( $params, $err );
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
return false; # No error
|
2010-10-30 19:04:26 +00:00
|
|
|
}
|
2010-10-30 19:11:30 +00:00
|
|
|
|
2010-10-30 19:04:26 +00:00
|
|
|
/**
|
|
|
|
|
* Transform an image using the built in GD library
|
2010-10-30 19:11:30 +00:00
|
|
|
*
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $image File associated with this thumbnail
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $params Array with scaler params
|
2010-10-30 19:11:30 +00:00
|
|
|
*
|
2017-08-07 14:55:20 +00:00
|
|
|
* @return MediaTransformError|bool Error object if error occurred, false (=no error) otherwise
|
2010-10-30 19:04:26 +00:00
|
|
|
*/
|
|
|
|
|
protected function transformGd( $image, $params ) {
|
2010-10-30 19:11:30 +00:00
|
|
|
# Use PHP's builtin GD library functions.
|
|
|
|
|
# First find out what kind of file this is, and select the correct
|
|
|
|
|
# input routine for this.
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$typemap = [
|
|
|
|
|
'image/gif' => [ 'imagecreatefromgif', 'palette', false, 'imagegif' ],
|
|
|
|
|
'image/jpeg' => [ 'imagecreatefromjpeg', 'truecolor', true,
|
|
|
|
|
[ __CLASS__, 'imageJpegWrapper' ] ],
|
|
|
|
|
'image/png' => [ 'imagecreatefrompng', 'bits', false, 'imagepng' ],
|
|
|
|
|
'image/vnd.wap.wbmp' => [ 'imagecreatefromwbmp', 'palette', false, 'imagewbmp' ],
|
|
|
|
|
'image/xbm' => [ 'imagecreatefromxbm', 'palette', false, 'imagexbm' ],
|
|
|
|
|
];
|
2014-05-09 05:51:59 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
if ( !isset( $typemap[$params['mimeType']] ) ) {
|
|
|
|
|
$err = 'Image type not supported';
|
|
|
|
|
wfDebug( "$err\n" );
|
2012-08-19 23:05:20 +00:00
|
|
|
$errMsg = wfMessage( 'thumbnail_image-type' )->text();
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
return $this->getMediaTransformError( $params, $errMsg );
|
|
|
|
|
}
|
2014-05-09 05:51:59 +00:00
|
|
|
list( $loader, $colorStyle, $useQuality, $saveType ) = $typemap[$params['mimeType']];
|
2007-04-20 12:31:36 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
if ( !function_exists( $loader ) ) {
|
|
|
|
|
$err = "Incomplete GD library configuration: missing function $loader";
|
|
|
|
|
wfDebug( "$err\n" );
|
2012-08-19 23:05:20 +00:00
|
|
|
$errMsg = wfMessage( 'thumbnail_gd-library', $loader )->text();
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
return $this->getMediaTransformError( $params, $errMsg );
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
if ( !file_exists( $params['srcPath'] ) ) {
|
|
|
|
|
$err = "File seems to be missing: {$params['srcPath']}";
|
|
|
|
|
wfDebug( "$err\n" );
|
2012-08-19 23:05:20 +00:00
|
|
|
$errMsg = wfMessage( 'thumbnail_image-missing', $params['srcPath'] )->text();
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
return $this->getMediaTransformError( $params, $errMsg );
|
|
|
|
|
}
|
2009-04-13 15:05:47 +00:00
|
|
|
|
2018-02-19 22:59:17 +00:00
|
|
|
if ( filesize( $params['srcPath'] ) === 0 ) {
|
|
|
|
|
$err = "Image file size seems to be zero.";
|
|
|
|
|
wfDebug( "$err\n" );
|
|
|
|
|
$errMsg = wfMessage( 'thumbnail_image-size-zero', $params['srcPath'] )->text();
|
|
|
|
|
|
|
|
|
|
return $this->getMediaTransformError( $params, $errMsg );
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 23:26:32 +00:00
|
|
|
$src_image = $loader( $params['srcPath'] );
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2015-09-26 15:53:53 +00:00
|
|
|
$rotation = function_exists( 'imagerotate' ) && !isset( $params['disableRotation'] ) ?
|
|
|
|
|
$this->getRotation( $image ) :
|
|
|
|
|
0;
|
2011-07-15 15:13:18 +00:00
|
|
|
list( $width, $height ) = $this->extractPreRotationDimensions( $params, $rotation );
|
2011-01-07 22:12:05 +00:00
|
|
|
$dst_image = imagecreatetruecolor( $width, $height );
|
2010-10-30 19:11:30 +00:00
|
|
|
|
|
|
|
|
// Initialise the destination image to transparent instead of
|
|
|
|
|
// the default solid black, to support PNG and GIF transparency nicely
|
|
|
|
|
$background = imagecolorallocate( $dst_image, 0, 0, 0 );
|
|
|
|
|
imagecolortransparent( $dst_image, $background );
|
|
|
|
|
imagealphablending( $dst_image, false );
|
|
|
|
|
|
|
|
|
|
if ( $colorStyle == 'palette' ) {
|
|
|
|
|
// Don't resample for paletted GIF images.
|
|
|
|
|
// It may just uglify them, and completely breaks transparency.
|
|
|
|
|
imagecopyresized( $dst_image, $src_image,
|
|
|
|
|
0, 0, 0, 0,
|
2011-01-07 22:12:05 +00:00
|
|
|
$width, $height,
|
2010-10-30 19:11:30 +00:00
|
|
|
imagesx( $src_image ), imagesy( $src_image ) );
|
|
|
|
|
} else {
|
|
|
|
|
imagecopyresampled( $dst_image, $src_image,
|
|
|
|
|
0, 0, 0, 0,
|
2011-01-07 22:12:05 +00:00
|
|
|
$width, $height,
|
2010-10-30 19:11:30 +00:00
|
|
|
imagesx( $src_image ), imagesy( $src_image ) );
|
|
|
|
|
}
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2011-01-07 22:12:05 +00:00
|
|
|
if ( $rotation % 360 != 0 && $rotation % 90 == 0 ) {
|
|
|
|
|
$rot_image = imagerotate( $dst_image, $rotation, 0 );
|
|
|
|
|
imagedestroy( $dst_image );
|
|
|
|
|
$dst_image = $rot_image;
|
|
|
|
|
}
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
imagesavealpha( $dst_image, true );
|
2007-08-22 00:30:16 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$funcParams = [ $dst_image, $params['dstPath'] ];
|
2014-05-09 05:51:59 +00:00
|
|
|
if ( $useQuality && isset( $params['quality'] ) ) {
|
|
|
|
|
$funcParams[] = $params['quality'];
|
|
|
|
|
}
|
2018-06-09 23:26:32 +00:00
|
|
|
$saveType( ...$funcParams );
|
2014-05-09 05:51:59 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
imagedestroy( $dst_image );
|
|
|
|
|
imagedestroy( $src_image );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-10-30 19:11:30 +00:00
|
|
|
return false; # No error
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-23 16:24:54 +00:00
|
|
|
/**
|
2014-07-09 20:03:31 +00:00
|
|
|
* Callback for transformGd when transforming jpeg images.
|
2018-04-19 17:00:16 +00:00
|
|
|
*
|
|
|
|
|
* @param resource $dst_image Image resource of the original image
|
|
|
|
|
* @param string $thumbPath File path to write the thumbnail image to
|
|
|
|
|
* @param int|null $quality Quality of the thumbnail from 1-100,
|
|
|
|
|
* or null to use default quality.
|
2010-08-20 13:22:02 +00:00
|
|
|
*/
|
2018-04-19 17:00:16 +00:00
|
|
|
static function imageJpegWrapper( $dst_image, $thumbPath, $quality = null ) {
|
|
|
|
|
global $wgJpegQuality;
|
|
|
|
|
|
|
|
|
|
if ( $quality === null ) {
|
|
|
|
|
$quality = $wgJpegQuality;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
imageinterlace( $dst_image );
|
2014-05-09 05:51:59 +00:00
|
|
|
imagejpeg( $dst_image, $thumbPath, $quality );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-08 11:49:09 +00:00
|
|
|
/**
|
|
|
|
|
* Returns whether the current scaler supports rotation (im and gd do)
|
2011-04-28 20:18:32 +00:00
|
|
|
*
|
2011-01-08 11:49:09 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2014-07-09 20:03:31 +00:00
|
|
|
public function canRotate() {
|
|
|
|
|
$scaler = $this->getScalerType( null, false );
|
2011-03-02 19:42:30 +00:00
|
|
|
switch ( $scaler ) {
|
|
|
|
|
case 'im':
|
|
|
|
|
# ImageMagick supports autorotation
|
|
|
|
|
return true;
|
2011-03-12 19:32:39 +00:00
|
|
|
case 'imext':
|
|
|
|
|
# Imagick::rotateImage
|
|
|
|
|
return true;
|
2011-03-02 19:42:30 +00:00
|
|
|
case 'gd':
|
|
|
|
|
# GD's imagerotate function is used to rotate images, but not
|
|
|
|
|
# all precompiled PHP versions have that function
|
|
|
|
|
return function_exists( 'imagerotate' );
|
|
|
|
|
default:
|
|
|
|
|
# Other scalers don't support rotation
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-01-07 22:12:05 +00:00
|
|
|
}
|
2011-04-28 20:18:32 +00:00
|
|
|
|
2013-12-22 03:08:28 +00:00
|
|
|
/**
|
|
|
|
|
* @see $wgEnableAutoRotation
|
|
|
|
|
* @return bool Whether auto rotation is enabled
|
|
|
|
|
*/
|
2014-07-09 20:03:31 +00:00
|
|
|
public function autoRotateEnabled() {
|
2013-12-22 03:08:28 +00:00
|
|
|
global $wgEnableAutoRotation;
|
|
|
|
|
|
|
|
|
|
if ( $wgEnableAutoRotation === null ) {
|
2014-07-09 20:03:31 +00:00
|
|
|
// Only enable auto-rotation when we actually can
|
|
|
|
|
return $this->canRotate();
|
2013-12-22 03:08:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $wgEnableAutoRotation;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-08 11:35:55 +00:00
|
|
|
/**
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param File $file
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $params Rotate parameters.
|
2013-12-05 19:27:27 +00:00
|
|
|
* 'rotation' clockwise rotation in degrees, allowed are multiples of 90
|
2013-01-08 11:35:55 +00:00
|
|
|
* @since 1.21
|
2016-11-01 19:08:38 +00:00
|
|
|
* @return bool|MediaTransformError
|
2013-01-08 11:35:55 +00:00
|
|
|
*/
|
2013-03-08 12:07:32 +00:00
|
|
|
public function rotate( $file, $params ) {
|
2013-01-08 11:35:55 +00:00
|
|
|
global $wgImageMagickConvertCommand;
|
|
|
|
|
|
2013-03-24 10:01:51 +00:00
|
|
|
$rotation = ( $params['rotation'] + $this->getRotation( $file ) ) % 360;
|
2013-01-08 11:35:55 +00:00
|
|
|
$scene = false;
|
|
|
|
|
|
2014-07-09 20:03:31 +00:00
|
|
|
$scaler = $this->getScalerType( null, false );
|
2013-01-08 11:35:55 +00:00
|
|
|
switch ( $scaler ) {
|
|
|
|
|
case 'im':
|
|
|
|
|
$cmd = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " .
|
2013-03-24 10:01:51 +00:00
|
|
|
wfEscapeShellArg( $this->escapeMagickInput( $params['srcPath'], $scene ) ) .
|
2014-01-27 21:49:30 +00:00
|
|
|
" -rotate " . wfEscapeShellArg( "-$rotation" ) . " " .
|
2013-09-12 01:40:56 +00:00
|
|
|
wfEscapeShellArg( $this->escapeMagickOutput( $params['dstPath'] ) );
|
2013-01-08 11:35:55 +00:00
|
|
|
wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" );
|
|
|
|
|
$retval = 0;
|
2014-02-20 03:47:25 +00:00
|
|
|
$err = wfShellExecWithStderr( $cmd, $retval );
|
2013-01-08 11:35:55 +00:00
|
|
|
if ( $retval !== 0 ) {
|
2013-03-08 12:07:32 +00:00
|
|
|
$this->logErrorForExternalProcess( $retval, $err, $cmd );
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-01-08 11:35:55 +00:00
|
|
|
return new MediaTransformError( 'thumbnail_error', 0, 0, $err );
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-01-08 11:35:55 +00:00
|
|
|
return false;
|
|
|
|
|
case 'imext':
|
|
|
|
|
$im = new Imagick();
|
|
|
|
|
$im->readImage( $params['srcPath'] );
|
|
|
|
|
if ( !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) {
|
|
|
|
|
return new MediaTransformError( 'thumbnail_error', 0, 0,
|
|
|
|
|
"Error rotating $rotation degrees" );
|
|
|
|
|
}
|
|
|
|
|
$result = $im->writeImage( $params['dstPath'] );
|
|
|
|
|
if ( !$result ) {
|
|
|
|
|
return new MediaTransformError( 'thumbnail_error', 0, 0,
|
|
|
|
|
"Unable to write image to {$params['dstPath']}" );
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2013-01-08 11:35:55 +00:00
|
|
|
return false;
|
|
|
|
|
default:
|
|
|
|
|
return new MediaTransformError( 'thumbnail_error', 0, 0,
|
|
|
|
|
"$scaler rotation not implemented" );
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|