mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-02 19:15:29 -04:00
TMI-JPEG-4: Clean up
This commit is contained in:
parent
ca48837e11
commit
d7958fc8a7
@ -32,13 +32,14 @@ final class JPEGImage10MetadataCleaner {
|
|||||||
|
|
||||||
private final JPEGImageReader reader;
|
private final JPEGImageReader reader;
|
||||||
|
|
||||||
JPEGImage10MetadataCleaner(JPEGImageReader reader) {
|
JPEGImage10MetadataCleaner(final JPEGImageReader reader) {
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
IIOMetadata cleanMetadata(final int imageIndex, final IIOMetadata imageMetadata, final List<JPEGSegment> appSegments) throws IOException {
|
IIOMetadata cleanMetadata(final IIOMetadata imageMetadata) throws IOException {
|
||||||
// We filter out pretty much everything from the stream..
|
// We filter out pretty much everything from the stream..
|
||||||
// Meaning we have to read get *all APP segments* and re-insert into metadata.
|
// Meaning we have to read get *all APP segments* and re-insert into metadata.
|
||||||
|
List<JPEGSegment> appSegments = reader.getAppSegments(JPEGImageReader.ALL_APP_MARKERS, null);
|
||||||
|
|
||||||
// NOTE: There's a bug in the merging code in JPEGMetadata mergeUnknownNode that makes sure all "unknown" nodes are added twice in certain conditions.... ARGHBL...
|
// NOTE: There's a bug in the merging code in JPEGMetadata mergeUnknownNode that makes sure all "unknown" nodes are added twice in certain conditions.... ARGHBL...
|
||||||
// DONE: 1: Work around
|
// DONE: 1: Work around
|
||||||
@ -109,7 +110,7 @@ final class JPEGImage10MetadataCleaner {
|
|||||||
IIOMetadataNode app0JFXX = new IIOMetadataNode("app0JFXX");
|
IIOMetadataNode app0JFXX = new IIOMetadataNode("app0JFXX");
|
||||||
app0JFXX.setAttribute("extensionCode", String.valueOf(jfxxSegment.extensionCode));
|
app0JFXX.setAttribute("extensionCode", String.valueOf(jfxxSegment.extensionCode));
|
||||||
|
|
||||||
JFXXThumbnailReader thumbnailReader = new JFXXThumbnailReader(null, reader.getThumbnailReader(), imageIndex, -1, jfxxSegment);
|
JFXXThumbnailReader thumbnailReader = new JFXXThumbnailReader(null, reader.getThumbnailReader(), 0, 0, jfxxSegment);
|
||||||
IIOMetadataNode jfifThumb;
|
IIOMetadataNode jfifThumb;
|
||||||
|
|
||||||
switch (jfxxSegment.extensionCode) {
|
switch (jfxxSegment.extensionCode) {
|
||||||
|
@ -102,7 +102,7 @@ public class JPEGImageReader extends ImageReaderBase {
|
|||||||
final static boolean DEBUG = "true".equalsIgnoreCase(System.getProperty("com.twelvemonkeys.imageio.plugins.jpeg.debug"));
|
final static boolean DEBUG = "true".equalsIgnoreCase(System.getProperty("com.twelvemonkeys.imageio.plugins.jpeg.debug"));
|
||||||
|
|
||||||
/** Internal constant for referring all APP segments */
|
/** Internal constant for referring all APP segments */
|
||||||
private static final int ALL_APP_MARKERS = -1;
|
static final int ALL_APP_MARKERS = -1;
|
||||||
|
|
||||||
/** Segment identifiers for the JPEG segments we care about reading. */
|
/** Segment identifiers for the JPEG segments we care about reading. */
|
||||||
private static final Map<Integer, List<String>> SEGMENT_IDENTIFIERS = createSegmentIds();
|
private static final Map<Integer, List<String>> SEGMENT_IDENTIFIERS = createSegmentIds();
|
||||||
@ -683,7 +683,7 @@ public class JPEGImageReader extends ImageReaderBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<JPEGSegment> getAppSegments(final int marker, final String identifier) throws IOException {
|
List<JPEGSegment> getAppSegments(final int marker, final String identifier) throws IOException {
|
||||||
initHeader();
|
initHeader();
|
||||||
|
|
||||||
List<JPEGSegment> appSegments = Collections.emptyList();
|
List<JPEGSegment> appSegments = Collections.emptyList();
|
||||||
@ -1036,9 +1036,7 @@ public class JPEGImageReader extends ImageReaderBase {
|
|||||||
metadataCleaner = new JPEGImage10MetadataCleaner(this);
|
metadataCleaner = new JPEGImage10MetadataCleaner(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<JPEGSegment> appSegments = getAppSegments(JPEGImageReader.ALL_APP_MARKERS, null);
|
return metadataCleaner.cleanMetadata(imageMetadata);
|
||||||
|
|
||||||
return metadataCleaner.cleanMetadata(imageIndex, imageMetadata, appSegments);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageMetadata;
|
return imageMetadata;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user