This commit is contained in:
Ross
2021-02-14 17:58:25 +00:00
parent c8020bdba0
commit fc2c64cd76
3 changed files with 40 additions and 11 deletions
+15 -5
View File
@@ -6,7 +6,11 @@ from io import BytesIO
from PIL import Image, ImageFile
import pydicom
from .pydicom_PIL import get_PIL_image
try:
from .pydicom_PIL import get_PIL_image
except:
from pydicom_PIL import get_PIL_image
def image_as_base64(image_file):
"""
@@ -42,11 +46,11 @@ def pil_dicom_image(source, exif_orientation=True, **options):
# return
#source = BytesIO(source.read())
print("start pdi")
# open file with pydicom
ds = pydicom.read_file(source)
image = get_PIL_image(ds)
# return the image file
return get_PIL_image(ds)
#with Image.open(source) as image:
# # Fully load the image now to catch any problems with the image contents.
@@ -58,4 +62,10 @@ def pil_dicom_image(source, exif_orientation=True, **options):
#if exif_orientation:
# image = utils.exif_orientation(image)
return image
def show_PIL(dataset):
"""Display an image using the Python Imaging Library (PIL)"""
im = get_PIL_image(dataset)
im.show()