|
| 1 | +function info = inspectFile(path, opts) |
| 2 | +%INSPECTFILE Report whether one file contains readable thermal data. |
| 3 | +% |
| 4 | +% App-facing contract: |
| 5 | +% info = labkit.thermal.inspectFile(path) |
| 6 | +% info = labkit.thermal.inspectFile(path, opts) |
| 7 | +% |
| 8 | +% Inputs: |
| 9 | +% path - scalar char/string path. |
| 10 | +% opts - optional scalar struct with fields accepted by |
| 11 | +% labkit.thermal.readFile. |
| 12 | +% |
| 13 | +% Outputs: |
| 14 | +% info - scalar struct with path, name, supportedExtension, isThermal, |
| 15 | +% format, identifier, and message fields. This function catches reader |
| 16 | +% failures and never throws for unsupported or non-radiometric image |
| 17 | +% content. |
| 18 | + |
| 19 | + if nargin < 2 || isempty(opts) |
| 20 | + opts = struct(); |
| 21 | + end |
| 22 | + [~, base, ext] = fileparts(char(string(path))); |
| 23 | + info = struct( ... |
| 24 | + 'path', string(path), ... |
| 25 | + 'name', string([base ext]), ... |
| 26 | + 'supportedExtension', labkit.thermal.isSupportedPath(path), ... |
| 27 | + 'isThermal', false, ... |
| 28 | + 'format', "", ... |
| 29 | + 'identifier', "", ... |
| 30 | + 'message', ""); |
| 31 | + |
| 32 | + if ~info.supportedExtension |
| 33 | + info.identifier = "labkit:thermal:UnsupportedFile"; |
| 34 | + info.message = "Unsupported thermal image file extension."; |
| 35 | + return; |
| 36 | + end |
| 37 | + |
| 38 | + try |
| 39 | + record = labkit.thermal.readFile(path, opts); |
| 40 | + info.isThermal = true; |
| 41 | + info.format = record.format; |
| 42 | + info.message = record.message; |
| 43 | + catch ME |
| 44 | + info.identifier = string(ME.identifier); |
| 45 | + info.message = string(ME.message); |
| 46 | + end |
| 47 | +end |
0 commit comments