Skip to content

Commit

Permalink
Merge pull request #914 from tledoux/badOrientationInMix
Browse files Browse the repository at this point in the history
Checks the range of the orientation tag to be 1-9, and forces value 9…
  • Loading branch information
carlwilson authored Aug 13, 2024
2 parents c45fd1c + 09cd9c9 commit bf9b7da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ public class NisoImageMetadata
/** 6.2.4 orientation value labels. */
public static final String [] ORIENTATION = {
"", "normal", "reflected horiz", "rotated 180 deg", "reflected vert",
"left top", "rotated cw 90 deg", "Right bottom", "Rotated ccw 90 deg",
"Unknown"
"left top", "rotated cw 90 deg", "right bottom", "rotated ccw 90 deg",
"unknown"
};

/** 6.1.6 planar configuration value labels. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1648,19 +1648,19 @@ protected JsonObjectBuilder showNisoImageCaptureMetadata(

n = niso.getOrientation();
if (n != NisoImageMetadata.NULL) {
if (n > 9 || n < 1) {
n = 9; // force "unknown" for reserved value
}
if (bMix10) {
mixBuilder.add("mix:orientation", n);
} else {
final String[] orient = { "unknown", "normal*",
final String[] orient = { "", "normal*",
"normal, image flipped", "normal, rotated 180\u00B0",
"normal, image flipped, rotated 180\u00B0",
"normal, image flipped, rotated cw 90\u00B0",
"normal, rotated ccw 90\u00B0",
"normal, image flipped, rotated ccw 90\u00B0",
"normal, rotated cw 90\u00B0" };
if (n > 8 || n < 0) {
n = 0; // force "unknown" for bad value
}
"normal, rotated cw 90\u00B0", "unknown" };
mixBuilder.add("mix:orientation", orient[n]);
}
hasBuilder = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,9 @@ protected void showNisoBasicImageParameters02(NisoImageMetadata niso,
}
n = niso.getOrientation();
if (n != NisoImageMetadata.NULL) {
if (n > 9 || n < 1) {
n = 9; // force "unknown" for reserved value
}
fileBuf.append(margn4
+ element("mix:Orientation", Integer.toString(n)) + EOL);
useFileBuf = true;
Expand Down Expand Up @@ -2717,6 +2720,9 @@ protected void showNisoImageCaptureMetadata10(NisoImageMetadata niso,

n = niso.getOrientation();
if (n != NisoImageMetadata.NULL) {
if (n > 9 || n < 1) {
n = 9; // force "unknown" for reserved value
}
captureBuffer.append(margn3
+ element("mix:orientation", Integer.toString(n)) + EOL);
useCaptureBuffer = true;
Expand Down Expand Up @@ -3780,15 +3786,16 @@ protected void showNisoImageCaptureMetadata20(NisoImageMetadata niso,

n = niso.getOrientation();
if (n != NisoImageMetadata.NULL) {
final String[] orient = { "unknown", "normal*",
// Values defined in the MIX 2.0 schema
final String[] orient = { "", "normal*",
"normal, image flipped", "normal, rotated 180\u00B0",
"normal, image flipped, rotated 180\u00B0",
"normal, image flipped, rotated cw 90\u00B0",
"normal, rotated ccw 90\u00B0",
"normal, image flipped, rotated ccw 90\u00B0",
"normal, rotated cw 90\u00B0" };
if (n > 8 || n < 0) {
n = 0; // force "unknown" for bad value
"normal, rotated cw 90\u00B0", "unknown" };
if (n > 9 || n < 1) {
n = 9; // force "unknown" for reserved value
}
captureBuffer.append(margn3 + element("mix:orientation", orient[n])
+ EOL);
Expand Down

0 comments on commit bf9b7da

Please sign in to comment.