Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…y-4J into develop
  • Loading branch information
Adri7 committed May 26, 2017
2 parents 30aeba7 + 79612f3 commit 7f52c24
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/easyinnova/tiff/model/IfdTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public void addTag(String tagName, String tagValue) {
int id = TiffTags.getTagId(tagName);
TagValue tag = new TagValue(id, 2);
for (int i = 0; i < tagValue.length(); i++) {
Ascii cha = new Ascii(tagValue.charAt(i));
int val = tagValue.charAt(i);
if (val > 127) val = 0;
Ascii cha = new Ascii(val);
tag.add(cha);
}
Ascii chaf = new Ascii(0);
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/com/easyinnova/tiff/model/types/SubIFD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* <h1>SubIFD.java</h1>
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version; or, at your choice, under the terms of the
* Mozilla Public License, v. 2.0. SPDX GPL-3.0+ or MPL-2.0+.
* </p>
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License and the Mozilla Public License for more details.
* </p>
* <p>
* You should have received a copy of the GNU General Public License and the Mozilla Public License
* along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a> and at
* <a href="http://mozilla.org/MPL/2.0">http://mozilla.org/MPL/2.0</a> .
* </p>
* <p>
* NB: for the © statement, include Easy Innova SL or other company/Person contributing the code.
* </p>
* <p>
* © 2015 Easy Innova, SL
* </p>
*
* @author Víctor Muñoz Solà
* @version 1.0
* @since 9/6/2015
*
*/
package com.easyinnova.tiff.model.types;


/**
* The Class SubIFD.
*/
public class SubIFD extends IFD {

/**
* Instantiates a new exif ifd.
*/
public SubIFD() {
super(false);
super.setIsIFD(true);
}

@Override
public String toString() {
return super.getMetadata().toString();
}
}

2 changes: 1 addition & 1 deletion src/main/java/com/easyinnova/tiff/reader/TiffReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ protected TagValue getValue(int tagtype, int n, int id, int beginOffset, IFD par

if (ok && TiffTags.hasTag(id)) {
Tag t = TiffTags.getTag(id);
if (t.hasTypedef()) {
if (t.hasTypedef() && !t.getTypedef().equals("SubIFD")) {
String tagclass = t.getTypedef();

try {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/tifftags/Photoshop.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"description": "",
"source": "",
"created": "18/05/2015",
"modified": "18/05/2015"
"modified": "18/05/2015",
"forceDescription": ""
}
2 changes: 1 addition & 1 deletion src/main/resources/tifftags/SubIFDs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"LONG",
"IFD"
],
"typedef": "IFD",
"typedef": "SubIFD",
"cardinality": "N",
"defaultValue": "",
"ifd": "",
Expand Down
22 changes: 11 additions & 11 deletions src/test/java/com/easyinnova/tiff/TiffTagsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ public class TiffTagsTest {
@Test
public void test() {
Tag tag = TiffTags.getTag(259);
assertEquals(tag.getTagValueDescription("5"), "LZW");
assertEquals(tag.getTagValueDescription("unexisting"), null);
assertEquals(tag.getTextDescription("5"), "LZW");
assertEquals(tag.getTextDescription("unexisting"), null);

Tag tag2 = TiffTags.getTag(TiffTags.getTagId("PhotometricInterpretation"));
assertEquals(tag2.getTagValueDescription("2"), "RGB");
assertEquals(tag2.getTagValueDescription("6"), "YCbCr");
assertEquals(tag2.getTagValueDescription("unexisting"), null);
assertEquals(tag2.getTextDescription("2"), "RGB");
assertEquals(tag2.getTextDescription("6"), "YCbCr");
assertEquals(tag2.getTextDescription("unexisting"), null);

tag2 = TiffTags.getTag(TiffTags.getTagId("Orientation"));
assertEquals(tag2.getTagValueDescription("1"), "TopLeft");
assertEquals(tag2.getTagValueDescription("unexisting"), null);
assertEquals(tag2.getTextDescription("1"), "TopLeft");
assertEquals(tag2.getTextDescription("unexisting"), null);

tag2 = TiffTags.getTag(TiffTags.getTagId("PlanarConfiguration"));
assertEquals(tag2.getTagValueDescription("1"), "Chunky");
assertEquals(tag2.getTagValueDescription("2"), "Planar");
assertEquals(tag2.getTagValueDescription("unexisting"), null);
assertEquals(tag2.getTextDescription("1"), "Chunky");
assertEquals(tag2.getTextDescription("2"), "Planar");
assertEquals(tag2.getTextDescription("unexisting"), null);

TiffReader tr;
try {
Expand All @@ -79,7 +79,7 @@ public void test() {
assertEquals(true, tr.getBaselineValidation().isCorrect());

String value =
tr.getModel().getFirstIFD().getTag("PhotometricInterpretation").getDescriptiveValue();
tr.getModel().getFirstIFD().getTag("PhotometricInterpretation").getFirstTextReadValue();
assertEquals(value, "Bilevel");
} catch (ReadTagsIOException e) {
assertEquals(0, 1);
Expand Down

0 comments on commit 7f52c24

Please sign in to comment.