Mercurial > hg > orthanc-book
diff Sphinx/source/plugins/python.rst @ 706:c62539d00251
Conversions between Orthanc and Python images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 11 Jun 2021 12:42:39 +0200 |
parents | ba2403ebd4b7 |
children | daf07750e901 |
line wrap: on
line diff
--- a/Sphinx/source/plugins/python.rst Fri Jun 11 10:50:45 2021 +0200 +++ b/Sphinx/source/plugins/python.rst Fri Jun 11 12:42:39 2021 +0200 @@ -502,6 +502,26 @@ :language: python +.. _python_pil_conversions: + +Conversions between Orthanc and Python images (new in 3.2) +.......................................................... + +The Python method ``orthanc.Image.GetImageBuffer()`` returns a copy of +the memory buffer of an image that is handled Orthanc. Conversely, the +Python function ``orthanc.CreateImageFromBuffer()`` can be used to +create an Orthanc image from a Python buffer. Taken together, these +two functions can be used to do bidirectional conversions between +Orthanc images and Python images. + +Here is a full working example using PIL/Pillow that shows how to +decode a DICOM instance using Orthanc, then to modify this image using +PIL, and finally to upload the modified image as a new DICOM instance: + +.. literalinclude:: python/pil-conversions.py + :language: python + + .. _python_dicom_scp: Handling DICOM SCP requests (new in 3.2)