Skip to content

Commit 587e4ae

Browse files
committed
TIKA-2447 Inspired by the patch from Jan Burkhardt, do not bother fetching+keeping data from PSD sections we ignore
1 parent 2c54f93 commit 587e4ae

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

‎tika-parsers/src/main/java/org/apache/tika/parser/image/PSDParser.java‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,29 @@ private ResourceBlock(InputStream stream) throws IOException, TikaException {
188188
}
189189
totalLength = 4 + 2 + nameLen + 4 + dataLen;
190190

191-
data = new byte[dataLen];
192-
IOUtils.readFully(stream, data);
191+
// Do we have use for the data segment?
192+
if (captureData(id)) {
193+
data = new byte[dataLen];
194+
IOUtils.readFully(stream, data);
195+
} else {
196+
data = new byte[0];
197+
IOUtils.skipFully(stream, dataLen);
198+
}
199+
}
200+
201+
/**
202+
* To save memory, only capture the data
203+
* section of resource blocks we process
204+
*/
205+
private static boolean captureData(int id) {
206+
switch (id) {
207+
case ID_CAPTION:
208+
case ID_EXIF_1:
209+
case ID_EXIF_3:
210+
case ID_XMP:
211+
return true;
212+
}
213+
return false;
193214
}
194215

195216
private String getDataAsString() {

0 commit comments

Comments
 (0)