This new configuration variable defaults to 80, which is the current
quality in use when scaling jpeg thumbnails with ImageMagick. GD used a
quality of 95, which was reduced to 80 as a result of this change.
Bug: T192248
Change-Id: I94cad01cc876ef9083250f5d1989a73cd19617fb
* (T115414) The $wgEnableAPI and $wgEnableWriteAPI settings, deprecated in 1.31, have been removed.
* The $wgUseAjax setting is now formally deprecated, and MediaWiki will act as if it is always set.
* The $wgSiteSupportPage setting, unused since 1.5, was removed.
* (T115414) The $wgEnableAPI and $wgEnableWriteAPI settings, deprecated in 1.31, have been removed.
* The $wgUseAjax setting is now formally deprecated, and MediaWiki will act as if it is always set.
* The $wgSiteSupportPage setting, unused since 1.5, was removed.
+* $wgJpegQuality was added to allow configuring the quality of JPEG thumbnails (default 80).
+* The default quality of JPEG thumbnails generated by GD was reduced from 95 to 80.
* …
=== New features in 1.32 ===
* …
=== New features in 1.32 ===
*/
$wgJpegPixelFormat = 'yuv420';
*/
$wgJpegPixelFormat = 'yuv420';
+/**
+ * When scaling a JPEG thumbnail, this is the quality we request
+ * from the backend. It should be an int between 1 and 100,
+ * with 100 indicating 100% quality.
+ *
+ * @since 1.32
+ */
+$wgJpegQuality = 80;
+
/**
* Some tests and extensions use exiv2 to manipulate the Exif metadata in some
* image formats.
/**
* Some tests and extensions use exiv2 to manipulate the Exif metadata in some
* image formats.
protected function transformImageMagick( $image, $params ) {
# use ImageMagick
global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
protected function transformImageMagick( $image, $params ) {
# use ImageMagick
global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
- $wgImageMagickTempDir, $wgImageMagickConvertCommand, $wgJpegPixelFormat;
+ $wgImageMagickTempDir, $wgImageMagickConvertCommand, $wgJpegPixelFormat,
+ $wgJpegQuality;
$quality = [];
$sharpen = [];
$quality = [];
$sharpen = [];
if ( $params['mimeType'] == 'image/jpeg' ) {
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
if ( $params['mimeType'] == 'image/jpeg' ) {
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
- $quality = [ '-quality', $qualityVal ?: '80' ]; // 80%
+ $quality = [ '-quality', $qualityVal ?: (string)$wgJpegQuality ]; // 80% by default
if ( $params['interlace'] ) {
$animation_post = [ '-interlace', 'JPEG' ];
}
if ( $params['interlace'] ) {
$animation_post = [ '-interlace', 'JPEG' ];
}
*/
protected function transformImageMagickExt( $image, $params ) {
global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
*/
protected function transformImageMagickExt( $image, $params ) {
global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
+ $wgJpegPixelFormat, $wgJpegQuality;
try {
$im = new Imagick();
try {
$im = new Imagick();
$im->sharpenImage( $radius, $sigma );
}
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
$im->sharpenImage( $radius, $sigma );
}
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
- $im->setCompressionQuality( $qualityVal ?: 80 );
+ $im->setCompressionQuality( $qualityVal ?: $wgJpegQuality );
if ( $params['interlace'] ) {
$im->setInterlaceScheme( Imagick::INTERLACE_JPEG );
}
if ( $params['interlace'] ) {
$im->setInterlaceScheme( Imagick::INTERLACE_JPEG );
}
/**
* Callback for transformGd when transforming jpeg images.
/**
* Callback for transformGd when transforming jpeg images.
+ *
+ * @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.
- // FIXME: transformImageMagick() & transformImageMagickExt() uses JPEG quality 80, here it's 95?
- static function imageJpegWrapper( $dst_image, $thumbPath, $quality = 95 ) {
+ static function imageJpegWrapper( $dst_image, $thumbPath, $quality = null ) {
+ global $wgJpegQuality;
+
+ if ( $quality === null ) {
+ $quality = $wgJpegQuality;
+ }
+
imageinterlace( $dst_image );
imagejpeg( $dst_image, $thumbPath, $quality );
}
imageinterlace( $dst_image );
imagejpeg( $dst_image, $thumbPath, $quality );
}