@@ 99-126 (lines=28) @@ | ||
96 | return $res; |
|
97 | } |
|
98 | ||
99 | function getMetadata( $image, $filename ) { |
|
100 | try { |
|
101 | $meta = BitmapMetadataHandler::Jpeg( $filename ); |
|
102 | if ( !is_array( $meta ) ) { |
|
103 | // This should never happen, but doesn't hurt to be paranoid. |
|
104 | throw new MWException( 'Metadata array is not an array' ); |
|
105 | } |
|
106 | $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version(); |
|
107 | ||
108 | return serialize( $meta ); |
|
109 | } catch ( Exception $e ) { |
|
110 | // BitmapMetadataHandler throws an exception in certain exceptional |
|
111 | // cases like if file does not exist. |
|
112 | wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" ); |
|
113 | ||
114 | /* This used to use 0 (ExifBitmapHandler::OLD_BROKEN_FILE) for the cases |
|
115 | * * No metadata in the file |
|
116 | * * Something is broken in the file. |
|
117 | * However, if the metadata support gets expanded then you can't tell if the 0 is from |
|
118 | * a broken file, or just no props found. A broken file is likely to stay broken, but |
|
119 | * a file which had no props could have props once the metadata support is improved. |
|
120 | * Thus switch to using -1 to denote only a broken file, and use an array with only |
|
121 | * MEDIAWIKI_EXIF_VERSION to denote no props. |
|
122 | */ |
|
123 | ||
124 | return ExifBitmapHandler::BROKEN_FILE; |
|
125 | } |
|
126 | } |
|
127 | ||
128 | /** |
|
129 | * @param File $file |
@@ 79-101 (lines=23) @@ | ||
76 | * @throws MWException |
|
77 | * @return string |
|
78 | */ |
|
79 | function getMetadata( $image, $filename ) { |
|
80 | global $wgShowEXIF; |
|
81 | ||
82 | if ( $wgShowEXIF ) { |
|
83 | try { |
|
84 | $meta = BitmapMetadataHandler::Tiff( $filename ); |
|
85 | if ( !is_array( $meta ) ) { |
|
86 | // This should never happen, but doesn't hurt to be paranoid. |
|
87 | throw new MWException( 'Metadata array is not an array' ); |
|
88 | } |
|
89 | $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version(); |
|
90 | ||
91 | return serialize( $meta ); |
|
92 | } catch ( Exception $e ) { |
|
93 | // BitmapMetadataHandler throws an exception in certain exceptional |
|
94 | // cases like if file does not exist. |
|
95 | wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" ); |
|
96 | ||
97 | return ExifBitmapHandler::BROKEN_FILE; |
|
98 | } |
|
99 | } else { |
|
100 | return ''; |
|
101 | } |
|
102 | } |
|
103 | ||
104 | public function isExpensiveToThumbnail( $file ) { |