/** Main entry point for jpeg's.
  *
  * @param string $filename filename (with full path)
  * @return array metadata result array.
  * @throws MWException on invalid file.
  */
 static function Jpeg($filename)
 {
     $showXMP = function_exists('xml_parser_create_ns');
     $meta = new self();
     $seg = JpegMetadataExtractor::segmentSplitter($filename);
     if (isset($seg['COM']) && isset($seg['COM'][0])) {
         $meta->addMetadata(array('JPEGFileComment' => $seg['COM']), 'native');
     }
     if (isset($seg['PSIR']) && count($seg['PSIR']) > 0) {
         foreach ($seg['PSIR'] as $curPSIRValue) {
             $meta->doApp13($curPSIRValue);
         }
     }
     if (isset($seg['XMP']) && $showXMP) {
         $xmp = new XMPReader();
         $xmp->parse($seg['XMP']);
         foreach ($seg['XMP_ext'] as $xmpExt) {
             /* Support for extended xmp in jpeg files
              * is not well tested and a bit fragile.
              */
             $xmp->parseExtended($xmpExt);
         }
         $res = $xmp->getResults();
         foreach ($res as $type => $array) {
             $meta->addMetadata($array, $type);
         }
     }
     if (isset($seg['byteOrder'])) {
         $meta->getExif($filename, $seg['byteOrder']);
     }
     return $meta->getMetadataArray();
 }