.
This commit is contained in:
+3
-2
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user