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.