r69422 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69421‎ | r69422 | r69423 >
Date:11:41, 16 July 2010
Author:mglaser
Status:ok (Comments)
Tags:
Comment:
* use wgMaxImageArea when resizing with imagemagic
* use im_shrink when rendering with vips
* removed selenium_copy_to_mediawiki_root, since it has been integrated into maintenance/tests/selenium
Modified paths:
  • /trunk/extensions/PagedTiffHandler/PagedTiffHandler_body.php (modified) (history)
  • /trunk/extensions/PagedTiffHandler/selenium_copy_to_mediawiki_root (deleted) (history)

Diff [purge]

Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler_body.php
@@ -276,7 +276,7 @@
277277 */
278278 function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
279279 global $wgImageMagickConvertCommand, $wgTiffMaxEmbedFileResolution,
280 - $wgTiffUseVips, $wgTiffVipsCommand;
 280+ $wgTiffUseVips, $wgTiffVipsCommand, $wgMaxImageArea;
281281
282282 $meta = $this->getMetaArray( $image );
283283 $errors = PagedTiffHandler::getMetadataErrors( $meta );
@@ -325,12 +325,33 @@
326326 return $this->doThumbError( $params, 'thumbnail_dest_directory' );
327327
328328 if ( $wgTiffUseVips ) {
329 - // tested in Linux
330 - $cmd = wfEscapeShellArg( $wgTiffVipsCommand );
331 - $cmd .= ' im_resize_linear "' . wfEscapeShellArg( $srcPath ) . ':' . ( $page - 1 ) . '" ';
332 - $cmd .= wfEscapeShellArg( $dstPath );
333 - $cmd .= " {$width} {$height} 2>&1";
 329+ $pagesize = PagedTiffImage::getPageSize($meta, $page);
 330+ if ( !$pagesize ) {
 331+ return $this->doThumbError( $params, 'tiff_no_metadata' );
 332+ }
 333+
 334+ // Shrink factors must be > 1.
 335+ if ( ( $pagesize['width'] > $width ) && ( $pagesize['height'] > $height ) ) {
 336+ $xfac = $pagesize['width'] / $width;
 337+ $yfac = $pagesize['height'] / $height;
 338+ // tested in Linux and Windows
 339+ $cmd = wfEscapeShellArg( $wgTiffVipsCommand );
 340+ $cmd .= ' im_shrink "' . wfEscapeShellArg( $srcPath ) . ':' . ( $page - 1 ) . '" ';
 341+ $cmd .= wfEscapeShellArg( $dstPath );
 342+ $cmd .= " {$xfac} {$yfac} 2>&1";
 343+ } else {
 344+ // tested in Linux and Windows
 345+ $cmd = wfEscapeShellArg( $wgTiffVipsCommand );
 346+ $cmd .= ' im_resize_linear "' . wfEscapeShellArg( $srcPath ) . ':' . ( $page - 1 ) . '" ';
 347+ $cmd .= wfEscapeShellArg( $dstPath );
 348+ $cmd .= " {$width} {$height} 2>&1";
 349+ }
334350 } else {
 351+ if ( ( $width * $height ) > $wgMaxImageArea )
 352+ return $this->doThumbError( $params, 'tiff_targetfile_too_large' );
 353+ if ( isset( $meta['page_data'][$page]['pixels'] )
 354+ && $meta['page_data'][$page]['pixels'] > $wgMaxImageArea )
 355+ return $this->doThumbError( $params, 'tiff_sourcefile_too_large' );
335356 $cmd = wfEscapeShellArg( $wgImageMagickConvertCommand );
336357 $cmd .= " " . wfEscapeShellArg( $srcPath ) . "[" . ( $page - 1 ) . "]";
337358 $cmd .= " -depth 8 -resize {$width} ";

Comments

#Comment by Duesentrieb (talk | contribs)   11:46, 16 July 2010

please use separate commits for unrelated changes. removing selenium_copy_to_mediawiki_root should have it's own chance set. this makes rreviewing and especially reverting much easier.

Status & tagging log