in Orthanc: conversion of dicom images into jpeg

How can I in Orthanc convert DICOM images to JPEG and then export them?

Josef Erni

There is a way to generate small preview images, though that might not
be sufficient for your needs.

GET /instances/{id}/preview
Accept: image/jpeg

(It defaults to PNG, so you need to specify the HTTP Accept header.)

$ sample_instance=
$ http $sample_instance/preview | file -
/dev/stdin: PNG image data, 512 x 512, 8-bit grayscale, non-interlaced
$ http $sample_instance/preview accept:image/jpeg | file -
/dev/stdin: JPEG image data, JFIF standard 1.01, aspect ratio, density
1x1, segment length 16, baseline, precision 8, 512x512, frames 1

Otherwise you can use the /file subresource and leverage external
software to convert the instances.

Hi Josef, we went through something similar here at CMRAD during the build phase of our product. we found that the /preview API was too simplistic (specifically it does not respect the WW and WL baked into the DICOM instance), hence we needed something more robust. after reviewing and testing multiple external libraries to do the same, we found the using DCMTK through an external call provided this most reliable output (the fewest errors to manage).

as a suggestion, as Thibault was saying, you could use /file to get the instance and then call DCMTK externally through:

dcm2pnm -v +Wi 1 +on2

or something similiar (read the DCMTK documentation). the above call will produce a PNG image based on the first set of WW/WL stored within the instance (typically set by the originating device based on the study type).


As a side note, it would be interesting to create an Orthanc plugin that implements such a more advanced DICOM-to-JPEG/PNG conversion by extending the REST API of Orthanc:

Don’t hesitate to contribute!