Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler_body.php |
— | — | @@ -60,8 +60,9 @@ |
61 | 61 | * - check for running-identify-service |
62 | 62 | */ |
63 | 63 | static function check( $saveName, $tempName, &$error ) { |
64 | | - global $wgTiffMaxEmbedFiles, $wgTiffMaxMetaSize, $wgMaxUploadSize, $wgTiffRejectOnError, $wgTiffRejectOnWarning, |
65 | | - $wgTiffUseTiffReader, $wgTiffReaderPath, $wgTiffReaderCheckEofForJS; |
| 64 | + global $wgTiffMaxEmbedFiles, $wgTiffMaxMetaSize, $wgMaxUploadSize, |
| 65 | + $wgTiffRejectOnError, $wgTiffRejectOnWarning, $wgTiffUseTiffReader, |
| 66 | + $wgTiffReaderPath, $wgTiffReaderCheckEofForJS; |
66 | 67 | wfLoadExtensionMessages( 'PagedTiffHandler' ); |
67 | 68 | if ( $wgTiffUseTiffReader ) { |
68 | 69 | $tr = new TiffReader( $tempName ); |
— | — | @@ -143,7 +144,7 @@ |
144 | 145 | if ( in_array( $name, array( 'width', 'height', 'page', 'lossy' ) ) ) { |
145 | 146 | if ( $name == 'lossy' ) { |
146 | 147 | return in_array( $value, array( 1, 0, '1', '0', 'true', 'false', 'lossy', 'lossless' ) ); |
147 | | - } elseif ( $value <= 0 || $value > 65535 ) { // ImageMagick hits an overflow for values over 65536 |
| 148 | + } elseif ( $value <= 0 || $value > 65535 ) { // ImageMagick overflows for values > 65536 |
148 | 149 | return false; |
149 | 150 | } else { |
150 | 151 | return true; |
— | — | @@ -282,7 +283,8 @@ |
283 | 284 | * Supports extra parameters for multipage files and thumbnail type (lossless vs. lossy) |
284 | 285 | */ |
285 | 286 | function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
286 | | - global $wgImageMagickConvertCommand, $wgTiffMaxEmbedFileResolution, $wgTiffUseVips, $wgTiffVipsCommand; |
| 287 | + global $wgImageMagickConvertCommand, $wgTiffMaxEmbedFileResolution, |
| 288 | + $wgTiffUseVips, $wgTiffVipsCommand; |
287 | 289 | |
288 | 290 | $meta = $this->getMetaArray( $image ); |
289 | 291 | $errors = PagedTiffHandler::getMetadataErrors( $meta ); |
— | — | @@ -290,7 +292,8 @@ |
291 | 293 | if ( $errors ) { |
292 | 294 | $errors = PagedTiffHandler::joinMessages( $errors ); |
293 | 295 | if ( is_string( $errors ) ) { |
294 | | - return $this->doThumbError( $params, 'tiff_bad_file' ); #TODO: original error as param # #test this ^DK |
| 296 | + // TODO: original error as param // TESTME |
| 297 | + return $this->doThumbError( $params, 'tiff_bad_file' ); |
295 | 298 | } else { |
296 | 299 | return $this->doThumbError( $params, 'tiff_no_metadata' ); |
297 | 300 | } |
— | — | @@ -305,7 +308,8 @@ |
306 | 309 | $srcPath = $image->getPath(); |
307 | 310 | $page = intval( $params['page'] ); |
308 | 311 | |
309 | | - if ( $flags & self::TRANSFORM_LATER ) { //pretend the thumbnail exists, let it be created by a 404-handler |
| 312 | + if ( $flags & self::TRANSFORM_LATER ) { |
| 313 | + // pretend the thumbnail exists, let it be created by a 404-handler |
310 | 314 | return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page ); |
311 | 315 | } |
312 | 316 | |
— | — | @@ -318,7 +322,8 @@ |
319 | 323 | $height, $dstPath, $page ); |
320 | 324 | } |
321 | 325 | |
322 | | - if ( isset( $meta['page_data'][$page]['pixels'] ) && $meta['page_data'][$page]['pixels'] > $wgTiffMaxEmbedFileResolution ) |
| 326 | + if ( isset( $meta['page_data'][$page]['pixels'] ) |
| 327 | + && $meta['page_data'][$page]['pixels'] > $wgTiffMaxEmbedFileResolution ) |
323 | 328 | return $this->doThumbError( $params, 'tiff_sourcefile_too_large' ); |
324 | 329 | |
325 | 330 | if ( ( $width * $height ) > $wgTiffMaxEmbedFileResolution ) |
— | — | @@ -388,21 +393,21 @@ |
389 | 394 | global $wgUser, $wgThumbLimits; |
390 | 395 | |
391 | 396 | if ( empty( $params['width'] ) ) { |
392 | | - // no width/height in the parameter array |
| 397 | + // no usable width/height in the parameter array |
393 | 398 | // only happens if we don't have image meta-data, and no |
394 | 399 | // size was specified by the user. |
395 | 400 | // we need to pick *some* size, and the preferred |
396 | 401 | // thumbnail size seems sane. |
397 | 402 | $sz = $wgUser->getOption( 'thumbsize' ); |
398 | 403 | $width = $wgThumbLimits[ $sz ]; |
399 | | - $height = $width; // we don't have a hight, and no aspect ratio. make it square. |
| 404 | + $height = $width; // we don't have a hight or aspect ratio. make it square. |
400 | 405 | } else { |
401 | 406 | $width = intval( $params['width'] ); |
402 | 407 | |
403 | 408 | if ( !empty( $params['height'] ) ) { |
404 | 409 | $height = intval( $params['height'] ); |
405 | 410 | } else { |
406 | | - $height = $width; // we don't have a hight, and no aspect ratio. make it square. |
| 411 | + $height = $width; // we don't have a hight or aspect ratio. make it square. |
407 | 412 | } |
408 | 413 | } |
409 | 414 | |
— | — | @@ -459,8 +464,8 @@ |
460 | 465 | if ( !empty( $metadata ) && $metadata != serialize( array() ) ) { |
461 | 466 | $meta = unserialize( $metadata ); |
462 | 467 | if ( isset( $meta['errors'] ) ) { |
463 | | - //metadata contains an error message, but it's valid. |
464 | | - //don't try to re-render until the error is resolved! |
| 468 | + // metadata contains an error message, but it's valid. |
| 469 | + // don't try to re-render until the error is resolved! |
465 | 470 | return true; |
466 | 471 | } |
467 | 472 | if ( isset( $meta['page_amount'] ) && isset( $meta['page_data'] ) ) { |
— | — | @@ -548,7 +553,7 @@ |
549 | 554 | 'error', |
550 | 555 | $errors |
551 | 556 | ); |
552 | | - //XXX: need translation for <metadata-error> |
| 557 | + // XXX: need translation for <metadata-error> |
553 | 558 | } |
554 | 559 | if ( !empty( $meta['warnings'] ) ) { |
555 | 560 | $warnings = PagedTiffHandler::joinMessages( $meta['warnings'] ); |
— | — | @@ -558,7 +563,7 @@ |
559 | 564 | 'warning', |
560 | 565 | $warnings |
561 | 566 | ); |
562 | | - //XXX: need translation for <metadata-warning> |
| 567 | + // XXX: need translation for <metadata-warning> |
563 | 568 | } |
564 | 569 | return $result; |
565 | 570 | } |
— | — | @@ -570,8 +575,8 @@ |
571 | 576 | */ |
572 | 577 | static function getTiffImage( $image, $path ) { |
573 | 578 | // If no Image object is passed, a TiffImage is created based on $path . |
574 | | - // If there is an Image object, we check whether there's already a TiffImage instance in there; |
575 | | - // if not, a new instance is created and stored in the Image object |
| 579 | + // If there is an Image object, we check whether there's already a TiffImage |
| 580 | + // instance in there; if not, a new instance is created and stored in the Image object |
576 | 581 | if ( !$image ) { |
577 | 582 | $tiffimg = new PagedTiffImage( $path ); |
578 | 583 | } elseif ( !isset( $image->tiffImage ) ) { |
— | — | @@ -614,7 +619,8 @@ |
615 | 620 | * Returns false if unknown or if the document is not multi-page. |
616 | 621 | */ |
617 | 622 | function getPageDimensions( $image, $page ) { |
618 | | - // makeImageLink2 (Linker.php) sets $page to false if no page parameter in wiki code is set |
| 623 | + // makeImageLink2 (Linker.php) sets $page to false if no page parameter |
| 624 | + // is set in wiki code |
619 | 625 | if ( !$page ) { |
620 | 626 | $page = 1; |
621 | 627 | } |
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php |
— | — | @@ -86,10 +86,8 @@ |
87 | 87 | if ( $wgImageMagickIdentifyCommand ) { |
88 | 88 | |
89 | 89 | wfProfileIn( 'PagedTiffImage::retrieveMetaData' ); |
90 | | - /** |
91 | | - * ImageMagick is used in order to get the basic metadata of embedded files. |
92 | | - * This is not reliable in exiv2m since it is not possible to name a set of required fields. |
93 | | - */ |
| 90 | + |
| 91 | + // ImageMagick is used to get the basic metadata of individual pages |
94 | 92 | $cmd = wfEscapeShellArg( $wgImageMagickIdentifyCommand ) . |
95 | 93 | ' -format "[BEGIN]page=%p\nalpha=%A\nalpha2=%r\nheight=%h\nwidth=%w\ndepth=%z[END]" ' . |
96 | 94 | wfEscapeShellArg( $this->mFilename ) . ' 2>&1'; |
— | — | @@ -101,17 +99,19 @@ |
102 | 100 | if ( $retval ) { |
103 | 101 | $data['errors'][] = "identify command failed: $cmd"; |
104 | 102 | wfDebug( __METHOD__ . ": identify command failed: $cmd\n" ); |
105 | | - return $data; //fail. we *need* that info |
| 103 | + return $data; // fail. we *need* that info |
106 | 104 | } |
107 | 105 | $this->_meta = $this->convertDumpToArray( $dump ); |
108 | 106 | $this->_meta['exif'] = array(); |
109 | 107 | |
110 | 108 | if ( $wgTiffUseExiv ) { |
| 109 | + // read EXIF, XMP, IPTC as name-tag => interpreted data |
| 110 | + // -ignore unknown fields |
| 111 | + // see exiv2-doc @link http://www.exiv2.org/sample.html |
| 112 | + // NOTE: the linux version of exiv2 has a bug: it can only |
| 113 | + // read one type of meta-data at a time, not all at once. |
111 | 114 | $cmd = wfEscapeShellArg( $wgTiffExivCommand ) . |
112 | | - ' -u -psix -Pnt ' . // read EXIF, XMP, IPTC as name-tag => interpreted data -ignore unknown fields |
113 | | - // exiv2-doc @link http://www.exiv2.org/sample.html |
114 | | - # # the linux version of exiv2 has a bug an this command doesn't work on it. ^SU |
115 | | - wfEscapeShellArg( $this->mFilename ); |
| 115 | + ' -u -psix -Pnt ' . wfEscapeShellArg( $this->mFilename ); |
116 | 116 | |
117 | 117 | wfRunHooks( 'PagedTiffHandlerExivCommand', array( &$cmd, $this->mFilename ) ); |
118 | 118 | |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | if ( $retval ) { |
125 | 125 | $data['errors'][] = "exiv command failed: $cmd"; |
126 | 126 | wfDebug( __METHOD__ . ": exiv command failed: $cmd\n" ); |
127 | | - //don't fail - we are missing info, but that's no reason to abort yet. |
| 127 | + // don't fail - we are missing info, just report |
128 | 128 | } |
129 | 129 | |
130 | 130 | $result = array(); |
— | — | @@ -214,7 +214,7 @@ |
215 | 215 | } |
216 | 216 | } |
217 | 217 | if ( !$knownError ) { |
218 | | - # # drop BypassMessages ^SU |
| 218 | + // ignore messages that match $wgTiffIdentifyBypassMessages |
219 | 219 | foreach ( $wgTiffIdentifyBypassMessages as $msg ) { |
220 | 220 | if ( preg_match( $msg, trim( $error ) ) ) { |
221 | 221 | // $data['warnings'][] = $error; |