r48462 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48461‎ | r48462 | 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:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/media/Tiff.php (added) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -141,6 +141,10 @@
142142 * (bug 4582) Provide preference-based autoformatting of unlinked dates with the dateformat
143143 parser function.
144144 * (bug 17886) Special:Export now allows you to export a whole namespace (limited to 5000 pages)
 145+* (bug 17714) Limited TIFF upload support now built in if 'tif' extension is
 146+ enabled. Image width and height are now recognized, and when using ImageMagick,
 147+ optional flattening to PNG or JPEG for inline display can be enabled by setting
 148+ $wgTiffThumbnailType
145149
146150 === Bug fixes in 1.15 ===
147151 * (bug 16968) Special:Upload no longer throws useless warnings.
Index: trunk/phase3/includes/AutoLoader.php
@@ -189,6 +189,7 @@
190190 'StringUtils' => 'includes/StringUtils.php',
191191 'TablePager' => 'includes/Pager.php',
192192 'ThumbnailImage' => 'includes/MediaTransformOutput.php',
 193+ 'TiffHandler' => 'includes/media/Tiff.php',
193194 'TitleDependency' => 'includes/CacheDependency.php',
194195 'Title' => 'includes/Title.php',
195196 'TitleArray' => 'includes/TitleArray.php',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1997,6 +1997,7 @@
19981998 'image/jpeg' => 'BitmapHandler',
19991999 'image/png' => 'BitmapHandler',
20002000 'image/gif' => 'BitmapHandler',
 2001+ 'image/tiff' => 'TiffHandler',
20012002 'image/x-ms-bmp' => 'BmpHandler',
20022003 'image/x-bmp' => 'BmpHandler',
20032004 'image/svg+xml' => 'SvgHandler', // official
@@ -2075,6 +2076,16 @@
20762077 */
20772078 $wgMaxAnimatedGifArea = 1.0e6;
20782079 /**
 2080+ * Browsers don't support TIFF inline generally...
 2081+ * For inline display, we need to convert to PNG or JPEG.
 2082+ * Note scaling should work with ImageMagick, but may not with GD scaling.
 2083+ * // PNG is lossless, but inefficient for photos
 2084+ * $wgTiffThumbnailType = array( 'png', 'image/png' );
 2085+ * // JPEG is good for photos, but has no transparency support. Bad for diagrams.
 2086+ * $wgTiffThumbnailType = array( 'jpg', 'image/jpeg' );
 2087+ */
 2088+$wgTiffThumbnailType = false;
 2089+/**
20792090 * If rendered thumbnail files are older than this timestamp, they
20802091 * will be rerendered on demand as if the file didn't already exist.
20812092 * Update if there is some need to force thumbs and SVG rasterizations
Index: trunk/phase3/includes/media/Tiff.php
@@ -0,0 +1,33 @@
 2+<?php
 3+/**
 4+ * @file
 5+ * @ingroup Media
 6+ */
 7+
 8+/**
 9+ * @ingroup Media
 10+ */
 11+class TiffHandler extends BitmapHandler {
 12+
 13+ /**
 14+ * Conversion to PNG for inline display can be disabled here...
 15+ * Note scaling should work with ImageMagick, but may not with GD scaling.
 16+ */
 17+ function canRender( $file ) {
 18+ global $wgTiffThumbnailType;
 19+ return (bool)$wgTiffThumbnailType;
 20+ }
 21+
 22+ /**
 23+ * Browsers don't support TIFF inline generally...
 24+ * For inline display, we need to convert to PNG.
 25+ */
 26+ function mustRender( $file ) {
 27+ return true;
 28+ }
 29+
 30+ function getThumbType( $ext, $mime ) {
 31+ global $wgTiffThumbnailType;
 32+ return $wgTiffThumbnailType;
 33+ }
 34+}
Property changes on: trunk/phase3/includes/media/Tiff.php
___________________________________________________________________
Added: svn:eol-style
135 + native

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