8 * JPEG specific handler.
9 * Inherits most stuff from BitmapHandler, just here to do the metadata handler differently.
11 * Metadata stuff common to Jpeg and built-in Tiff (not PagedTiffHandler) is
12 * in ExifBitmapHandler.
16 class JpegHandler
extends ExifBitmapHandler
{
18 function getMetadata ( $image, $filename ) {
20 $meta = BitmapMetadataHandler
::Jpeg( $filename );
21 if ( !is_array( $meta ) ) {
22 // This should never happen, but doesn't hurt to be paranoid.
23 throw new MWException('Metadata array is not an array');
25 $meta['MEDIAWIKI_EXIF_VERSION'] = Exif
::version();
26 return serialize( $meta );
28 catch ( MWException
$e ) {
29 // BitmapMetadataHandler throws an exception in certain exceptional cases like if file does not exist.
30 wfDebug( __METHOD__
. ': ' . $e->getMessage() . "\n" );
32 /* This used to use 0 (ExifBitmapHandler::OLD_BROKEN_FILE) for the cases
33 * * No metadata in the file
34 * * Something is broken in the file.
35 * However, if the metadata support gets expanded then you can't tell if the 0 is from
36 * a broken file, or just no props found. A broken file is likely to stay broken, but
37 * a file which had no props could have props once the metadata support is improved.
38 * Thus switch to using -1 to denote only a broken file, and use an array with only
39 * MEDIAWIKI_EXIF_VERSION to denote no props.
41 return ExifBitmapHandler
::BROKEN_FILE
;