From 397077ac8feec15355ea458701629e7198d6294e Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 21 Nov 2021 10:40:45 +0000 Subject: [PATCH] . --- rapids/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rapids/models.py b/rapids/models.py index 0a1fc425..c1f63bba 100644 --- a/rapids/models.py +++ b/rapids/models.py @@ -457,10 +457,11 @@ class RapidImage(models.Model): if self.image: # Try and read the file as a dicom try: - hash = ",".join(pydicom.dcmread(self.image).pixel_array.tostring()) + hash = ",".join(pydicom.dcmread(self.image).pixel_array.to()) self.is_dicom = True except pydicom.errors.InvalidDicomError: - hash = hashlib.md5(self.image).hexdigest() + with self.image.open("r") as f: + hash = hashlib.md5(f).hexdigest() self.image_md5_hash = hash super().save(*args, **kwargs) # Call the "real" save() method.