MediaWiki  REL1_20
Jpeg.php
Go to the documentation of this file.
00001 <?php
00033 class JpegHandler extends ExifBitmapHandler {
00034 
00035         function getMetadata ( $image, $filename ) {
00036                 try {
00037                         $meta = BitmapMetadataHandler::Jpeg( $filename );
00038                         if ( !is_array( $meta ) ) {
00039                                 // This should never happen, but doesn't hurt to be paranoid.
00040                                 throw new MWException('Metadata array is not an array');
00041                         }
00042                         $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
00043                         return serialize( $meta );
00044                 }
00045                 catch ( MWException $e ) {
00046                         // BitmapMetadataHandler throws an exception in certain exceptional cases like if file does not exist.
00047                         wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
00048 
00049                         /* This used to use 0 (ExifBitmapHandler::OLD_BROKEN_FILE) for the cases
00050                          *      * No metadata in the file
00051                          *      * Something is broken in the file.
00052                          * However, if the metadata support gets expanded then you can't tell if the 0 is from
00053                          * a broken file, or just no props found. A broken file is likely to stay broken, but
00054                          * a file which had no props could have props once the metadata support is improved.
00055                          * Thus switch to using -1 to denote only a broken file, and use an array with only
00056                          * MEDIAWIKI_EXIF_VERSION to denote no props.
00057                          */
00058                         return ExifBitmapHandler::BROKEN_FILE;
00059                 }
00060         }
00061 
00062 }
00063