1img2dcm(1) OFFIS DCMTK img2dcm(1)
2
3
4
6 img2dcm - Convert standard image formats into DICOM format
7
8
10 img2dcm [options] imgfile-in... dcmfile-out
11
13 The img2dcm tool serves as a conversion tool from a standard image
14 format like JPEG or BMP to DICOM. Different output SOP Classes can be
15 selected. The additional information (regarding patients, series, etc.)
16 stored in the DICOM output file can be extracted from other DICOM files
17 which serve as a 'template' for the resulting DICOM object. img2dcm can
18 also be configured to invent missing DICOM type 1 and type 2 attributes
19 to work even without any template dataset.
20
22 imgfile-in image input filename
23
24 dcmfile-out DICOM output filename
25
27 general options
28 -h --help
29 print this help text and exit
30
31 --version
32 print version information and exit
33
34 --arguments
35 print expanded command line arguments
36
37 -q --quiet
38 quiet mode, print no warnings and errors
39
40 -v --verbose
41 verbose mode, print processing details
42
43 -d --debug
44 debug mode, print debug information
45
46 -ll --log-level [l]evel: string constant
47 (fatal, error, warn, info, debug, trace)
48 use level l for the logger
49
50 -lc --log-config [f]ilename: string
51 use config file f for the logger
52
53 input options
54 general:
55
56 -i --input-format [i]nput file format: string
57 supported formats: JPEG (default), BMP
58
59 -df --dataset-from [f]ilename: string
60 use dataset from DICOM file f
61
62 -dx --dataset-from-xml [f]ilename: string
63 use dataset from XML file f
64
65 -stf --study-from [f]ilename: string
66 read patient/study from DICOM file f
67
68 -sef --series-from [f]ilename: string
69 read patient/study/series from DICOM file f
70
71 -ii --instance-inc
72 increase instance number read from DICOM file
73
74 JPEG format:
75
76 -dp --disable-progr
77 disable support for progressive JPEG
78
79 -de --disable-ext
80 disable support for extended sequential JPEG
81
82 -jf --insist-on-jfif
83 insist on JFIF header existence
84
85 -ka --keep-appn
86 keep APPn sections (except JFIF)
87
88 -rc --remove-com
89 remove COM segment
90
91 XML validation:
92
93 +Vd --validate-document
94 validate XML document against DTD
95
96 +Vn --check-namespace
97 check XML namespace in document root
98
99 processing options
100 attribute checking:
101
102 --do-checks
103 enable attribute validity checking (default)
104
105 --no-checks
106 disable attribute validity checking
107
108 +i2 --insert-type2
109 insert missing type 2 attributes (default)
110 (only with --do-checks)
111
112 -i2 --no-type2-insert
113 do not insert missing type 2 attributes
114 (only with --do-checks)
115
116 +i1 --invent-type1
117 invent missing type 1 attributes (default)
118 (only with --do-checks)
119
120 -i1 --no-type1-invent
121 do not invent missing type 1 attributes
122 (only with --do-checks)
123
124 character set conversion of study/series file:
125
126 -Ct --transliterate
127 try to approximate characters that cannot be
128 represented through similar looking characters
129
130 -Cd --discard-illegal
131 discard characters that cannot be represented
132 in destination character set
133
134 other processing options:
135
136 -k --key [k]ey: gggg,eeee="str", path or dictionary name="str"
137 add further attribute
138
139 output options
140 target SOP class:
141
142 -sc --sec-capture
143 write Secondary Capture SOP class (default)
144
145 -nsc --new-sc
146 write new Secondary Capture SOP classes
147
148 -vlp --vl-photo
149 write Visible Light Photographic SOP class
150
151 -oph --oph-photo
152 write Ophthalmic Photography SOP classes
153
154 output file format:
155
156 +F --write-file
157 write file format (default)
158
159 -F --write-dataset
160 write data set without file meta information
161
162 group length encoding:
163
164 +g= --group-length-recalc
165 recalculate group lengths if present (default)
166
167 +g --group-length-create
168 always write with group length elements
169
170 -g --group-length-remove
171 always write without group length elements
172
173 length encoding in sequences and items:
174
175 +e --length-explicit
176 write with explicit lengths (default)
177
178 -e --length-undefined
179 write with undefined lengths
180
181 data set trailing padding (not with --write-dataset):
182
183 -p --padding-off
184 no padding (implicit if --write-dataset)
185
186 +p --padding-create [f]ile-pad [i]tem-pad: integer
187 align file on multiple of f bytes
188 and items on multiple of i bytes
189
191 Attribute Sources
192 For converting a general image format into DICOM format, the img2dcm
193 application may be fed with some additional input for filling mandatory
194 (and optional) attributes in the new DICOM file like patient, study and
195 series information. This information can be collected using different
196 approaches, which can be combined and are applied to the result file in
197 the following order:
198
199 • Using the --dataset-from option img2dcm is forced to import
200 attributes from an existing DICOM file. The given DICOM file is fully
201 imported and serves as the basis for all further export operations.
202 As an exception, the SOP Instance UID is not copied by this option.
203 Also image related data like Rows, Columns etc. is exchanged during
204 conversion. Note that img2dcm does not check any other attribute
205 values for validity, e.g. it does not look into sequences to adapt
206 any attributes to the new object (referenced images etc.). Therefore,
207 it is recommended to use the templates in the data directory for
208 (old) SC and VLP objects. See also section 'Input Templates'.
209 • Using the --dataset-from-xml option img2dcm is also forced to import
210 attributes from an existing file. In this case, however, the file
211 must contain XML data in the format as produced by dcm2xml.
212 • The --study-from and --series-from options (mutually exclusive) can
213 be used to import patient, study and series information from an
214 existing DICOM file. If --series-from is specified, then the given
215 DICOM file is opened by img2dcm and all mandatory information down to
216 the series level is imported. Note that this includes patient, study
217 and series information. In case of --study-from, the series
218 information is excluded. The following attributes are taken over:
219 Patient Level:
220 Patient's Name
221 Patient ID
222 Patient's Sex
223 Patient's Birth Date
224 Specific Character Set
225
226 Study Level:
227 Study Instance UID
228 Study Date
229 Study Time
230 Referring Physician's Name
231 Study ID
232 Accession Number
233
234 Series Level (only in case of option --series-from):
235 Series Instance UID
236 Series Number
237 Manufacturer
238 • With the --insert-type2 and --invent-type1 options (both enabled per
239 default), missing attributes (type 2 attributes) and/or missing
240 attribute values (for type 1 attributes) are automatically added and
241 invented by img2dcm. Please note that these options are only
242 evaluated if option --do-checks is enabled (default). If the --no-
243 checks options is enabled, no automatic attribute insertion will take
244 place.
245 • The --key option can be used to add further attributes to the DICOM
246 output file. It is also possible to specify sequences, items and
247 nested attributes using the --key option. In these cases, a special
248 'path' notation has to be used. Details on this path notation can be
249 found in the documentation of dcmodify. The --key option can be
250 present more than once. The value part (after the '=') may be absent
251 causing the attribute to be set with zero length. Please be advised
252 that the --key option is applied at the very end, just before saving
253 the DICOM file, so there is no value checking whatsoever.
254 UIDs
255 New Study and Series Instance UIDs are generated if necessary after
256 applying the --study-from and --series options. If Study Instance UID
257 or Series Instance UID are not present after these steps, they are
258 newly generated, independently from each other. A contrary behavior is
259 chosen for the SOP Instance UID that one could expect to be taken over
260 when using the --dataset-from option. This is not the case, the SOP
261 Instance UID is not copied to the new object. This should be the
262 desirable behavior for most use cases. However, if a certain SOP
263 Instance UID should be inserted into the new object, the --key option
264 should be used.
265 Input Templates
266 For supporting the conversion into DICOM, img2dcm comes with some pre-
267 defined templates which can be used for the --dataset-from option (see
268 sample files SC.dump and VLP.dump). These templates should be filled
269 with the desired values and then must be dumped (converted) to a DICOM
270 file before actually being used with img2dcm. Use dump2dcm to convert
271 the dump to DICOM. Example:
272 dump2dcm SC.dump SC.dcm
273
274 For Ophthalmic Photography images, XML templates are provided (see
275 sample file OP_template_utf_8.xml and OP_template_latin_1.xml).
276 It is possible to use any DICOM file as a template. Please note that
277 the complete DICOM dataset is imported; hence, it should be assured
278 that only attributes are present which should be part of the
279 constructed DICOM object. The SOP Class UID and the Pixel Data
280 attributes (including attributes like Rows, Columns etc.) are not
281 copied but replaced by img2dcm during conversion.
282 Character Sets
283 When an input template is loaded using --dataset-from or --dataset-
284 from-xml, the specific character set of that template is used for the
285 generated DICOM file. If the --study-from or --series-from options are
286 used additionally, img2dcm will try to convert the character set of
287 these attributes to that of the template, and will report an error if
288 that is not possible. If the --study-from or --series-from options are
289 used without a template, the specific character set of this source is
290 used for the generated DICOM file. Any keys specified on the command
291 line with the --key option are treated as raw bytes and override any
292 attributes that may already be present due to a template or
293 study/series file. Therefore, care should be taken to not specify a
294 specific character set on the command line if one might be loaded from
295 another file. It is also the user's responsibility to ensure that
296 attribute values specified on the command line use the correct
297 encoding, as no conversion will take place before the values are stored
298 in the DICOM file.
299 Input Plugins
300 The img2dcm application currently supports the JPEG and the BMP image
301 format as input.
302 JPEG Input Plugin
303 For JPEG, the original JPEG from the source file is not decoded but
304 extracted and slightly transformed (e.g. JFIF header is cut off) to
305 allow fast conversion of even big JPEG files without the need of
306 decoding and re-encoding. The JPEG plugin chooses the necessary output
307 transfer syntax automatically depending on the actual encoding of the
308 data inside the JPEG file. Therefore, the following Transfer Syntaxes
309 (and their corresponding JPEG encodings) are used by the JPEG plugin:
310 • JPEG Coding Process 1 Baseline, Lossy, Non-Hierarchical, Sequential,
311 DCT, Huffman, 8 Bit SOP Class = 1.2.840.10008.1.2.4.50
312 • JPEG Coding Process 2 (8-bit) and 4 (12-bit) Extended, Lossy, Non-
313 Hierarchical, Sequential, DCT, Huffman, 8/12 Bit SOP Class =
314 1.2.840.10008.1.2.4.51
315 • JPEG Coding Process 10 (8-bit) and 12 (12-bit) Full Progression,
316 lossy, Non-Hierarch., Progressive, DCT, Huffman, 8/12 Bit SOP Class =
317 1.2.840.10008.1.2.4.55
318 Color and grayscale images are supported.
319 The support for the Extended JPEG Transfer Syntax can be disabled
320 (--disable-ext option) as well as the support for the (retired)
321 Progressive JPEG Transfer Syntax (--disable-progr option).
322 JPEG lossless encoding as well as any arithmetic or hierarchical JPEG
323 encoding modes are not supported by the plugin.
324 JFIF (JPEG File Interchange Format) information facilitates optional
325 APPn markers in a JPEG file. Many digital cameras do not integrate such
326 JFIF information into the JPEG output they create. For example, JFIF
327 contains information about the pixel aspect ratio of the compressed
328 image. If you want the img2dcm application to insist on a JFIF header
329 in the JPEG stream, you can use the option --insist-on-jfif which will
330 abort if no JFIF information can be found. By default, missing JFIF
331 information is ignored.
332 For DICOM it is kind of a 'gray zone', whether the integration of JFIF
333 (or any other APPn) data into the DICOM object's internal JPEG stream
334 is allowed or not. However, the most reliable approach is to cut those
335 markers and their information off the JPEG stream. This approach is
336 also taken by the img2dcm application. By default, all APPn markers are
337 cut off from the original JPEG stream. However, if you want to keep
338 other APPn markers than JFIF (e.g. EXIF information) inside the DICOM
339 stream, the option --keep-appn does the trick. It should also be
340 slightly faster than cutting off APPn information, because it is not
341 necessary to scan the whole JPEG stream for such data. As stated
342 before, JFIF information is always removed by img2dcm. However, when
343 using this option, the APP2 marker is retained, but img2dcm does not
344 create an equivalent ICC Profile (0028,2000) attribute.
345 BMP Input Plugin
346 img2dcm supports BMP as input format. However, so far only the most
347 common BMP images are supported. In particular, BMP images which use
348 bit fields or run length encoding will be rejected. Such images are
349 uncommon. Input images will either be converted into a DICOM image with
350 RGB color model and a bit depth of 24, or into an image with
351 MONOCHROME2 color model an 8 bits per pixel. There are no specific
352 options for fine-tuning BMP format conversion.
353 Output Plugins
354 The desired output SOP Class can be selected on the command line.
355 Currently, export plugins for the Secondary Capture Image SOP class
356 (default, option -sc), the Multiframe Secondary Capture Image SOP
357 classes (option -nsc), Visible Light Photographic Image SOP class
358 (option -vl), and the Ophthalmic Photography Image SOP Classes (option
359 -oph) are available. Please note that the first one is deprecated
360 according to the DICOM standard but is selected as a default because it
361 is widely supported. Future versions of img2dcm might provide further
362 output plugins for other SOP Classes.
363 For the new Secondary Capture SOP classes, it is not possible to
364 specify which specific SOP class should be used for output. That is
365 because these new SOP classes are differentiated from each other by
366 color depth (1/8/16) and the fact whether the image is black/white or
367 color. That is why img2dcm decides during conversion, which output SOP
368 class is suitable for a given source image.
370 Here are some examples that show how the img2dcm application can be
371 used.
372 1. img2dcm image.jpg out.dcm
373 Read JPEG file 'image.jpg', convert to the old Secondary Capture
374 SOP class and save the result to DICOM file 'out.dcm'. This is the
375 easiest way of using img2dcm. Any type 1 and type 2 attributes
376 required for writing valid objects of this SOP class are inserted
377 automatically.
378 2. img2dcm -i BMP image.bmp out.dcm
379 Same as above but tells img2dcm to read a BMP file instead of JPEG.
380 3. img2dcm image.jpg out.dcm -vlp -k 'PatientName=Bond^James'
381 Same as first example, but writes Visible Light Photographic Image
382 object to 'out.dcm' and sets PatientName to 'Bond^James' which
383 otherwise would be left empty.
384 4. img2dcm image.jpg out.dcm --series-from template.dcm -k
385 'PatientName=Bond^James'
386 Same as 1), but imports patient/study/series information from DICOM
387 file 'template.dcm'. Please note that attribute PatientName will
388 contain 'Bond^James' at the end, any value from 'template.dcm' will
389 be overwritten. That is, because the -k option is applied at the
390 very end of the conversion pipeline (see above).
391 5. img2dcm image.jpg out.dcm --no-checks
392 Same as 1), but does not perform any attribute checking and no type
393 1 and type 2 attribute insertion! So in this case, an invalid DICOM
394 object would be generated. This can be interesting if the output
395 file is not meant to be completed but will undergo further
396 transformations, e.g. adding attributes using dcmodify. Only use
397 option --no-checks if you know what you are doing!
398 6. img2dcm image.jpg out.dcm --no-type1-invent
399 Same as 1), but does not insert missing type 1 attributes and/or
400 their values. Type 2 attributes will be inserted. Note that in this
401 case it must be assured that all type 1 attributes are provided by
402 other means, i. e. by adding them with the --key option. Otherwise,
403 img2dcm will report an error and will stop converting.
404 7. img2dcm image.jpg out.dcm --keep-appn --insist-on-jfif
405 Same as 1), but takes over APPn information like EXIF into the
406 DICOM object's resulting JPEG stream. Further, --insist-on-jfif
407 will force img2dcm to abort if no JFIF information is existent in
408 the source file.
410 The level of logging output of the various command line tools and
411 underlying libraries can be specified by the user. By default, only
412 errors and warnings are written to the standard error stream. Using
413 option --verbose also informational messages like processing details
414 are reported. Option --debug can be used to get more details on the
415 internal activity, e.g. for debugging purposes. Other logging levels
416 can be selected using option --log-level. In --quiet mode only fatal
417 errors are reported. In such very severe error events, the application
418 will usually terminate. For more details on the different logging
419 levels, see documentation of module 'oflog'.
420 In case the logging output should be written to file (optionally with
421 logfile rotation), to syslog (Unix) or the event log (Windows) option
422 --log-config can be used. This configuration file also allows for
423 directing only certain messages to a particular output stream and for
424 filtering certain messages based on the module or application where
425 they are generated. An example configuration file is provided in
426 <etcdir>/logger.cfg.
428 All command line tools use the following notation for parameters:
429 square brackets enclose optional values (0-1), three trailing dots
430 indicate that multiple values are allowed (1-n), a combination of both
431 means 0 to n values.
432 Command line options are distinguished from parameters by a leading '+'
433 or '-' sign, respectively. Usually, order and position of command line
434 options are arbitrary (i.e. they can appear anywhere). However, if
435 options are mutually exclusive the rightmost appearance is used. This
436 behavior conforms to the standard evaluation rules of common Unix
437 shells.
438 In addition, one or more command files can be specified using an '@'
439 sign as a prefix to the filename (e.g. @command.txt). Such a command
440 argument is replaced by the content of the corresponding text file
441 (multiple whitespaces are treated as a single separator unless they
442 appear between two quotation marks) prior to any further evaluation.
443 Please note that a command file cannot contain another command file.
444 This simple but effective approach allows one to summarize common
445 combinations of options/parameters and avoids longish and confusing
446 command lines (an example is provided in file <datadir>/dumppat.txt).
448 The img2dcm utility will attempt to load DICOM data dictionaries
449 specified in the DCMDICTPATH environment variable. By default, i.e. if
450 the DCMDICTPATH environment variable is not set, the file
451 <datadir>/dicom.dic will be loaded unless the dictionary is built into
452 the application (default for Windows).
453 The default behavior should be preferred and the DCMDICTPATH
454 environment variable only used when alternative data dictionaries are
455 required. The DCMDICTPATH environment variable has the same format as
456 the Unix shell PATH variable in that a colon (':') separates entries.
457 On Windows systems, a semicolon (';') is used as a separator. The data
458 dictionary code will attempt to load each file specified in the
459 DCMDICTPATH environment variable. It is an error if no data dictionary
460 can be loaded.
462 <datadir>/SC.dump - Sample dump file for Secondary Capture images
463 <datadir>/VLP.dump - Sample dump file for Visible Light Photographic
464 images
465 <datadir>/OP_template.xml - Sample XML template for Ophthalmic
466 Photography images
468 dcm2pnm(1), dcmj2pnm(1), dump2dcm(1), dcmconv(1), dcmodify(1),
469 dcm2xml(1)
471 Copyright (C) 2007-2022 by OFFIS e.V., Escherweg 2, 26121 Oldenburg,
472 Germany.
473
474
475
476Version 3.6.7 Fri Apr 22 2022 img2dcm(1)