How to get valid image preview without viewer?

The preview functionality sometimes gives invalid images (e.g black screen)
http://localhost:8042/instances/609665c0-c5198aa2-8632476b-a00e0de0-e9075d94/preview

We use this endpoint in the backend to generate pdf, so we can’t use any viewer like Stone Web viewer or OHIF. We can only make requests, get buffer of the image and add it to pdf.

Is there any tool that renders an image correctly and returns it?

Hello,

The /instances/{...}/preview is not dedicated to the rendering of PDF. You must use /instances/{...}/pdf to retrieve the PDF embedded in a DICOM instance (cf. documentation).

Regards,
Sébastien-

Sorry i did’t explain it well. We generate regular pdf of doctor’s conclusion to study. We need to add some images to pdf. We use /preview feature, but sometimes it generates invalid png. In our case we can’t send viewer rendered image from client to backend (like JS canvas.toBlob() or something), so is there any orthanc tool to get image from dicom without viewer on backend?
We’ve tried /instances/…/image-uint8 and image-uint16, but it generates black screen.
Thanks

If you don’t provide a sample DICOM instance for which a preview cannot be generated, we cannot provide any guidance.

Here is anonymized instance.

This image is correctly rendered by Orthanc if you use the /instances/{id}/rendered route in the REST API of Orthanc:

$ curl http://localhost:8042/instances/9e2e5424-31ca7a89-6fcf8d1f-c8a96493-a9a17355/rendered > /tmp/a.png

Wow. Thanks. Because of this response https://groups.google.com/g/orthanc-users/c/CVwYMUwycO8 i thought viewer is required.
Is there any caveats of using /render instead of /preview? I mean why /preview is used in admin dashboard?

/preview only considers the pixel data (which is fine for an administration dashboard), while /rendered takes into account the DICOM tags associated with windowing (which is more adapted to medical applications, even though this could lead to a bad rendering if the DICOM modality has not correctly populated this information). This depends upon your application.

2 Likes