@@ -95,6 +95,8 @@ pub enum AppData {
9595 Avi1 ,
9696 Icc ( IccChunk ) ,
9797 Exif ( Vec < u8 > ) ,
98+ Xmp ( Vec < u8 > ) ,
99+ Psir ( Vec < u8 > ) ,
98100}
99101
100102// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe
@@ -621,21 +623,20 @@ pub fn parse_app<R: Read>(reader: &mut R, marker: Marker) -> Result<Option<AppDa
621623 }
622624 }
623625 }
624- // Exif Data
625626 APP ( 1 ) => {
626- if length >= 6 {
627- let mut buffer = [ 0u8 ; 6 ] ;
628- reader . read_exact ( & mut buffer ) ? ;
629- bytes_read = buffer . len ( ) ;
630-
631- // https://web.archive.org/web/20190624045241if_/http://www.cipa.jp:80/std/documents/e/DC-008-Translation-2019-E.pdf
632- // 4.5.4 Basic Structure of JPEG Compressed Data
633- if buffer == * b" Exif\x00 \x00 " {
634- let mut data = vec ! [ 0 ; length - bytes_read ] ;
635- reader . read_exact ( & mut data ) ? ;
636- bytes_read += data . len ( ) ;
637- result = Some ( AppData :: Exif ( data ) ) ;
638- }
627+ let mut buffer = vec ! [ 0u8 ; length ] ;
628+ reader . read_exact ( & mut buffer) ? ;
629+ bytes_read = buffer . len ( ) ;
630+
631+ // https://web.archive.org/web/20190624045241if_/http://www.cipa.jp:80/std/documents/e/DC-008-Translation-2019-E.pdf
632+ // 4.5.4 Basic Structure of JPEG Compressed Data
633+ if length >= 6 && buffer [ 0 .. 6 ] == * b"Exif \x00 \x00 " {
634+ result = Some ( AppData :: Exif ( buffer [ 6 .. ] . to_vec ( ) ) ) ;
635+ }
636+ // XMP packet
637+ // https://github.com/adobe/XMP-Toolkit-SDK/blob/main/docs/XMPSpecificationPart3.pdf
638+ else if length >= 29 && buffer [ 0 .. 29 ] == * b"http://ns.adobe.com/xap/1.0/ \0 " {
639+ result = Some ( AppData :: Xmp ( buffer [ 29 .. ] . to_vec ( ) ) ) ;
639640 }
640641 }
641642 APP ( 2 ) => {
@@ -658,6 +659,22 @@ pub fn parse_app<R: Read>(reader: &mut R, marker: Marker) -> Result<Option<AppDa
658659 }
659660 }
660661 }
662+ APP ( 13 ) => {
663+ if length >= 14 {
664+ let mut buffer = [ 0u8 ; 14 ] ;
665+ reader. read_exact ( & mut buffer) ?;
666+ bytes_read = buffer. len ( ) ;
667+
668+ // PSIR (Photoshop)
669+ // https://github.com/adobe/XMP-Toolkit-SDK/blob/main/docs/XMPSpecificationPart3.pdf
670+ if buffer[ 0 ..14 ] == * b"Photoshop 3.0\0 " {
671+ let mut data = vec ! [ 0 ; length - bytes_read] ;
672+ reader. read_exact ( & mut data) ?;
673+ bytes_read += data. len ( ) ;
674+ result = Some ( AppData :: Psir ( data) ) ;
675+ }
676+ }
677+ }
661678 APP ( 14 ) => {
662679 if length >= 12 {
663680 let mut buffer = [ 0u8 ; 12 ] ;
0 commit comments