From e213593467fff4bd30f47b2e1dc67d769233bbc0 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 21 Nov 2021 10:56:20 +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 ab2b7fed..966456e1 100644 --- a/rapids/models.py +++ b/rapids/models.py @@ -457,11 +457,12 @@ class RapidImage(models.Model): if self.image: # Try and read the file as a dicom try: + # and generate a hash from the pixel data hash = ",".join(pydicom.dcmread(self.image.path).pixel_array.tostring()) self.is_dicom = True except pydicom.errors.InvalidDicomError: - with self.image.open("r") as f: - hash = hashlib.md5(f).hexdigest() + self.image.file.open() + hash = hashlib.md5(self.image.file).hexdigest() self.image_md5_hash = hash super().save(*args, **kwargs) # Call the "real" save() method.