Do not append JPEG 2000 end of codestream marker if already present

This commit is contained in:
RunasSudo 2023-11-23 21:33:21 +11:00
parent d24fbd0503
commit ae015e051e
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 2 additions and 2 deletions

View File

@ -113,8 +113,8 @@ def ev_files_to_dcm_file(study_uid, series_uid, series_number, image_number, inp
block.add_new(0x02, 'OB', msgpack.packb(metadata))
if metadata['imageFormat'] == 0:
# JPEG 2000 - For some reason, the end of codestream tag is missing
ds.PixelData = encapsulate([pixel_data + b'\xff\xd9' for pixel_data in pixel_datas])
# JPEG 2000 - For some reason, the end of codestream marker is (always?) missing
ds.PixelData = encapsulate([pixel_data if pixel_data.endswith(b'\xff\xd9') else pixel_data + b'\xff\xd9' for pixel_data in pixel_datas])
else:
ds.PixelData = encapsulate(pixel_datas)