Skip to content

Commit b18a447

Browse files
authored
Add tool: parse_image_metadata (#226)
* Add parse_image_metadata.xml * Fix * Add more outputs * Add .shed.yml * Update help and description * Clean up test-data * Clean up `expression` * Revert "Clean up test-data" This reverts commit fcfda53. * Fix test-data * Bump `GALAXY_BRANCH` to `release_25.1` * Bump `GALAXY_BRANCH` to `release_26.0` * Bump `profile` to `25.1` * Add `label` for each `output` * Add `jpg` support * Add test comments * Update `label`
1 parent 7a3d03f commit b18a447

9 files changed

Lines changed: 178 additions & 2 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99
env:
1010
GALAXY_FORK: galaxyproject
11-
GALAXY_BRANCH: release_25.0
11+
GALAXY_BRANCH: release_26.0
1212
MAX_CHUNKS: 40
1313
jobs:
1414
setup:

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- '*'
1616
env:
1717
GALAXY_FORK: galaxyproject
18-
GALAXY_BRANCH: release_25.0
18+
GALAXY_BRANCH: release_26.0
1919
MAX_CHUNKS: 4
2020
MAX_FILE_SIZE: 1M
2121
concurrency:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
categories:
2+
- Imaging
3+
4+
description: Parse image metadata as parameter values (width, height, number of channels, etc.)
5+
6+
long_description: |
7+
This tool can be used in workflows to parse parameter values from image metadata.
8+
9+
name: parse_image_metadata
10+
11+
owner: imgteam
12+
homepage_url: https://github.com/bmcv
13+
remote_repository_url: https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/parse_image_metadata/
14+
15+
type: unrestricted
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../macros/creators.xml
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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>
1.05 KB
Loading
4.45 KB
Loading
549 KB
Binary file not shown.
549 KB
Binary file not shown.

0 commit comments

Comments
 (0)