}
// There should never be more than one COM segment.
byte[] comSegment = segmentReader.getSegment(JpegSegmentReader.SEGMENT_COM);
if (comSegment != null)
new JpegCommentReader().extract(new ByteArrayReader(comSegment), metadata);
// Loop through all APP1 segments, checking the leading bytes to identify the format of each.
for (byte[] app1Segment : segmentReader.getSegments(JpegSegmentReader.SEGMENT_APP1)) {
if (app1Segment.length > 3 && "EXIF".equalsIgnoreCase(new String(app1Segment, 0, 4)))
new ExifReader().extract(new ByteArrayReader(app1Segment), metadata);