Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler_body.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | function isMultiPage($img = false) { |
58 | 58 | if (!$img) return true; |
59 | 59 | $meta = unserialize($img->metadata); |
60 | | - return ($meta['Pages'] > 1); |
| 60 | + return ($meta['page_amount'] > 1); |
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
— | — | @@ -72,7 +72,6 @@ |
73 | 73 | function check( $saveName, $tempName, &$error ) { |
74 | 74 | global $wgTiffMaxEmbedFiles, $wgTiffMaxMetaSize, $wgMaxUploadSize, $wgTiffRejectOnError, $wgTiffRejectOnWarning, |
75 | 75 | $wgTiffUseTiffReader, $wgTiffReaderPath, $wgTiffReaderCheckEofForJS; |
76 | | - if (!(substr($saveName, -5, 5)=='.tiff' || substr($saveName, -4, 4)=='.tif')) return true; ### why? ^DK |
77 | 76 | wfLoadExtensionMessages( 'PagedTiffHandler' ); |
78 | 77 | if($wgTiffUseTiffReader) { |
79 | 78 | require_once($wgTiffReaderPath.'/TiffReader.php'); |
— | — | @@ -124,7 +123,7 @@ |
125 | 124 | wfDebug( __METHOD__.": tiff_too_much_meta ($saveName)\n" ); |
126 | 125 | return false; |
127 | 126 | } |
128 | | - if($wgTiffMaxEmbedFiles && $meta['Pages'] > $wgTiffMaxEmbedFiles) { |
| 127 | + if($wgTiffMaxEmbedFiles && $meta['page_amount'] > $wgTiffMaxEmbedFiles) { |
129 | 128 | $error = 'tiff_too_much_embed_files'; |
130 | 129 | wfDebug( __METHOD__.": tiff_too_much_embed_files ($saveName)\n" ); |
131 | 130 | return false; |
— | — | @@ -139,8 +138,7 @@ |
140 | 139 | function getParamMap() { |
141 | 140 | return array( |
142 | 141 | 'img_width' => 'width', |
143 | | - // @todo check height ### height!! ^DK |
144 | | - ## Die Methode gibt nur die ParamMap für die MagicWordIDs zurück. Es gibt keine MagicWordID für height. ^SU |
| 142 | + // @todo check height ## MediaWiki bietet keine MagicWord-ID für height. Dies scheint ein Bug zu sein. ^SU |
145 | 143 | 'img_page' => 'page', |
146 | 144 | 'img_lossy' => 'lossy', |
147 | 145 | ); |
— | — | @@ -159,10 +157,10 @@ |
160 | 158 | } |
161 | 159 | return false; |
162 | 160 | } |
163 | | - if ( $value <= 0 || $value > PHP_INT_MAX ) { ## check against integer overflow ^SU |
| 161 | + if ( $value <= 0 || $value > 65535 ) { ## ImageMagick läuft bei einer Seitenangabe höher als 65535 in einen Overflow. ^SU |
164 | 162 | return false; |
165 | 163 | } else { |
166 | | - return true; ## spills at 65536?? ^DK |
| 164 | + return true; |
167 | 165 | } |
168 | 166 | } else { |
169 | 167 | return false; |
— | — | @@ -232,8 +230,11 @@ |
233 | 231 | $srcHeight = $size['height']; |
234 | 232 | |
235 | 233 | if ( isset( $params['height'] ) && $params['height'] != -1 ) { |
236 | | - ## checks if with the given ratio the image box should be fitted ^SU |
237 | | - if ( $params['width'] * $srcHeight > $params['height'] * $srcWidth ) { ## huh?? what does this do? ^DK |
| 234 | + ## Wenn das Bild im Hochformat ist und der Height-Parameter angegeben ist, |
| 235 | + ## wird der Width-Parameter angepasst, sofern width x height die Original-Ratio |
| 236 | + ## zerstören würden. Dies dient der Paging-Vorschau auf der ImagePage, |
| 237 | + ## damit die Seiten-Vorschauen nicht das Seiten-Layout zerstören. ^SU |
| 238 | + if ( $params['width'] * $srcHeight > $params['height'] * $srcWidth ) { |
238 | 239 | $params['width'] = wfFitBoxWidth( $srcWidth, $srcHeight, $params['height'] ); |
239 | 240 | } |
240 | 241 | } |
— | — | @@ -258,6 +259,7 @@ |
259 | 260 | if ( !$metadata ) { |
260 | 261 | if($metadata == -1) { |
261 | 262 | return $this->doThumbError( @$params['width'], @$params['height'], 'tiff_error_cached' ); ##test this ^DK |
| 263 | + // $wgCacheType = CACHE_DB |
262 | 264 | } |
263 | 265 | return $this->doThumbError( @$params['width'], @$params['height'], 'tiff_no_metadata' ); |
264 | 266 | } |
— | — | @@ -284,7 +286,7 @@ |
285 | 287 | return new ThumbnailImage( $image, $dstUrl, $width, |
286 | 288 | $height, $dstPath, $page ); |
287 | 289 | |
288 | | - if(isset($meta['pages'][$page]['pixels']) && $meta['pages'][$page]['pixels'] > $wgTiffMaxEmbedFileResolution) |
| 290 | + if(isset($meta['page_data'][$page]['pixels']) && $meta['page_data'][$page]['pixels'] > $wgTiffMaxEmbedFileResolution) |
289 | 291 | return $this->doThumbError( $width, $height, 'tiff_sourcefile_too_large' ); |
290 | 292 | |
291 | 293 | if(($width * $height) > $wgTiffMaxEmbedFileResolution) |
— | — | @@ -335,7 +337,7 @@ |
336 | 338 | function getThumbExtension( $image, $page, $lossy ) { |
337 | 339 | if($lossy === NULL) { |
338 | 340 | $data = $this->getMetaArray($image); |
339 | | - if((strtolower($data['pages'][$page]['alpha']) == 'true')) { |
| 341 | + if((strtolower($data['page_data'][$page]['alpha']) == 'true')) { |
340 | 342 | return '.png'; |
341 | 343 | } |
342 | 344 | else { |
— | — | @@ -358,7 +360,7 @@ |
359 | 361 | function pageCount( $image ) { |
360 | 362 | $data = $this->getMetaArray( $image ); |
361 | 363 | if ( !$data ) return false; |
362 | | - return intval( $data['Pages'] ); |
| 364 | + return intval( $data['page_amount'] ); |
363 | 365 | } |
364 | 366 | |
365 | 367 | /** |
— | — | @@ -397,8 +399,8 @@ |
398 | 400 | if( $metadata ) { |
399 | 401 | wfLoadExtensionMessages( 'PagedTiffHandler' ); |
400 | 402 | return wfMsgExt('tiff-file-info-size', 'parseinline', |
401 | | - $wgLang->formatNum( $metadata['pages'][$page]['width'] ), |
402 | | - $wgLang->formatNum( $metadata['pages'][$page]['height'] ), |
| 403 | + $wgLang->formatNum( $metadata['page_data'][$page]['width'] ), |
| 404 | + $wgLang->formatNum( $metadata['page_data'][$page]['height'] ), |
403 | 405 | $wgLang->formatSize( $image->getSize() ), |
404 | 406 | $image->getMimeType(), |
405 | 407 | $page ); |
— | — | @@ -413,8 +415,7 @@ |
414 | 416 | function isMetadataValid( $image, $metadata ) { |
415 | 417 | if(!empty( $metadata ) && $metadata != serialize(array())) { |
416 | 418 | $meta = unserialize($metadata); |
417 | | - ## Sollte das wirklich geändert werden, werden bereits bestehende Bilder Fehler produzieren. ^SU |
418 | | - if(isset($meta['Pages']) && isset($meta['pages'])) { # ['Pages'] UND ['pages']? wieso das denn? das ist verwirrend... ^DK |
| 419 | + if(isset($meta['page_amount']) && isset($meta['page_data'])) { |
419 | 420 | return true; |
420 | 421 | } |
421 | 422 | } |
— | — | @@ -428,8 +429,7 @@ |
429 | 430 | * @return array of strings |
430 | 431 | * @access private |
431 | 432 | */ |
432 | | - ## könnte in den ImageHandler ... ist bis jetzt aber nur im BitmapHandler implementiert. ^SU |
433 | | - function visibleMetadataFields() { #sieht vollig generisch aus. gehört das nicht in die oberklasse? ^DK |
| 433 | + function visibleMetadataFields() { |
434 | 434 | $fields = array(); |
435 | 435 | $lines = explode( "\n", wfMsg( 'metadata-fields' ) ); |
436 | 436 | foreach( $lines as $line ) { |
— | — | @@ -527,7 +527,7 @@ |
528 | 528 | ## Ist dies nicht der Fall, wird eine Instanz erstellt und im ImageObject gespeichert. ^SU |
529 | 529 | if ( !$image ) |
530 | 530 | $tiffimg = new PagedTiffImage( $path ); |
531 | | - elseif ( !isset( $image->tiffImage ) ) #wo kommt $image her, wofür ist es gut? könnte es evtl schon ein TiffImage sein? ^DK |
| 531 | + elseif ( !isset( $image->tiffImage ) ) |
532 | 532 | $tiffimg = $image->tiffImage = new PagedTiffImage( $path ); |
533 | 533 | else |
534 | 534 | $tiffimg = $image->tiffImage; |
— | — | @@ -539,8 +539,6 @@ |
540 | 540 | * Returns an Array with the Image-Metadata. |
541 | 541 | */ |
542 | 542 | function getMetaArray( $image ) { |
543 | | - # gehört das nicht ein einen lazy initializer in TiffImage::getMetaArray() oder so? ^DK |
544 | | - # Nein. Die Methode holt die Metadaten aus dem MediaWiki-ImageObject und nicht aus dem TiffImage. ^SU |
545 | 543 | if ( isset( $image->tiffMetaArray ) ) |
546 | 544 | return $image->tiffMetaArray; |
547 | 545 | |
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php |
— | — | @@ -70,9 +70,9 @@ |
71 | 71 | * Returns an array with width and height of the tiff page. |
72 | 72 | */ |
73 | 73 | public static function getPageSize( $data, $page ) { |
74 | | - if( isset( $data['pages'][$page] ) ) { |
75 | | - return array('width' => $data['pages'][$page]['width'], |
76 | | - 'height' => $data['pages'][$page]['height']); |
| 74 | + if( isset( $data['page_data'][$page] ) ) { |
| 75 | + return array('width' => $data['page_data'][$page]['width'], |
| 76 | + 'height' => $data['page_data'][$page]['height']); |
77 | 77 | } |
78 | 78 | return false; |
79 | 79 | } |
— | — | @@ -80,8 +80,8 @@ |
81 | 81 | /** |
82 | 82 | * Reads metadata of the tiff file via shell command and returns an associative array. |
83 | 83 | * layout: |
84 | | - * meta['Pages'] = amount of pages |
85 | | - * meta['pages'] = metadata per page |
| 84 | + * meta['page_amount'] = amount of pages |
| 85 | + * meta['page_data'] = metadata per page |
86 | 86 | * meta['exif'] = Exif, XMP and IPTC |
87 | 87 | * meta['errors'] = identify-errors |
88 | 88 | * meta['warnings'] = identify-warnings |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | if($this->_meta === NULL) { |
101 | 101 | if ( $wgImageMagickIdentifyCommand ) { |
102 | 102 | |
103 | | - wfProfileIn( 'PagedTiffImage' ); |
| 103 | + wfProfileIn( 'PagedTiffImage::retrieveMetaData' ); |
104 | 104 | /** |
105 | 105 | * ImageMagick is used in order to get the basic metadata of embedded files. |
106 | 106 | * This is not reliable in exiv2m since it is not possible to name a set of required fields. |
— | — | @@ -122,6 +122,7 @@ |
123 | 123 | $cmd = wfEscapeShellArg( $wgTiffExivCommand ) . |
124 | 124 | ' -u -psix -Pnt ' . // read EXIF, XMP, IPTC as name-tag => interpreted data -ignore unknown fields |
125 | 125 | // exiv2-doc @link http://www.exiv2.org/sample.html |
| 126 | + ## In der Linux-Version von exiv2 gibt es einen Bug, sodass diese Parameter dort nicht funktionieren. ^SU |
126 | 127 | wfEscapeShellArg( $this->mFilename ); |
127 | 128 | |
128 | 129 | wfRunHooks( "PagedTiffHandlerExivCommand", array( &$cmd, $this->mFilename ) ); |
— | — | @@ -148,7 +149,7 @@ |
149 | 150 | wfProfileOut( 'identify -verbose' ); |
150 | 151 | $this->_meta['exif'] = $this->parseVerbose($dump); |
151 | 152 | } |
152 | | - wfProfileOut( 'PagedTiffImage' ); |
| 153 | + wfProfileOut( 'PagedTiffImage::retrieveMetaData' ); |
153 | 154 | } |
154 | 155 | } |
155 | 156 | unset($this->_meta['exif']['Image']); |
— | — | @@ -167,8 +168,8 @@ |
168 | 169 | $infos = NULL; |
169 | 170 | preg_match_all('/\[BEGIN\](.+?)\[END\]/si', $dump, $infos, PREG_SET_ORDER); |
170 | 171 | $data = array(); |
171 | | - $data['Pages'] = count($infos); |
172 | | - $data['pages'] = array(); |
| 172 | + $data['page_amount'] = count($infos); |
| 173 | + $data['page_data'] = array(); |
173 | 174 | foreach($infos as $info) { |
174 | 175 | $entry = array(); |
175 | 176 | $lines = explode("\n", $info[1]); |
— | — | @@ -195,7 +196,7 @@ |
196 | 197 | $entry[trim($parts[0])] = trim($parts[1]); |
197 | 198 | } |
198 | 199 | $entry['pixels'] = $entry['height'] * $entry['width']; |
199 | | - $data['pages'][$entry['page']] = $entry; |
| 200 | + $data['page_data'][$entry['page']] = $entry; |
200 | 201 | } |
201 | 202 | |
202 | 203 | $dump = preg_replace('/\[BEGIN\](.+?)\[END\]/si', '', $dump); |
— | — | @@ -210,17 +211,18 @@ |
211 | 212 | break; |
212 | 213 | } |
213 | 214 | } |
214 | | - if(!$knownError) { |
| 215 | + if(!$knownError) { |
| 216 | + ## BypassMessages werden nicht gespeichert ^SU |
215 | 217 | foreach($wgTiffIdentifyBypassMessages as $msg) { |
216 | 218 | if (preg_match($msg, trim($error))) { |
217 | | - $data['warnings'][] = $error; |
| 219 | + //$data['warnings'][] = $error; |
218 | 220 | $knownError = true; |
219 | 221 | break; |
220 | 222 | } |
221 | 223 | } |
222 | 224 | } |
223 | 225 | if(!$knownError) { |
224 | | - $data['unknownErrors'][] = $error; |
| 226 | + $data['warning'][] = $error; |
225 | 227 | } |
226 | 228 | } |
227 | 229 | } |
Property changes on: trunk/extensions/PagedTiffHandler |
___________________________________________________________________ |
Name: svn:ignore |
228 | 230 | + nbproject |