r48462 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r48461 | r48462 (on ViewVC) | r48463 >
Date:22:03, 16 March 2009
Author:brion
Status:ok (Comments)
Tags:
Comment:* (bug 17714) Limited TIFF upload support now built in if 'tif' extension is
enabled. Image width and height are now recognized, and when using ImageMagick,
optional flattening to PNG or JPEG for inline display can be enabled by setting
$wgTiffThumbnailType

By default no thumbnailing will occur; only difference from previous will be that the image width/height is detected and displayed.

Not yet implemented:
* Multi-page support
* Cleverer thumbnailing for giant files
* Thumbnailing of any sort if not using ImageMagick
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/media/Tiff.php
===================================================================
--- trunk/phase3/includes/media/Tiff.php	(revision 0)
+++ trunk/phase3/includes/media/Tiff.php	(revision 48462)
@@ -0,0 +1,33 @@
+<?php
+/**
+ * @file
+ * @ingroup Media
+ */
+
+/**
+ * @ingroup Media
+ */
+class TiffHandler extends BitmapHandler {
+
+	/**
+	 * Conversion to PNG for inline display can be disabled here...
+	 * Note scaling should work with ImageMagick, but may not with GD scaling.
+	 */
+	function canRender( $file ) {
+		global $wgTiffThumbnailType;
+		return (bool)$wgTiffThumbnailType;
+	}
+
+	/**
+	 * Browsers don't support TIFF inline generally...
+	 * For inline display, we need to convert to PNG.
+	 */
+	function mustRender( $file ) {
+		return true;
+	}
+
+	function getThumbType( $ext, $mime ) {
+		global $wgTiffThumbnailType;
+		return $wgTiffThumbnailType;
+	}
+}

Property changes on: trunk/phase3/includes/media/Tiff.php
___________________________________________________________________
Name: svn:eol-style
   + native

Index: trunk/phase3/includes/AutoLoader.php
===================================================================
--- trunk/phase3/includes/AutoLoader.php	(revision 48461)
+++ trunk/phase3/includes/AutoLoader.php	(revision 48462)
@@ -189,6 +189,7 @@
 	'StringUtils' => 'includes/StringUtils.php',
 	'TablePager' => 'includes/Pager.php',
 	'ThumbnailImage' => 'includes/MediaTransformOutput.php',
+	'TiffHandler' => 'includes/media/Tiff.php',
 	'TitleDependency' => 'includes/CacheDependency.php',
 	'Title' => 'includes/Title.php',
 	'TitleArray' => 'includes/TitleArray.php',
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 48461)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 48462)
@@ -1997,6 +1997,7 @@
 	'image/jpeg' => 'BitmapHandler',
 	'image/png' => 'BitmapHandler',
 	'image/gif' => 'BitmapHandler',
+	'image/tiff' => 'TiffHandler',
 	'image/x-ms-bmp' => 'BmpHandler',
 	'image/x-bmp' => 'BmpHandler',
 	'image/svg+xml' => 'SvgHandler', // official
@@ -2075,6 +2076,16 @@
  */
 $wgMaxAnimatedGifArea = 1.0e6;
 /**
+ * Browsers don't support TIFF inline generally...
+ * For inline display, we need to convert to PNG or JPEG.
+ * Note scaling should work with ImageMagick, but may not with GD scaling.
+ *  // PNG is lossless, but inefficient for photos
+ *  $wgTiffThumbnailType = array( 'png', 'image/png' );
+ *  // JPEG is good for photos, but has no transparency support. Bad for diagrams.
+ *  $wgTiffThumbnailType = array( 'jpg', 'image/jpeg' );
+ */
+$wgTiffThumbnailType = false;
+/**
  * If rendered thumbnail files are older than this timestamp, they
  * will be rerendered on demand as if the file didn't already exist.
  * Update if there is some need to force thumbs and SVG rasterizations
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 48461)
+++ trunk/phase3/RELEASE-NOTES	(revision 48462)
@@ -141,6 +141,10 @@
 * (bug 4582) Provide preference-based autoformatting of unlinked dates with the dateformat
   parser function.
 * (bug 17886) Special:Export now allows you to export a whole namespace (limited to 5000 pages)
+* (bug 17714) Limited TIFF upload support now built in if 'tif' extension is
+  enabled. Image width and height are now recognized, and when using ImageMagick,
+  optional flattening to PNG or JPEG for inline display can be enabled by setting
+  $wgTiffThumbnailType
 
 === Bug fixes in 1.15 ===
 * (bug 16968) Special:Upload no longer throws useless warnings.

Comments

#Comment by Tim Starling (Talk | contribs)   04:36, 16 May 2009

For the benefit of non-Wikimedia users, it would be nice if this worked out of the box, if ImageMagick is in use.

Status & tagging log

Views
Toolbox