Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.php |
— | — | @@ -123,9 +123,10 @@ |
124 | 124 | $wgMediaHandlers['image/tiff'] = 'PagedTiffHandler'; |
125 | 125 | $wgHooks['LanguageGetMagic'][] = 'PagedTiffHandler::addTiffLossyMagicWordLang'; |
126 | 126 | |
127 | | -define('TIFF_METADATA_VERSION', '1.1'); |
| 127 | +define('TIFF_METADATA_VERSION', '1.2'); |
128 | 128 | # 1.0: initial |
129 | 129 | # 1.1: fixed bugs in imageinfo parser |
| 130 | +# 1.2: photoshop quirks for imageinfo parser |
130 | 131 | |
131 | 132 | //$wgHooks['PagedTiffHandlerRenderCommand'][] = 'PagedTiffHandler::renderCommand'; |
132 | 133 | //$wgHooks['PagedTiffHandlerTiffData'][] = 'PagedTiffImage::tiffData'; |
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php |
— | — | @@ -225,6 +225,7 @@ |
226 | 226 | $entry = array(); |
227 | 227 | |
228 | 228 | $prevPage = 0; |
| 229 | + $quirks = false; |
229 | 230 | |
230 | 231 | foreach ( $rows as $row ) { |
231 | 232 | $row = trim( $row ); |
— | — | @@ -282,17 +283,37 @@ |
283 | 284 | $entry['width'] = (int)$value; |
284 | 285 | } else if ( $key == 'Image Length' || $key == 'PixelYDimension' ) { |
285 | 286 | $entry['height'] = (int)$value; |
| 287 | + } else if ( $key == 'Software' && preg_match('/photoshop/i', $value) ) { |
| 288 | + $quirks = "photoshop"; |
| 289 | + } else if ( $key == 'Subfile Type' ) { |
| 290 | + $entry['type'] = (int)$value; |
286 | 291 | } |
287 | 292 | } else { |
288 | 293 | // strange line |
289 | 294 | } |
290 | | - |
291 | 295 | } |
292 | 296 | |
293 | 297 | if ( $entry ) { |
294 | 298 | $ok = $this->addPageEntry($entry, $data, $prevPage); |
295 | 299 | } |
296 | 300 | |
| 301 | + if ( $quirks === 'photoshop' && count( $data['page_data'] ) > 1 ) { |
| 302 | + # Photoshop may use multiple directories for a single page image |
| 303 | + # Ignore the ones with SubfileType == 0 |
| 304 | + foreach ( $data['page_data'] as $i => $entry ) { |
| 305 | + if ( isset($entry['type']) && $entry['type'] === 0 ) { |
| 306 | + unset( $data['page_data'][$i] ); |
| 307 | + $data['warnings'][] = "removed spurious frame (photoshop quirk)"; |
| 308 | + } |
| 309 | + } |
| 310 | + |
| 311 | + $data['page_data'] = array_values( $data['page_data'] ); # re-index |
| 312 | + array_unshift( $data['page_data'], null ); # make 1-indexed |
| 313 | + unset( $data['page_data'][0] ); #remove dummy |
| 314 | + } |
| 315 | + |
| 316 | + $data['quirks'] = $quirks; |
| 317 | + |
297 | 318 | if ( !isset( $data['page_amount'] ) ) { |
298 | 319 | $data['page_amount'] = count( $data['page_data'] ); |
299 | 320 | } |