dcmcjpeg(1)
dcmcjpeg(1) π β¨
OFFIS DCMTK manual page, bestie edition π«Ά β yes, this is the dcmcjpeg(1) page, and we're gonna make it make sense.
πΈ NAME πΈ
dcmcjpeg β Encode DICOM file to JPEG transfer syntax. That's the whole vibe: DICOM in, JPEG-compressed transfer syntax out. Slay. β¨
β¨ SYNOPSIS β¨
dcmcjpeg [options] dcmfile-in dcmfile-out
π DESCRIPTION π
Okay so dcmcjpeg reads an uncompressed DICOM image (dcmfile-in), performs a JPEG compression (i.e. conversion to an encapsulated DICOM transfer syntax), and writes the converted image to an output file (dcmfile-out). Literally the glow-up pipeline. π
π PARAMETERS π
dcmfile-inβ DICOM input filename to be converted ("-"for stdin).dcmfile-outβ DICOM output filename ("-"for stdout).
β¨ OPTIONS β¨
general options
-h,--helpβ print this help text and exit. π«Ά--versionβ print version information and exit.--argumentsβ print expanded command line arguments.-q,--quietβ quiet mode, print no warnings and errors.-v,--verboseβ verbose mode, print processing details.-d,--debugβ debug mode, print debug information.-ll,--log-levelβ[l]evel: string constant(fatal,error,warn,info,debug,trace); use levellfor the logger.-lc,--log-configβ[f]ilename: string; use config fileffor the logger.
input options
input file format:
+f,--read-fileβ read file format or data set (default).+fo,--read-file-onlyβ read file format only.-f,--read-datasetβ read data set without file meta information.
input transfer syntax:
-t=,--read-xfer-autoβ use TS recognition (default).-td,--read-xfer-detectβ ignore TS specified in the file meta header.-te,--read-xfer-littleβ read with explicit VR little endian TS.-tb,--read-xfer-bigβ read with explicit VR big endian TS.-ti,--read-xfer-implicitβ read with implicit VR little endian TS.
compatibility (ignored by +tl):
+Ma,--accept-acr-nemaβ accept ACR-NEMA images without photometric interpretation.
Enables compatibility for old ACR-NEMA images without photometric information (only pseudo lossless encoder).
+Mp,--accept-palettesβ accept incorrect palette attribute tags(0028,111x)and(0028,121x).
If enabled, incorrect palette attribute tags are accepted (only pseudo lossless encoder).
JPEG encoding options
JPEG process:
+e1,--encode-lossless-sv1β encode lossless sv1 (default).
This option selects the JPEG Lossless, Non-Hierarchical, First-Order Prediction (Process 14 Selection Value 1) Transfer Syntax for Lossless JPEG Image Compression.
+el,--encode-losslessβ encode lossless.
This option selects the JPEG Lossless, Non-Hierarchical (Process 14) Transfer Syntax for Lossless JPEG Image Compression.
+eb,--encode-baselineβ encode baseline.
This option selects the JPEG Baseline (Process 1) Transfer Syntax for Lossy JPEG 8 Bit Image Compression.
+ee,--encode-extendedβ encode extended sequential.
This option selects the JPEG Extended (Process 2 & 4) Transfer Syntax for Lossy JPEG Image Compression.
+es,--encode-spectralβ encode spectral selection.
This option selects the JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8) Transfer Syntax for Lossy JPEG Image Compression.
+ep,--encode-progressiveβ encode progressive.
This option selects the JPEG Full Progression, Non-Hierarchical (Process 10 & 12) Transfer Syntax for Lossy JPEG Image Compression.
lossless JPEG codec selection:
+tl,--true-losslessβ true lossless codec (default).
This option selects an encoder that guarantees truly lossless image compression. See NOTES for further information.
+pl,--pseudo-losslessβ old pseudo-lossless codec.
Old encoder, that uses lossless compression algorithms, but can cause lossy images because of internal color space transformations etc. Higher compression ratio than --true-lossless in most cases.
lossless JPEG representation:
+sv,--selection-valueβ[sv]: integer (1..7, default: 6); use selection valuesvonly with--encode-lossless.
This option selects the selection value for lossless JPEG.
+pt,--point-transformβ[pt]: integer (0..15, default: 0); use point transformpt.
This option selects the point transform for lossless JPEG. WARNING: Using this option with a value other than zero causes a loss of precision, i.e. makes the compression "lossy".
lossy JPEG representation:
+q,--qualityβ[q]: integer (0..100, default: 90); use quality factorq.
This option selects the quality factor used to determine the quantization table inside the JPEG compressor, which affects compression ratio and image quality in lossy JPEG. See documentation of the Independent JPEG Group for details.
+sm,--smoothβ[s]: integer (0..100, default: 0); use smoothing factors.
This option enables a smoothing (low-pass filter) of the image data prior to compression. Increases the compression ratio at the expense of image quality.
other JPEG options:
+ho,--huffman-optimizeβ optimize huffman tables (default).
This option enables an optimization of the huffman tables during image compression. It results in a slightly smaller image at a small increase of CPU time. Always on if bits/sample is larger than 8.
-ho,--huffman-standardβ use standard huffman tables if 8 bits/sample.
This option disables an optimization of the huffman tables during image compression.
compressed bits per sample (always +ba with +tl):
+ba,--bits-autoβ choose bits/sample automatically (default).+be,--bits-force-8β force 8 bits/sample.+bt,--bits-force-12β force 12 bits/sample (not with baseline).+bs,--bits-force-16β force 16 bits/sample (lossless only).
compression color space conversion (overridden by +tl):
+cy,--color-ybrβ use YCbCr for color images if lossy (default).
This option enables a transformation of the color space to YCbCr prior to image compression for color images in lossy JPEG.
+cr,--color-rgbβ use RGB for color images if lossy.
This option prevents the transformation of the color space to YCbCr prior to image compression for color images in lossy JPEG. It causes lossy image compression in the RGB color space which is not recommendable.
+cm,--monochromeβ convert color images to monochrome.
This option forces a conversion of color images to monochrome prior to compression.
decompression color space conversion (if input is compressed; always +cn with +tl):
+cp,--conv-photometricβ convert if YCbCr photometric interpretation (default).
This option describes the behavior of dcmcjpeg when a compressed image is read and decompressed prior to re-compression. If the compressed image uses YBR_FULL or YBR_FULL_422 photometric interpretation, it is converted to RGB during decompression.
+cl,--conv-lossyβ convert YCbCr to RGB if lossy JPEG.
If the compressed image is encoded in lossy JPEG, assume YCbCr color model and convert to RGB.
+cg,--conv-guessβ convert to RGB if YCbCr is guessed by library.
If the underlying JPEG library "guesses" the color space of the compressed image to be YCbCr, convert to RGB.
+cgl,--conv-guess-lossyβ convert to RGB if lossy JPEG and YCbCr is guessed by the underlying JPEG library.
If the compressed image is encoded in lossy JPEG and the underlying JPEG library "guesses" the color space to be YCbCr, convert to RGB.
+ca,--conv-alwaysβ always convert YCbCr to RGB.
If the compressed image is a color image, assume YCbCr color model and convert to RGB.
+cn,--conv-neverβ never convert color space.
Never convert color space during decompression.
decompr. workaround options for incorrect encodings (if input is compressed):
+w6,--workaround-pred6β enable workaround for JPEG lossless images with overflow in predictor 6.
DICOM images with 16 bits/pixel have been observed "in the wild" that are compressed with lossless JPEG and need special handling because the encoder produced an 16-bit integer overflow in predictor 6, which needs to be compensated (reproduced) during decompression. This flag enables a correct decompression of such faulty images, but at the same time will cause an incorrect decompression of correctly compressed images. Use with care.
+wi,--workaround-incplβ enable workaround for incomplete JPEG data.
This option causes dcmjpeg to ignore incomplete JPEG data at the end of a compressed fragment and to start decompressing the next frame from the next fragment (if any). This permits images with incomplete JPEG data to be decoded.
+wc,--workaround-cornellβ enable workaround for 16-bit JPEG lossless Cornell images with Huffman table overflow.
One of the first open-source implementations of lossless JPEG compression, the "Cornell" library, has a well-known bug that leads to invalid values in the Huffmann table when images with 16 bit/sample are compressed. This flag enables a workaround that permits such images to be decoded correctly.
YCbCr component subsampling (lossy JPEG only):
+s2,--sample-422β 4:2:2 subsampling with YBR_FULL_422 (default).
This option enables a 4:2:2 color component subsampling for compression in the YCbCr color space. The DICOM photometric interpretation is encoded as YBR_FULL_422.
non-standard YCbCr component subsampling (not with +tl):
+s4,--nonstd-444β 4:4:4 sampling with YBR_FULL.
This option disables color component subsampling for compression in the YCbCr color space. The DICOM photometric interpretation is encoded as YBR_FULL, which violates DICOM rules for lossy JPEG.
+n2,--nonstd-422-fullβ 4:2:2 subsampling with YBR_FULL.
This option enables a 4:2:2 color component subsampling for compression in the YCbCr color space. The DICOM photometric interpretation is encoded as YBR_FULL, which violates DICOM rules.
+n1,--nonstd-411-fullβ 4:1:1 subsampling with YBR_FULL.
β οΈ heads up: the option right before this one enables a 4:1:1 color component subsampling for compression in the YCbCr color space, and the DICOM photometric interpretation is encoded as YBR_FULL, which violates DICOM rules. π
+np,--nonstd-411β 4:1:1 subsampling withYBR_FULL_422- warning, bestie: this enables 4:1:1 color component subsampling for compression in the YCbCr color space, and the DICOM photometric interpretation is encoded as
YBR_FULL_422, which violates DICOM rules. π«
- warning, bestie: this enables 4:1:1 color component subsampling for compression in the YCbCr color space, and the DICOM photometric interpretation is encoded as
π encapsulated pixel data encoding options: π
π encapsulated pixel data fragmentation: π
+ff,--fragment-per-frameβ encode each frame as one fragment (default)- this causes the creation of one compressed fragment for each frame (recommended). π
+fs,--fragment-size[s]ize: integerβ limit fragment size to s kbytes- this limits the fragment size, which may cause the creation of multiple fragments per frame. π§©
π basic offset table encoding: π
+ot,--offset-table-createβ create offset table (default)- this causes the creation of a valid offset table for the compressed JPEG fragments. β
-ot,--offset-table-emptyβ leave offset table empty- this causes the creation of an empty offset table for the compressed JPEG fragments. π³οΈ
π icon image encoding: π
+ic,--icon-compressedβ compress icon images (default)+iu,--icon-uncompressedβ keep icon images uncompressed
π VOI windowing for monochrome images (not with +tl): π
-W,--no-windowingβ no VOI windowing (default)- no window level/width is βburnedβ into monochrome images prior to compression. See notes below on pixel scaling and rescale slope and intercept encoding. π₯
+Wi,--use-window[n]umber: integerβ use the n-th VOI window from image file- apply the n-th window center/width encoded in the image data prior to compression.
+Wl,--use-voi-lut[n]umber: integerβ use the n-th VOI look up table from image file- apply the n-th VOI LUT encoded in the image data prior to compression.
+Wm,--min-max-windowβ compute VOI window using min-max algorithm- compute and apply a window center and width that covers the range from the smallest to the largest occurring pixel value.
+Wn,--min-max-window-nβ compute VOI window using min-max algorithm, ignoring extreme values- compute and apply a window center and width that covers the range from the second smallest to the second largest occurring pixel value. This is useful if the background is set to an artificial black (padding value) or if white overlays are burned into the image data which should not be considered for the window computation. π€
+Wr,--roi-min-max-window[l]eft [t]op [w]idth [h]eight: integerβ compute ROI window using min-max algorithm, region of interest is specified by l, t, w, h- this works like
--min-max-windowbut only considers the given region of interest inside the image. π
- this works like
+Wh,--histogram-window[n]umber: integerβ compute VOI window using Histogram algorithm, ignoring n percent- compute a histogram of the image data and apply window center and width such that n% of the image data are ignored for the window computation.
+Ww,--set-window[c]enter [w]idth: floatβ compute VOI window using center c and width w- apply the given window center/width prior to compression. π―
π pixel scaling for monochrome images (--no-windowing; ignored by +tl): π
+sp,--scaling-pixelβ scale using min/max pixel value (default)- monochrome image pixel values are always scaled to make use of the pixel range available with the selected JPEG process as good as possible. This option selects a scaling based on the minimum and maximum pixel value occurring in the image. This often leads to significantly better image quality, but may cause different compressed images within one series to have different values for rescale slope and intercept, which is a problem if a presentation state for one series is to be created. π¨
+sr,--scaling-rangeβ scale using min/max range- this option selects a scaling based on the pixel range as defined by the stored bits, pixel representation and modality transform, without consideration of the minimum and maximum value really used within the image. π
π rescale slope/intercept encoding for monochrome (-W; ignored by +tl): π
+ri,--rescale-identityβ encode identity modality rescale (default); never used for CT images- this option prevents the creation of a modality transformation other than an identity transformation (which is required for many DICOM IODs). Window center/width settings encoded in the image are adapted, VOI LUTs are removed. π©»
+rm,--rescale-mapβ use modality rescale to scale pixel range; never used for XA/RF/XA Biplane images- this option causes the creation of a modality rescale slope and intercept that maps the decompressed image data back to their original range. This keeps all VOI transformations valid but requires that the DICOM IOD supports a modality rescale slope and intercept transformation other than identity. πΊοΈ
π SOP Class UID: π
+cd,--class-defaultβ keep SOP Class UID (default)- keep the SOP Class UID of the source image.
+cs,--class-scβ convert to Secondary Capture Image (implies--uid-always)- convert the image to Secondary Capture. In addition to the SOP Class UID, all attributes required for a valid secondary capture image are added. A new SOP instance UID is always assigned. πΈ
π SOP Instance UID: π
+ud,--uid-defaultβ assign new UID if lossy compression (default)- assigns a new SOP instance UID if the compression is lossy.
+ua,--uid-alwaysβ always assign new UID- unconditionally assigns a new SOP instance UID. π
+un,--uid-neverβ never assign new UID- never assigns a new SOP instance UID. π«
π output options π
π post-1993 value representations: π
+u,--enable-new-vrβ enable support for new VRs (UN/UT) (default)-u,--disable-new-vrβ disable support for new VRs, convert toOB
π group length encoding: π
+g=,--group-length-recalcβ recalculate group lengths if present (default)+g,--group-length-createβ always write with group length elements-g,--group-length-removeβ always write without group length elements
π length encoding in sequences and items: π
+e,--length-explicitβ write with explicit lengths (default)-e,--length-undefinedβ write with undefined lengths
π data set trailing padding: π
-p=,--padding-retainβ do not change padding (default)-p,--padding-offβ no padding+p,--padding-create[f]ile-pad [i]tem-pad: integerβ align file on multiple of f bytes and items on multiple of i bytes
β¨ NOTES β¨
The dcmcjpeg utility compresses DICOM images of all SOP classes. It processes all Pixel Data (7fe0,0010) elements in the dataset, i.e. compression is also performed on an icon image. Special handling has been implemented for CT images (where the modality transformation is required to create Hounsfield units) and the XA/RF/Biplane SOP classes (where the modality transformation has βinversedβ semantics). However, dcmcjpeg does not attempt to ensure that the compressed image still complies with all restrictions of the objectβs IOD. π¬
A few examples:
- MR images are required to have
BitsAllocated=16. - NM Images can only be encoded with
MONOCHROME2orPALETTE COLORphotometric interpretation but not withRGBorYBR_FULL(which effectively prevents compression). - Hardcopy Color images must have
RGBcolor model which is a problem if lossy compression is to be performed.
The user is responsible for making sure that the compressed images they create are compliant with the DICOM standard. If in question, the dcmcjpeg utility allows one to convert an image to secondary capture β this SOP class does not pose restrictions as the ones mentioned above. π«Ά
With version DCMTK 3.5.4 a new encoder for truly lossless JPEG compression was added (--true-lossless). Compared to the old (--pseudo-lossless) encoder, that creates slightly lossy images caused from internal color space conversions, windowing etc., there are some issues to consider:
- Only source images with
Bits Allocated8 or 16 are supported - Options for color space conversions, windowing or pixel scaling are ignored or overridden
- Photometric Interpretations
YBR_FULL_422,YBR_PARTIAL_422,YBR_PARTIAL_420,YBR_ICT,YBR_RCTare not supported - The encoder changes automatically
Planar Configurationfrom 1 to 0 if necessary - The compression ratio can be lower than in
--pseudo-losslessmode
However, when using the new encoder (default), you can be sure that compression does not affect image quality. π
In order to be on the safe side, the Lossy Compression Flag is always set to "01" and a new SOP instance UID is assigned (by default) for the old pseudo-lossless encoder. The output of the old and new lossless encoder can also be distinguished by the Derivation Description in the resulting DICOM image, which contains the term "Lossless JPEG compression" for the new and "Pseudo-Lossless JPEG compression" for the old encoder. π
π¦ TRANSFER SYNTAXES π¦
okay so bestie, hereβs the tea on what dcmcjpeg supports for input (dcmfile-in) β every single one, no cap:
LittleEndianImplicitTransferSyntaxβ1.2.840.10008.1.2LittleEndianExplicitTransferSyntaxβ1.2.840.10008.1.2.1DeflatedExplicitVRLittleEndianTransferSyntaxβ1.2.840.10008.1.2.1.99(*)BigEndianExplicitTransferSyntaxβ1.2.840.10008.1.2.2JPEGProcess1TransferSyntaxβ1.2.840.10008.1.2.4.50JPEGProcess2_4TransferSyntaxβ1.2.840.10008.1.2.4.51JPEGProcess6_8TransferSyntaxβ1.2.840.10008.1.2.4.53JPEGProcess10_12TransferSyntaxβ1.2.840.10008.1.2.4.55JPEGProcess14TransferSyntaxβ1.2.840.10008.1.2.4.57JPEGProcess14SV1TransferSyntaxβ1.2.840.10008.1.2.4.70
(*) only if compiled with zlib support enabled π«Ά
and for output (dcmfile-out), the lineup is this cute lil JPEG-only squad:
JPEGProcess1TransferSyntaxβ1.2.840.10008.1.2.4.50JPEGProcess2_4TransferSyntaxβ1.2.840.10008.1.2.4.51JPEGProcess6_8TransferSyntaxβ1.2.840.10008.1.2.4.53JPEGProcess10_12TransferSyntaxβ1.2.840.10008.1.2.4.55JPEGProcess14TransferSyntaxβ1.2.840.10008.1.2.4.57JPEGProcess14SV1TransferSyntaxβ1.2.840.10008.1.2.4.70
π LOGGING π
so the level of logging output from the various command line tools and underlying libraries? yeah, you can pick that. by default, only errors and warnings are written to the standard error stream. using option --verbose also reports informational messages like processing details. option --debug can be used to get more details on the internal activity, e.g. for debugging purposes. other logging levels can be selected using option --log-level. in --quiet mode only fatal errors are reported β and in such very severe error events, the application will usually terminate π. for more details on the different logging levels, see documentation of module "oflog".
in case the logging output should be written to file (optionally with logfile rotation), to syslog (Unix) or the event log (Windows), option --log-config can be used. this configuration file also allows for directing only certain messages to a particular output stream and for filtering certain messages based on the module or application where they are generated. an example configuration file is provided in <etcdir>/logger.cfg β¨
β¨ COMMAND LINE β¨
all command line tools use the following notation for parameters: square brackets enclose optional values (0-1), three trailing dots indicate that multiple values are allowed (1-n), a combination of both means 0 to n values. slay, very demure, very readable π
command line options are distinguished from parameters by a leading + or - sign, respectively. usually, order and position of command line options are arbitrary (i.e. they can appear anywhere). however, if options are mutually exclusive the rightmost appearance is used. this behavior conforms to the standard evaluation rules of common Unix shells.
in addition, one or more command files can be specified using an @ sign as a prefix to the filename (e.g. @command.txt). such a command argument is replaced by the content of the corresponding text file (multiple whitespaces are treated as a single separator unless they appear between two quotation marks) prior to any further evaluation.
please note that a command file cannot contain another command file β no command-file inception, bestie π
this simple but effective approach allows one to summarize common combinations of options/parameters and avoids longish and confusing command lines (an example is provided in file <datadir>/dumppat.txt).
πΈ ENVIRONMENT πΈ
the dcmcjpeg utility will attempt to load DICOM data dictionaries specified in the DCMDICTPATH environment variable. by default, i.e. if the DCMDICTPATH environment variable is not set, the file <datadir>/dicom.dic will be loaded unless the dictionary is built into the application (default for Windows).
the default behavior should be preferred and the DCMDICTPATH environment variable only used when alternative data dictionaries are required. the DCMDICTPATH environment variable has the same format as the Unix shell PATH variable in that a colon (":") separates entries. on Windows systems, a semicolon (";") is used as a separator. the data dictionary code will attempt to load each file specified in the DCMDICTPATH environment variable. it is an error if no data dictionary can be loaded ππ«Ά
π«Ά SEE ALSO π«Ά
go give that one a lil kiss too, iykyk π
π COPYRIGHT π
Copyright (C) 2001-2026 by OFFIS e.V., Escherweg 2, 26121 Oldenburg, Germany.
okay thatβs the whole dcmcjpeg(1) page, bestie β Version 3.7.1, dated Sat Oct 17 2026 09:34:01 πβ¨ bye-bye, go compress something iconic π
π¦
π¦ where this page comes from
- arch rolling: dcmtk 3.7.1-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms