public byte[] getExifThumbnailData() {
        if (exif == null) {
            return null;
        }
        final List<? extends ImageMetadataItem> dirs = exif.getDirectories();
        for (final ImageMetadataItem d : dirs) {
            final TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) d;

            byte[] data = null;
            if (dir.getJpegImageData() != null) {
                data = dir.getJpegImageData().getData();
            }
            // Support other image formats here.

            if (data != null) {
                // already cloned, safe to return this copy
                return data;
            }
        }
        return null;
    }
Returns the data of the first JPEG thumbnail found in the EXIF metadata.

@return JPEG data or null if no thumbnail.
src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java