| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
package com.drew.metadata.jpeg; |
| 22 |
|
| 23 |
import com.drew.imaging.jpeg.JpegSegmentMetadataReader; |
| 24 |
import com.drew.imaging.jpeg.JpegSegmentType; |
| 25 |
import com.drew.lang.annotations.NotNull; |
| 26 |
import com.drew.metadata.Metadata; |
| 27 |
import com.drew.metadata.StringValue; |
| 28 |
|
| 29 |
import java.util.Collections; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class JpegCommentReader implements JpegSegmentMetadataReader |
| 38 |
{ |
| 39 |
@NotNull |
| 40 |
public Iterable<JpegSegmentType> getSegmentTypes() |
| 41 |
{ |
| 42 |
return Collections.singletonList(JpegSegmentType.COM); |
| 43 |
} |
| 44 |
|
| 45 |
public void readJpegSegments(@NotNull Iterable<byte[]> segments, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType) |
| 46 |
{ |
| 47 |
for (byte[] segmentBytes : segments) { |
| 48 |
JpegCommentDirectory directory = new JpegCommentDirectory(); |
| 49 |
metadata.addDirectory(directory); |
| 50 |
|
| 51 |
|
| 52 |
directory.setStringValue(JpegCommentDirectory.TAG_COMMENT, new StringValue(segmentBytes, null)); |
| 53 |
} |
| 54 |
} |
| 55 |
} |