feat(oiiotool): Allow decision making about fixnan #4171
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a new bit of pseudo-metadata that can be retrieved by oiiotool's expression substitution:
{TOP.NONFINITE_COUNT}
will be replaced by the count of inf and nan values present in the top image.Also, the
-fixnan
command now has the side effect of setting a user variable calledNONFINITE_COUNT
to the number of nonfinite values that were detected or repaired.Between the two of these, it's now easy to solve the following problem that actually came up in production for us.
Sometimes, nans creep into images, and it's easier to repair them than to fix the complicated process that produced them in the first place. For some process in the studio, we had a script that was doing this preemptively on every image it encountered:
It was very expensive to repair every image whether it needed it or not, when actually it's only needed once every
many-thousands-of-images. Most of the expense was in outputting the repaired file overtop the original. Now we can do this
It still has to read the image and look for NaN values, but since there are almost never any actual NaN's, now for the usual case, it can skip writing the output -- which was the vast majority of time.