private void validateIfdCT(IFD ifd, int p) {
    IfdTags metadata = ifd.getMetadata();

    boolean rgb =
        metadata.containsTagId(TiffTags.getTagId("PhotometricInterpretation"))
            && metadata.get(TiffTags.getTagId("PhotometricInterpretation")).getFirstNumericValue() == 2;
    boolean lab =
        metadata.containsTagId(TiffTags.getTagId("PhotometricInterpretation"))
            && metadata.get(TiffTags.getTagId("PhotometricInterpretation")).getFirstNumericValue() == 8;
    int spp = -1;
    if (metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
      spp = (int) metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
    }
    int planar = 1;
    if (metadata.containsTagId(TiffTags.getTagId("PlanarConfiguration"))) {
      planar = (int) metadata.get(TiffTags.getTagId("PlanarConfiguration")).getFirstNumericValue();
    }
    int rps = -1;
    if (metadata.containsTagId(TiffTags.getTagId("RowsPerStrip"))) {
      rps = (int) metadata.get(TiffTags.getTagId("RowsPerStrip")).getFirstNumericValue();
    }
    int length = -1;
    if (metadata.containsTagId(TiffTags.getTagId("ImageLength"))) {
      length = (int) metadata.get(TiffTags.getTagId("ImageLength")).getFirstNumericValue();
    }
    int spi = Math.floorDiv(length + rps - 1, rps);

    if (lab) {

    } else {
      if (p == 1 || p == 2) {
        checkRequiredTag(metadata, "NewSubfileType", 1, new long[]{0});
      }
    }
    checkRequiredTag(metadata, "ImageLength", 1);
    checkRequiredTag(metadata, "ImageWidth", 1);
    checkRequiredTag(metadata, "BitsPerSample", spp);
    if (rgb || lab) {
      checkRequiredTag(metadata, "BitsPerSample", 3, new long[]{8, 16});
    } else {
      if (p == 0) {
        checkRequiredTag(metadata, "BitsPerSample", spp, new long[]{8, 16});
      } else {
        checkRequiredTag(metadata, "BitsPerSample", spp, new long[]{8});
      }
    }
    if (p == 2 || rgb || lab) {
      checkRequiredTag(metadata, "Compression", 1, new long[]{1,7,8});
    } else if (p == 1) {
      checkRequiredTag(metadata, "Compression", 1, new long[]{1});
    }
    if (p == 0) {
      checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {2, 5, 6, 8});
      if (metadata.containsTagId(TiffTags.getTagId("PhotometricInterpretation"))
          && metadata.get(TiffTags.getTagId("PhotometricInterpretation")).getFirstNumericValue() == 6
          &&
          metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue() != 7) {
        validation.addErrorLoc("YCbCr shall be used only when compression has the value 7", "IFD"
            + currentIfd);
      }
    } else if (p == 1 || p == 2) {
      checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {5});
    }
    if (planar == 1 || planar == 32768) {
      checkRequiredTag(metadata, "StripOffsets", spi);
    } else if (planar == 2) {
      checkRequiredTag(metadata, "StripOffsets", spp * spi);
    }
    if (rgb || lab) {
    } else if (p == 1 || p == 2) {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1});
    }
    if (rgb || lab) {
      checkRequiredTag(metadata, "SamplesPerPixel", 1, new long[]{3});
    } else {
      if (p == 0) {
        checkRequiredTag(metadata, "SamplesPerPixel", 1);
      } else if (p == 1 || p == 2) {
        checkRequiredTag(metadata, "SamplesPerPixel", 1, new long[]{4});
      }
    }
    if (p == 1 || p == 2 || rgb || lab) {
      if (planar == 1 || planar == 32768) {
        checkRequiredTag(metadata, "StripBYTECount", spi);
      } else if (planar == 2) {
        checkRequiredTag(metadata, "StripBYTECount", spp * spi);
      }
      checkRequiredTag(metadata, "XResolution", 1);
      checkRequiredTag(metadata, "YResolution", 1);
    }
    if (p == 0 || rgb || lab) {
      checkRequiredTag(metadata, "PlanarConfiguration", 1, new long[]{1,2,32768});
    } else if (p == 1 || p == 2) {
      checkRequiredTag(metadata, "PlanarConfiguration", 1, new long[]{1});
    }
    if (rgb || lab) {

    } else {
      if (p == 1 || p == 2) {
        checkRequiredTag(metadata, "ResolutionUnit", 1, new long[]{2, 3});
        checkRequiredTag(metadata, "InkSet", 1, new long[]{1});
        checkRequiredTag(metadata, "NumberOfInks", 1, new long[]{4});
        checkRequiredTag(metadata, "DotRange", 2, new long[]{0, 255});
      }
    }
  }
private void validateIfdCT ( IFD ifd , int p ) { IfdTags metadata = ifd . getMetadata ( ) ; boolean rgb = metadata . containsTagId ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) && metadata . get ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) . getFirstNumericValue ( ) == 2 ; boolean lab = metadata . containsTagId ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) && metadata . get ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) . getFirstNumericValue ( ) == 8 ; int spp = - 1 ; if ( metadata . containsTagId ( TiffTags . getTagId ( "SamplesPerPixel" ) ) ) { spp = ( int ) metadata . get ( TiffTags . getTagId ( "SamplesPerPixel" ) ) . getFirstNumericValue ( ) ; } int planar = 1 ; if ( metadata . containsTagId ( TiffTags . getTagId ( "PlanarConfiguration" ) ) ) { planar = ( int ) metadata . get ( TiffTags . getTagId ( "PlanarConfiguration" ) ) . getFirstNumericValue ( ) ; } int rps = - 1 ; if ( metadata . containsTagId ( TiffTags . getTagId ( "RowsPerStrip" ) ) ) { rps = ( int ) metadata . get ( TiffTags . getTagId ( "RowsPerStrip" ) ) . getFirstNumericValue ( ) ; } int length = - 1 ; if ( metadata . containsTagId ( TiffTags . getTagId ( "ImageLength" ) ) ) { length = ( int ) metadata . get ( TiffTags . getTagId ( "ImageLength" ) ) . getFirstNumericValue ( ) ; } int spi = Math . floorDiv ( length + rps - 1 , rps ) ; if ( lab ) { } else { if ( p == 1 || p == 2 ) { checkRequiredTag ( metadata , "NewSubfileType" , 1 , new long [ ] { 0 } ) ; } } checkRequiredTag ( metadata , "ImageLength" , 1 ) ; checkRequiredTag ( metadata , "ImageWidth" , 1 ) ; checkRequiredTag ( metadata , "BitsPerSample" , spp ) ; if ( rgb || lab ) { checkRequiredTag ( metadata , "BitsPerSample" , 3 , new long [ ] { 8 , 16 } ) ; } else { if ( p == 0 ) { checkRequiredTag ( metadata , "BitsPerSample" , spp , new long [ ] { 8 , 16 } ) ; } else { checkRequiredTag ( metadata , "BitsPerSample" , spp , new long [ ] { 8 } ) ; } } if ( p == 2 || rgb || lab ) { checkRequiredTag ( metadata , "Compression" , 1 , new long [ ] { 1 , 7 , 8 } ) ; } else if ( p == 1 ) { checkRequiredTag ( metadata , "Compression" , 1 , new long [ ] { 1 } ) ; } if ( p == 0 ) { checkRequiredTag ( metadata , "PhotometricInterpretation" , 1 , new long [ ] { 2 , 5 , 6 , 8 } ) ; if ( metadata . containsTagId ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) && metadata . get ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) . getFirstNumericValue ( ) == 6 && metadata . get ( TiffTags . getTagId ( "Compression" ) ) . getFirstNumericValue ( ) != 7 ) { validation . addErrorLoc ( "YCbCr shall be used only when compression has the value 7" , "IFD" + currentIfd ) ; } } else if ( p == 1 || p == 2 ) { checkRequiredTag ( metadata , "PhotometricInterpretation" , 1 , new long [ ] { 5 } ) ; } if ( planar == 1 || planar == 32768 ) { checkRequiredTag ( metadata , "StripOffsets" , spi ) ; } else if ( planar == 2 ) { checkRequiredTag ( metadata , "StripOffsets" , spp * spi ) ; } if ( rgb || lab ) { } else if ( p == 1 || p == 2 ) { checkRequiredTag ( metadata , "Orientation" , 1 , new long [ ] { 1 } ) ; } if ( rgb || lab ) { checkRequiredTag ( metadata , "SamplesPerPixel" , 1 , new long [ ] { 3 } ) ; } else { if ( p == 0 ) { checkRequiredTag ( metadata , "SamplesPerPixel" , 1 ) ; } else if ( p == 1 || p == 2 ) { checkRequiredTag ( metadata , "SamplesPerPixel" , 1 , new long [ ] { 4 } ) ; } } if ( p == 1 || p == 2 || rgb || lab ) { if ( planar == 1 || planar == 32768 ) { checkRequiredTag ( metadata , "StripBYTECount" , spi ) ; } else if ( planar == 2 ) { checkRequiredTag ( metadata , "StripBYTECount" , spp * spi ) ; } checkRequiredTag ( metadata , "XResolution" , 1 ) ; checkRequiredTag ( metadata , "YResolution" , 1 ) ; } if ( p == 0 || rgb || lab ) { checkRequiredTag ( metadata , "PlanarConfiguration" , 1 , new long [ ] { 1 , 2 , 32768 } ) ; } else if ( p == 1 || p == 2 ) { checkRequiredTag ( metadata , "PlanarConfiguration" , 1 , new long [ ] { 1 } ) ; } if ( rgb || lab ) { } else { if ( p == 1 || p == 2 ) { checkRequiredTag ( metadata , "ResolutionUnit" , 1 , new long [ ] { 2 , 3 } ) ; checkRequiredTag ( metadata , "InkSet" , 1 , new long [ ] { 1 } ) ; checkRequiredTag ( metadata , "NumberOfInks" , 1 , new long [ ] { 4 } ) ; checkRequiredTag ( metadata , "DotRange" , 2 , new long [ ] { 0 , 255 } ) ; } } }
Validate Continuous Tone.

@param ifd the ifd
@param p the profile (default = 0, P1 = 1, P2 = 2)