40 if ( !parent::normaliseParams( $image, $params ) ) {
43 if ( isset( $params[
'quality'] ) && !self::validateQuality( $params[
'quality'] ) ) {
50 if ( $name ===
'quality' ) {
53 return parent::validateParam( $name, $value );
62 return $value ===
'low';
67 $res = parent::makeParamString( $params );
68 if (
$res && isset( $params[
'quality'] ) ) {
69 $res =
"q{$params['quality']}-$res";
81 if ( preg_match(
'/q([^-]+)-(.*)$/', $str, $m ) ) {
83 if ( self::validateQuality( $v ) ) {
84 $res = parent::parseParamString( $m[2] );
90 $res = parent::parseParamString( $str );
96 $res = parent::getScriptParams( $params );
97 if ( isset( $params[
'quality'] ) ) {
98 $res[
'quality'] = $params[
'quality'];
106 if ( !is_array( $meta ) ) {
108 throw new MWException(
'Metadata array is not an array' );
113 }
catch ( Exception $e ) {
116 wfDebug( __METHOD__ .
': ' . $e->getMessage() );
144 if ( $wgJpegTran && is_executable(
$wgJpegTran ) ) {
155 if ( $result->getExitCode() !== 0 ) {
157 $result->getStdout(),
166 return parent::rotate(
$file, $params );
175 $params = parent::sanitizeParamsForBucketing( $params );
178 if ( isset( $params[
'quality'] ) ) {
179 unset( $params[
'quality'] );
191 $ret = parent::transformImageMagick( $image, $params );
216 if ( isset( $params[
'quality'] ) && $params[
'quality'] > 30 ) {
224 realpath( __DIR__ ) .
'/tinyrgb.icc'
243 array $oldProfileStrings, $profileFilepath
251 $result = Shell::command(
254 '-ICC_Profile:ProfileDescription',
263 $data = explode(
"\t", trim( $result->getStdout() ) );
265 if ( $result->getExitCode() !== 0 ) {
271 $colorSpaceRegex =
'/' . preg_quote( $data[0],
'/' ) .
'/i';
272 if ( empty( preg_grep( $colorSpaceRegex, $colorSpaces ) ) ) {
277 $profileRegex =
'/' . preg_quote( $data[1],
'/' ) .
'/i';
278 if ( empty( preg_grep( $profileRegex, $oldProfileStrings ) ) ) {
284 '-overwrite_original',
285 '-icc_profile<=' . $profileFilepath,
292 if ( $result->getExitCode() !== 0 ) {
294 $result->getStdout(),
$wgUseTinyRGBForJPGThumbnails
When this variable is true and JPGs use the sRGB ICC profile, swaps it for the more lightweight (and ...
$wgJpegTran
used for lossless jpeg rotation
$wgExiftool
Path to exiftool binary.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Stuff specific to JPEG and (built-in) TIFF handler.
getRotation( $file)
On supporting image formats, try to read out the low-level orientation of the file and return the ang...
const BROKEN_FILE
Error extracting metadata.
makeParamString( $params)
Merge a parameter array into a string appropriate for inclusion in filenames.string Stable to overrid...
validateParam( $name, $value)
Validate a thumbnail parameter at parse time.Return true to accept the parameter, and false to reject...
const SRGB_ICC_PROFILE_DESCRIPTION
getScriptParams( $params)
Stable to override Stable to override
getMetadata( $image, $filename)
Get handler-specific metadata which will be saved in the img_metadata field.
swapICCProfile( $filepath, array $colorSpaces, array $oldProfileStrings, $profileFilepath)
Swaps an embedded ICC profile for another, if found.
static validateQuality( $value)
Validate and normalize quality value to be between 1 and 100 (inclusive).
supportsBucketing()
Returns whether or not this handler supports the chained generation of thumbnails according to bucket...
const SRGB_EXIF_COLOR_SPACE
parseParamString( $str)
Parse a param string made with makeParamString back into an array.array|bool Array of parameters or f...
sanitizeParamsForBucketing( $params)
Returns a normalised params array for which parameters have been cleaned up for bucketing purposes St...
normaliseParams( $image, &$params)
Stable to override.
transformImageMagick( $image, $params)
Transform an image using ImageMagick Stable to override.MediaTransformError|false Error object if err...
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.