Skip to content

Commit

Permalink
Fixes in implementation checker
Browse files Browse the repository at this point in the history
  • Loading branch information
victormunoz committed Jul 28, 2017
1 parent 01dc58a commit 6e75d1f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.easyinnova</groupId>
<artifactId>tiffimplementationchecker</artifactId>
<version>1.2.5</version>
<version>1.2.6</version>

<packaging>jar</packaging>
<name>Tiff Implementation Checker</name>
Expand Down Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>com.easyinnova</groupId>
<artifactId>tifflibrary4java</artifactId>
<version>1.9.5</version>
<version>1.9.6</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,10 @@ public TiffTag CreateTiffTag(TagValue tv, int parentIfd, long fileSize) {
if (tv.getId() > 32767) tt.setPrivateTag("private");
tt.setName(tv.getName());
tt.setCardinality(tv.getCardinality());
tt.setType(com.easyinnova.tiff.model.TiffTags.getTagTypeName(tv.getType()));
if (com.easyinnova.tiff.model.TiffTags.getTagTypeName(tv.getType()) != null)
tt.setType(com.easyinnova.tiff.model.TiffTags.getTagTypeName(tv.getType()));
else
tt.setType("Unknown");
try {
if (tt.getType().equals("ASCII")) {
boolean ascii7ok = true;
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/com/easyinnova/implementation_checker/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,20 @@ boolean checkRule(RuleType rule, TiffNode node) {
value = Double.parseDouble(value.split("/")[0]) / Double.parseDouble(value.split("/")[1]) + "";
if (value2.contains("/"))
value2 = Double.parseDouble(value2.split("/")[0]) / Double.parseDouble(value2.split("/")[1]) + "";
if (operation.equals("==")) ok = value.equals(value2);
else if (operation.equals("!="))
ok = !value.equals(value2);
if (operation.equals("==")) {
try {
ok = Double.parseDouble(value) == Double.parseDouble(value2);
} catch (Exception ex) {
ok = value.equals(value2);
}
}
else if (operation.equals("!=")) {
try {
ok = Double.parseDouble(value) != Double.parseDouble(value2);
} catch (Exception ex) {
ok = !value.equals(value2);
}
}
else if (operation.equals(">")) {
try {
ok = Double.parseDouble(value) > Double.parseDouble(value2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
9 = ICC L*a*b*.
10 = ITU L*a*b*.</description>
<reference><document>Extended TIFF 6</document><section>Section 8: Baseline Field Reference Guide</section><page>37</page></reference>
<assert test="{tags.tag[name=PhotometricInterpretation] &gt; -1} &amp;&amp; {tags.tag[name=PhotometricInterpretation] &lt; 11}">Photometric Interpretation value must be between 0 and 10</assert>
<assert test="{tags.tag[name=PhotometricInterpretation] &gt; -1} &amp;&amp; {tags.tag[name=PhotometricInterpretation] &lt; 11} &amp;&amp; {tags.tag[name=PhotometricInterpretation] != 7}">Photometric Interpretation value must be between 0 and 10</assert>
</rule>
</rules>

Expand Down Expand Up @@ -301,11 +301,11 @@
<assert test="{cardinality==2}">PageNumber cardinality is not valid, cardinality should be 2</assert>
</rule>

<rule id="TAG-297-0003" context="ifd[class=image]" level="warning" experimental="true">
<rule id="TAG-297-0003" context="ifd[class=image]" level="warning">
<title>PageNumber out of the document</title>
<description>PageNumber value must be less than the total number of pages in the document</description>
<reference><document>Extended TIFF 6</document><section>Section 12: Document Storage and Retrieval</section><page>55</page></reference>
<assert test="{tags.tag[name=PageNumber](0) &lt; tags.tag[name=PageNumber](1)}">Incoherent page number</assert>
<assert test="{tags.tag[name=PageNumber](0) &gt; tags.tag[name=PageNumber](1)}">Incoherent page number</assert>
</rule>

<rule id="TAG-297-0004" context="tag[id=297]" level="error" experimental="true">
Expand All @@ -329,11 +329,18 @@
<assert test="">There is a missing page in a multiple page (e.g. facsimile) document.</assert>
</rule>

<rule id="TAG-297-0007" context="tag[id=297]" level="warning" experimental="true">
<rule id="TAG-297-0007" context="ifd[class=image]" level="warning">
<title>Incoherent total number of pages</title>
<description>All the images in a multiple page (e.g. facsimile) document should have the same total number of pages</description>
<reference><document>Extended TIFF 6</document><section>Section 12: Document Storage and Retrieval</section><page>55</page></reference>
<assert test="tag[name=PageNumber](1) != TOTALNUMBERPAGES">PageNumber Tag contains and invalid total number of pages</assert>
<assert test="{tags.tag[name=PageNumber](1) != $tiffValidationObject.numberImages$}">PageNumber Tag contains and invalid total number of pages</assert>
</rule>

<rule id="TAG-297-0008" context="ifd[class=image]" level="warning">
<title>PageNumber out of the document</title>
<description>PageNumber value must be less than the total number of pages in the document</description>
<reference><document>Extended TIFF 6</document><section>Section 12: Document Storage and Retrieval</section><page>55</page></reference>
<assert test="{tags.tag[name=PageNumber](0) == tags.tag[name=PageNumber](1)}">Incoherent page number</assert>
</rule>
</rules>

Expand Down Expand Up @@ -487,7 +494,7 @@
<reference><document>Extended TIFF 6</document><section>Section 5: Palette-color Images</section><page>23</page></reference>
<reference><document>Extended TIFF 6</document><section>Section 6: RGB Full Color Images</section><page>23</page></reference>
<reference><document>Extended TIFF 6</document><section>Section 8: Baseline Field Reference Guide</section><page>40</page></reference>
<assert test="{tiles == 1} || {tags.tag[name=StripOffsets]}">Image IFD must have the tag StripOffsets</assert>
<assert test="{tiles == 1} || {strips == 1} &amp;&amp; {tags.tag[name=StripOffsets]}">Image IFD must have the tag StripOffsets</assert>
</rule>

<rule id="STRIPSEXT-0002" context="ifd[class=image]" level="error">
Expand All @@ -498,7 +505,7 @@
<reference><document>Extended TIFF 6</document><section>Section 5: Palette-color Images</section><page>23</page></reference>
<reference><document>Extended TIFF 6</document><section>Section 6: RGB Full Color Images</section><page>23</page></reference>
<reference><document>Extended TIFF 6</document><section>Section 8: Baseline Field Reference Guide</section><page>19</page></reference>
<assert test="{tiles == 1} || {tags.tag[name=StripBYTECount]}">Image IFD must have the tag StripBYTECount</assert>
<assert test="{tiles == 1} || {strips == 1} &amp;&amp; {tags.tag[name=StripBYTECount]}">Image IFD must have the tag StripBYTECount</assert>
</rule>

<rule id="TILES-0001" context="ifd[class=image]" level="error">
Expand All @@ -508,7 +515,7 @@
Use of tiles will therefore cause older TIFF readers to give up because they will have no way of knowing where the image data is or how it is organized.
Do not use both strip-oriented and tile-oriented fields in the same TIFF file.</description>
<reference><document>Extended TIFF 6</document><section>Section 15: Tiled Images</section><page>66</page></reference>
<assert test="{strips == 0} || {tiles == 0}">Image must be in either Strips or Tiles</assert>
<assert test="{strips == 1} || {tiles == 1}">Image must be in either Strips or Tiles</assert>
</rule>

<rule id="TILES-0002" context="ifd[class=image]" level="error">
Expand All @@ -518,7 +525,7 @@
Use of tiles will therefore cause older TIFF readers to give up because they will have no way of knowing where the image data is or how it is organized.
Do not use both strip-oriented and tile-oriented fields in the same TIFF file.</description>
<reference><document>Extended TIFF 6</document><section>Section 15: Tiled Images</section><page>66</page></reference>
<assert test="{strips == 1} || {tiles == 1}">Image cannot be in both Strips and Tiles</assert>
<assert test="{strips == 0} || {tiles == 0}">Image cannot be in both Strips and Tiles</assert>
</rule>

<rule id="TILES-0003" context="ifd[tiles=1]" level="error">
Expand All @@ -532,28 +539,28 @@
<title>TileOffsets required for tiled images</title>
<description>TileOffsets is required in an Image File Directory(IDF) containing an image organized in tiles</description>
<reference><document>Extended TIFF 6</document><section>Section 15: Tiled Images</section><page>68</page></reference>
<assert test="{strips == 1} || {tags.tag[name=TileOffsets]}">Missing required TileOffsets tag for tiled images</assert>
<assert test="{strips == 1} || {tiles == 1} &amp;&amp; {tags.tag[name=TileOffsets]}">Missing required TileOffsets tag for tiled images</assert>
</rule>

<rule id="TILES-0005" context="ifd[tiles=1]" level="error">
<title>TileByteCounts required for tiled images</title>
<description>TileByteCounts is required in an Image File Directory(IDF) containing an image organized in tiles</description>
<reference><document>Extended TIFF 6</document><section>Section 15: Tiled Images</section><page>68</page></reference>
<assert test="{strips == 1} || {tags.tag[name=TileBYTECounts]}">Missing required TileByteCounts tag for tiled images</assert>
<assert test="{strips == 1} || {tiles == 1} &amp;&amp; {tags.tag[name=TileBYTECounts]}">Missing required TileByteCounts tag for tiled images</assert>
</rule>

<rule id="TILES-0006" context="ifd[tiles=1]" level="error">
<title>TileWidth required for tiled images</title>
<description>TileWidth is required in an Image File Directory(IDF) containing an image organized in tiles</description>
<reference><document>Extended TIFF 6</document><section>Section 15: Tiled Images</section><page>67</page></reference>
<assert test="{strips == 1} || {tags.tag[name=TileWidth]}">Missing required TileOffsets tag for tiled images</assert>
<assert test="{strips == 1} || {tiles == 1} &amp;&amp; {tags.tag[name=TileWidth]}">Missing required TileOffsets tag for tiled images</assert>
</rule>

<rule id="TILES-0007" context="ifd[tiles=1]" level="error">
<title>TileLength required for tiled images</title>
<description>TileLength is required in an Image File Directory(IDF) containing an image organized in tiles</description>
<reference><document>Extended TIFF 6</document><section>Section 15: Tiled Images</section><page>67</page></reference>
<assert test="{strips == 1} || {tags.tag[name=TileLength]}">Missing required TileLength tag for tiled images</assert>
<assert test="{strips == 1} || {tiles == 1} &amp;&amp; {tags.tag[name=TileLength]}">Missing required TileLength tag for tiled images</assert>
</rule>

<rule id="TILES-0008" context="ifd[tiles=1]" level="error">
Expand Down

0 comments on commit 6e75d1f

Please sign in to comment.