This commit is contained in:
Ross
2021-11-21 10:40:45 +00:00
parent a927a05cf9
commit 397077ac8f
+3 -2
View File
@@ -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.