if ( !$this->normaliseParams( $image, $params ) ) {
return new TransformParameterError( $params );
}
+
# Create a parameter array to pass to the scaler
$scalerParams = array(
# The size to which the image will be resized
}
# Transform functions and binaries need a FS source file
- $scalerParams['srcPath'] = $image->getLocalRefPath();
+ $thumbnailSource = $image->getThumbnailSource( $params );
+
+ $scalerParams['srcPath'] = $thumbnailSource['path'];
+ $scalerParams['srcWidth'] = $thumbnailSource['width'];
+ $scalerParams['srcHeight'] = $thumbnailSource['height'];
+
if ( $scalerParams['srcPath'] === false ) { // Failed to get local copy
wfDebugLog( 'thumbnail',
sprintf( 'Thumbnail failed on %s: could not get local copy of "%s"',
}
}
} elseif ( $params['mimeType'] == 'image/x-xcf' ) {
- $animation_post = array( '-layers', 'merge' );
+ // 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)
+ $animation_pre = array(
+ '-background', 'transparent',
+ '-layers', 'merge',
+ '-background', 'white',
+ );
+ wfSuppressWarnings();
+ $xcfMeta = unserialize( $image->getMetadata() );
+ wfRestoreWarnings();
+ if ( $xcfMeta
+ && isset( $xcfMeta['colorType'] )
+ && $xcfMeta['colorType'] === 'greyscale-alpha'
+ && version_compare( $this->getMagickVersion(), "6.8.9-3" ) < 0
+ ) {
+ // bug 66323 - Greyscale images not rendered properly.
+ // So only take the "red" channel.
+ $channelOnly = array( '-channel', 'R', '-separate' );
+ $animation_pre = array_merge( $animation_pre, $channelOnly );
+ }
}
// Use one thread only, to avoid deadlock bugs on OOM
}
/**
- * Rerurns whether the file needs to be rendered. Returns true if the
+ * Returns whether the file needs to be rendered. Returns true if the
* file requires rotation and we are able to rotate it.
*
* @param File $file