.
This commit is contained in:
@@ -66,6 +66,12 @@ def upload_dicom(request, files: List[UploadedFile] = File(...)):
|
|||||||
|
|
||||||
return {"uploaded": uploaded, "duplicates": duplicate}
|
return {"uploaded": uploaded, "duplicates": duplicate}
|
||||||
|
|
||||||
|
@router.post("/generate_image_hash", auth=django_auth)
|
||||||
|
def generate_image_hash(request, id:int):
|
||||||
|
s = SeriesImage.objects.get(pk=id)
|
||||||
|
s.generate_hashes()
|
||||||
|
|
||||||
|
return {"md5": s.image_md5_hash, "blake3": s.image_blake3_hash, "is_dicom": s.is_dicom}
|
||||||
|
|
||||||
@router.post("/clear_dicoms", auth=django_auth)
|
@router.post("/clear_dicoms", auth=django_auth)
|
||||||
def clear_dicoms(request):
|
def clear_dicoms(request):
|
||||||
|
|||||||
@@ -238,6 +238,18 @@ class SeriesImageBase(models.Model):
|
|||||||
info = "File is not a dicom."
|
info = "File is not a dicom."
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
def generate_hashes(self):
|
||||||
|
image_hash, is_dicom = get_image_hash(self.image, hash_type="md5", direct_pixel_data=False)
|
||||||
|
|
||||||
|
self.is_dicom = is_dicom
|
||||||
|
self.image_md5_hash = image_hash
|
||||||
|
|
||||||
|
image_blake3_hash, is_dicom = get_image_hash(self.image, hash_type="blake3", direct_pixel_data=True)
|
||||||
|
self.is_dicom = is_dicom
|
||||||
|
self.image_blake3_hash = image_blake3_hash
|
||||||
|
|
||||||
|
self.save()
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
"""Override save method to add image hash"""
|
"""Override save method to add image hash"""
|
||||||
if self.image:
|
if self.image:
|
||||||
|
|||||||
Reference in New Issue
Block a user