code: private void CheckPalleteImage(IfdTags metadata, int nifd) {
      // Color Map
      if (!metadata.containsTagId(TiffTags.getTagId("ColorMap"))) {
        validation.addErrorLoc("Missing Color Map", "IFD" + nifd);
      } else {
        int n = metadata.get(TiffTags.getTagId("ColorMap")).getCardinality();
        if (n != 3 * (int) Math.pow(2, metadata.get(TiffTags.getTagId("BitsPerSample"))
            .getFirstNumericValue()))
          validation.addError("Incorrect Color Map Cardinality", "IFD" + nifd, metadata.get(320)
              .getCardinality());
      }
  
      // Bits per Sample
      long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
      if (bps != 4 && bps != 8)
        validation.addError("Invalid Bits per Sample", "IFD" + nifd, bps);
  
      // Compression
      long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
      // if (comp != 1 && comp != 32773)
      if (comp < 1)
        validation.addError("Invalid Compression", "IFD" + nifd, comp);
    }
docs: Check Pallete Color Image.
  
  @param metadata the metadata
  @param nifd the IFD number