Skip to content

Commit

Permalink
TIKA-2630 -- add defensive null check and fix "if (...width)" to "if …
Browse files Browse the repository at this point in the history
…(...height)"
  • Loading branch information
tballison committed Dec 3, 2019
1 parent 6045e48 commit 8c0d7fe
Showing 1 changed file with 12 additions and 5 deletions.
Expand Up @@ -504,12 +504,19 @@ public void handlePhotoTags(Directory directory, Metadata metadata) {

// For Compressed Images read from ExifSubIFDDirectory
if (directory.containsTag(ExifSubIFDDirectory.TAG_EXIF_IMAGE_WIDTH)) {
metadata.set(Metadata.IMAGE_WIDTH,
trimPixels(directory.getDescription(ExifSubIFDDirectory.TAG_EXIF_IMAGE_WIDTH)));
String width = directory.getDescription(ExifSubIFDDirectory.TAG_EXIF_IMAGE_WIDTH);
//check for null because this could overwrite earlier set width if the value is null
if (width != null) {
metadata.set(Metadata.IMAGE_WIDTH,
trimPixels(width));
}
}
if (directory.containsTag(ExifSubIFDDirectory.TAG_EXIF_IMAGE_WIDTH)) {
metadata.set(Metadata.IMAGE_LENGTH,
trimPixels(directory.getDescription(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT)));

if (directory.containsTag(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT)) {
String height = directory.getDescription(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT);
if (height != null) {
metadata.set(Metadata.IMAGE_LENGTH, trimPixels(height));
}
}

}
Expand Down

0 comments on commit 8c0d7fe

Please sign in to comment.