public void handlePhotoTags(Directory directory, Metadata metadata) {
            if (directory.containsTag(ExifSubIFDDirectory.TAG_EXPOSURE_TIME)) {
                Object exposure = directory.getObject(ExifSubIFDDirectory.TAG_EXPOSURE_TIME);
                if (exposure instanceof Rational) {
                    metadata.set(Metadata.EXPOSURE_TIME, ((Rational) exposure).doubleValue());
                } else {
                    metadata.set(Metadata.EXPOSURE_TIME,
                            directory.getString(ExifSubIFDDirectory.TAG_EXPOSURE_TIME));
                }
            }

            if (directory.containsTag(ExifSubIFDDirectory.TAG_FLASH)) {
                String flash = directory.getDescription(ExifSubIFDDirectory.TAG_FLASH);
                if (flash != null) {
                    if (flash.contains("Flash fired")) {
                        metadata.set(Metadata.FLASH_FIRED, Boolean.TRUE.toString());
                    } else if (flash.contains("Flash did not fire")) {
                        metadata.set(Metadata.FLASH_FIRED, Boolean.FALSE.toString());
                    } else {
                        metadata.set(Metadata.FLASH_FIRED, flash);
                    }
                }
            }

            if (directory.containsTag(ExifSubIFDDirectory.TAG_FNUMBER)) {
                Object fnumber = directory.getObject(ExifSubIFDDirectory.TAG_FNUMBER);
                if (fnumber instanceof Rational) {
                    metadata.set(Metadata.F_NUMBER, ((Rational) fnumber).doubleValue());
                } else {
                    metadata.set(Metadata.F_NUMBER,
                            directory.getString(ExifSubIFDDirectory.TAG_FNUMBER));
                }
            }

            if (directory.containsTag(ExifSubIFDDirectory.TAG_FOCAL_LENGTH)) {
                Object length = directory.getObject(ExifSubIFDDirectory.TAG_FOCAL_LENGTH);
                if (length instanceof Rational) {
                    metadata.set(Metadata.FOCAL_LENGTH, ((Rational) length).doubleValue());
                } else {
                    metadata.set(Metadata.FOCAL_LENGTH,
                            directory.getString(ExifSubIFDDirectory.TAG_FOCAL_LENGTH));
                }
            }

            if (directory.containsTag(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT)) {
                metadata.set(Metadata.ISO_SPEED_RATINGS,
                        directory.getString(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT));
            }

            if (directory.containsTag(ExifIFD0Directory.TAG_MAKE)) {
                metadata.set(Metadata.EQUIPMENT_MAKE,
                        directory.getString(ExifIFD0Directory.TAG_MAKE));
            }
            if (directory.containsTag(ExifIFD0Directory.TAG_MODEL)) {
                metadata.set(Metadata.EQUIPMENT_MODEL,
                        directory.getString(ExifIFD0Directory.TAG_MODEL));
            }

            if (directory.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
                Object length = directory.getObject(ExifIFD0Directory.TAG_ORIENTATION);
                if (length instanceof Integer) {
                    metadata.set(Metadata.ORIENTATION, Integer.toString((Integer) length));
                } else {
                    metadata.set(Metadata.ORIENTATION,
                            directory.getString(ExifIFD0Directory.TAG_ORIENTATION));
                }
            }

            if (directory.containsTag(ExifIFD0Directory.TAG_SOFTWARE)) {
                metadata.set(Metadata.SOFTWARE,
                        directory.getString(ExifIFD0Directory.TAG_SOFTWARE));
            }

            if (directory.containsTag(ExifIFD0Directory.TAG_X_RESOLUTION)) {
                Object resolution = directory.getObject(ExifIFD0Directory.TAG_X_RESOLUTION);
                if (resolution instanceof Rational) {
                    metadata.set(Metadata.RESOLUTION_HORIZONTAL,
                            ((Rational) resolution).doubleValue());
                } else {
                    metadata.set(Metadata.RESOLUTION_HORIZONTAL,
                            directory.getString(ExifIFD0Directory.TAG_X_RESOLUTION));
                }
            }
            if (directory.containsTag(ExifIFD0Directory.TAG_Y_RESOLUTION)) {
                Object resolution = directory.getObject(ExifIFD0Directory.TAG_Y_RESOLUTION);
                if (resolution instanceof Rational) {
                    metadata.set(Metadata.RESOLUTION_VERTICAL,
                            ((Rational) resolution).doubleValue());
                } else {
                    metadata.set(Metadata.RESOLUTION_VERTICAL,
                            directory.getString(ExifIFD0Directory.TAG_Y_RESOLUTION));
                }
            }
            if (directory.containsTag(ExifIFD0Directory.TAG_RESOLUTION_UNIT)) {
                metadata.set(Metadata.RESOLUTION_UNIT,
                        directory.getDescription(ExifIFD0Directory.TAG_RESOLUTION_UNIT));
            }
            if (directory.containsTag(ExifThumbnailDirectory.TAG_IMAGE_WIDTH)) {
                metadata.set(Metadata.IMAGE_WIDTH, trimPixels(
                        directory.getDescription(ExifThumbnailDirectory.TAG_IMAGE_WIDTH)));
            }
            if (directory.containsTag(ExifThumbnailDirectory.TAG_IMAGE_HEIGHT)) {
                metadata.set(Metadata.IMAGE_LENGTH, trimPixels(
                        directory.getDescription(ExifThumbnailDirectory.TAG_IMAGE_HEIGHT)));
            }

            // For Compressed Images read from ExifSubIFDDirectory
            if (directory.containsTag(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_HEIGHT)) {
                String height = directory.getDescription(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT);
                if (height != null) {
                    metadata.set(Metadata.IMAGE_LENGTH, trimPixels(height));
                }
            }

        }
Maps common TIFF and EXIF tags onto the Tika
TIFF image metadata namespace.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-image-module/src/main/java/org/apache/tika/parser/image/ImageMetadataExtractor.java