Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.php |
— | — | @@ -126,6 +126,8 @@ |
127 | 127 | define('TIFF_METADATA_VERSION', '1.1'); |
128 | 128 | # 1.0: initial |
129 | 129 | # 1.1: fixed bugs in imageinfo parser |
| 130 | +# 1.2: photoshop quirks (reverted) |
| 131 | +# 1.3: handing extra IDFs reported by tiffinfo |
130 | 132 | |
131 | 133 | //$wgHooks['PagedTiffHandlerRenderCommand'][] = 'PagedTiffHandler::renderCommand'; |
132 | 134 | //$wgHooks['PagedTiffHandlerTiffData'][] = 'PagedTiffImage::tiffData'; |
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php |
— | — | @@ -196,15 +196,17 @@ |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | | - $prevPage = max($prevPage, $entry['page']); |
| 200 | + if ( isset( $entry['width'] ) && isset( $entry['height'] ) ) { |
| 201 | + $prevPage = max($prevPage, $entry['page']); |
201 | 202 | |
202 | | - if ( !isset( $entry['alpha'] ) ) { |
203 | | - $entry['alpha'] = 'false'; |
| 203 | + if ( !isset( $entry['alpha'] ) ) { |
| 204 | + $entry['alpha'] = 'false'; |
| 205 | + } |
| 206 | + |
| 207 | + $entry['pixels'] = $entry['height'] * $entry['width']; |
| 208 | + $metadata['page_data'][$entry['page']] = $entry; |
204 | 209 | } |
205 | 210 | |
206 | | - $entry['pixels'] = $entry['height'] * $entry['width']; |
207 | | - $metadata['page_data'][$entry['page']] = $entry; |
208 | | - |
209 | 211 | $entry = array(); |
210 | 212 | return true; |
211 | 213 | } |
— | — | @@ -222,8 +224,10 @@ |
223 | 225 | $data = array(); |
224 | 226 | $data['page_data'] = array(); |
225 | 227 | |
| 228 | + $ignoreIFDs = array(); |
226 | 229 | $entry = array(); |
227 | 230 | |
| 231 | + $ignore = false; |
228 | 232 | $prevPage = 0; |
229 | 233 | |
230 | 234 | foreach ( $rows as $row ) { |
— | — | @@ -245,14 +249,19 @@ |
246 | 250 | |
247 | 251 | if ( $error ) continue; |
248 | 252 | |
249 | | - if ( preg_match('/^TIFF Directory at/', $row) ) { |
250 | | - if ( $entry ) { |
| 253 | + if ( preg_match('/^TIFF Directory at offset 0x[a-f0-9]+ \((\d+)\)/', $row, $m) ) { |
| 254 | + if ( $ignore ) { |
| 255 | + $entry = array(); |
| 256 | + } else if ( $entry ) { |
251 | 257 | $ok = $this->addPageEntry($entry, $data, $prevPage); |
252 | 258 | if ( !$ok ) { |
253 | 259 | $error = true; |
254 | 260 | continue; |
255 | 261 | } |
256 | 262 | } |
| 263 | + |
| 264 | + $ofs = (int)$m[1]; |
| 265 | + $ignore = !empty( $ignoreIFDs[ $ofs ] ); |
257 | 266 | } else if ( preg_match('#^(TIFF.*?Directory): (.*?/.*?): (.*)#i', $row, $m) ) { |
258 | 267 | $bypass = false; |
259 | 268 | $msg = $m[3]; |
— | — | @@ -282,6 +291,11 @@ |
283 | 292 | $entry['width'] = (int)$value; |
284 | 293 | } else if ( $key == 'Image Length' || $key == 'PixelYDimension' ) { |
285 | 294 | $entry['height'] = (int)$value; |
| 295 | + } else if ( preg_match('/.*IFDOffset/', $key) ) { |
| 296 | + # ignore extra IFDs, see <http://www.awaresystems.be/imaging/tiff/tifftags/exififd.html> |
| 297 | + # Note: we assume that we will always see the reference before the actual IFD, so we know which IFDs to ignore |
| 298 | + $ofs = (int)$value; |
| 299 | + $ignoreIFDs[$ofs] = true; |
286 | 300 | } |
287 | 301 | } else { |
288 | 302 | // strange line |
— | — | @@ -289,7 +303,7 @@ |
290 | 304 | |
291 | 305 | } |
292 | 306 | |
293 | | - if ( $entry ) { |
| 307 | + if ( $entry && !$ignore ) { |
294 | 308 | $ok = $this->addPageEntry($entry, $data, $prevPage); |
295 | 309 | } |
296 | 310 | |