|
| 1 | +<tool name="Parse value from image metadata" id="param_image_metadata" version="0.1.0" tool_type="expression" profile="25.1"> |
| 2 | + <description/> |
| 3 | + <macros> |
| 4 | + <import>creators.xml</import> |
| 5 | + </macros> |
| 6 | + <creator> |
| 7 | + <expand macro="creators/bmcv"/> |
| 8 | + <expand macro="creators/kostrykin"/> |
| 9 | + </creator> |
| 10 | + <macros/> |
| 11 | + <edam_operations> |
| 12 | + <edam_operation>operation_3443</edam_operation> |
| 13 | + </edam_operations> |
| 14 | + <expression type="ecma5.1"> |
| 15 | + { |
| 16 | + return { |
| 17 | + 'width': parseInt($job.input1.metadata.width), |
| 18 | + 'height': parseInt($job.input1.metadata.height), |
| 19 | + 'channels': parseInt($job.input1.metadata.channels), |
| 20 | + 'depth': parseInt($job.input1.metadata.depth), |
| 21 | + 'frames': parseInt($job.input1.metadata.frames) |
| 22 | + }; |
| 23 | + } |
| 24 | + </expression> |
| 25 | + <inputs> |
| 26 | + <param type="data" format="tiff,png,jpg" label="Input file to parse the metadata of" load_contents="0" name="input1"/> |
| 27 | + </inputs> |
| 28 | + <outputs> |
| 29 | + <output type="integer" name="width" from="width" label="Parse image width"/> |
| 30 | + <output type="integer" name="height" from="height" label="Parse image height"/> |
| 31 | + <output type="integer" name="channels" from="channels" label="Parse image channels"/> |
| 32 | + <output type="integer" name="depth" from="depth" label="Parse image depth"/> |
| 33 | + <output type="integer" name="frames" from="frames" label="Parse image frames"/> |
| 34 | + </outputs> |
| 35 | + <tests> |
| 36 | + <test expect_num_outputs="5"> |
| 37 | + <!-- Test for PNG metadata --> |
| 38 | + <param name="input1" value="input_yxc.png"/> |
| 39 | + <output name="width"> |
| 40 | + <assert_contents> |
| 41 | + <has_line line="265"/> |
| 42 | + </assert_contents> |
| 43 | + </output> |
| 44 | + <output name="height"> |
| 45 | + <assert_contents> |
| 46 | + <has_line line="530"/> |
| 47 | + </assert_contents> |
| 48 | + </output> |
| 49 | + <output name="channels"> |
| 50 | + <assert_contents> |
| 51 | + <has_line line="4"/> |
| 52 | + </assert_contents> |
| 53 | + </output> |
| 54 | + <output name="depth"> |
| 55 | + <assert_contents> |
| 56 | + <has_line line="0"/> |
| 57 | + </assert_contents> |
| 58 | + </output> |
| 59 | + <output name="frames"> |
| 60 | + <assert_contents> |
| 61 | + <has_line line="1"/> |
| 62 | + </assert_contents> |
| 63 | + </output> |
| 64 | + </test> |
| 65 | + <test expect_num_outputs="5"> |
| 66 | + <!-- Test for TIFF metadata (with Z axis, without T axis) --> |
| 67 | + <param name="input1" value="input_yxz.tiff"/> |
| 68 | + <output name="width"> |
| 69 | + <assert_contents> |
| 70 | + <has_line line="265"/> |
| 71 | + </assert_contents> |
| 72 | + </output> |
| 73 | + <output name="height"> |
| 74 | + <assert_contents> |
| 75 | + <has_line line="530"/> |
| 76 | + </assert_contents> |
| 77 | + </output> |
| 78 | + <output name="channels"> |
| 79 | + <assert_contents> |
| 80 | + <has_line line="0"/> |
| 81 | + </assert_contents> |
| 82 | + </output> |
| 83 | + <output name="depth"> |
| 84 | + <assert_contents> |
| 85 | + <has_line line="4"/> |
| 86 | + </assert_contents> |
| 87 | + </output> |
| 88 | + <output name="frames"> |
| 89 | + <assert_contents> |
| 90 | + <has_line line="0"/> |
| 91 | + </assert_contents> |
| 92 | + </output> |
| 93 | + </test> |
| 94 | + <test expect_num_outputs="5"> |
| 95 | + <!-- Test for TIFF metadata (with T axis, without Z axis) --> |
| 96 | + <param name="input1" value="input_yxt.tiff"/> |
| 97 | + <output name="width"> |
| 98 | + <assert_contents> |
| 99 | + <has_line line="265"/> |
| 100 | + </assert_contents> |
| 101 | + </output> |
| 102 | + <output name="height"> |
| 103 | + <assert_contents> |
| 104 | + <has_line line="530"/> |
| 105 | + </assert_contents> |
| 106 | + </output> |
| 107 | + <output name="channels"> |
| 108 | + <assert_contents> |
| 109 | + <has_line line="0"/> |
| 110 | + </assert_contents> |
| 111 | + </output> |
| 112 | + <output name="depth"> |
| 113 | + <assert_contents> |
| 114 | + <has_line line="0"/> |
| 115 | + </assert_contents> |
| 116 | + </output> |
| 117 | + <output name="frames"> |
| 118 | + <assert_contents> |
| 119 | + <has_line line="4"/> |
| 120 | + </assert_contents> |
| 121 | + </output> |
| 122 | + </test> |
| 123 | + <test expect_num_outputs="5"> |
| 124 | + <!-- Test for JPG metadata --> |
| 125 | + <param name="input1" value="input_yxc.jpg"/> |
| 126 | + <output name="width"> |
| 127 | + <assert_contents> |
| 128 | + <has_line line="10"/> |
| 129 | + </assert_contents> |
| 130 | + </output> |
| 131 | + <output name="height"> |
| 132 | + <assert_contents> |
| 133 | + <has_line line="10"/> |
| 134 | + </assert_contents> |
| 135 | + </output> |
| 136 | + <output name="channels"> |
| 137 | + <assert_contents> |
| 138 | + <has_line line="3"/> |
| 139 | + </assert_contents> |
| 140 | + </output> |
| 141 | + <output name="depth"> |
| 142 | + <assert_contents> |
| 143 | + <has_line line="0"/> |
| 144 | + </assert_contents> |
| 145 | + </output> |
| 146 | + <output name="frames"> |
| 147 | + <assert_contents> |
| 148 | + <has_line line="0"/> |
| 149 | + </assert_contents> |
| 150 | + </output> |
| 151 | + </test> |
| 152 | + </tests> |
| 153 | + <help><![CDATA[ |
| 154 | +
|
| 155 | + **Parse image metadata as parameter values.** |
| 156 | +
|
| 157 | + This tool can be used in workflows to parse parameter values from image metadata (e.g., width, height, etc.). |
| 158 | +
|
| 159 | + ]]></help> |
| 160 | +</tool> |
0 commit comments