This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pam
Recipients berker.peksag, claw, pam, terry.reedy, trrhodes
Date 2021-04-11.19:23:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618169032.86.0.668627717653.issue42916@roundup.psfhosted.org>
In-reply-to
Content
The DICOM format is indeed very widely used in the medical field and for me it deserves to be added in stdlib. I do not see why it is more specific than rast format which is included. Moreover it should be easy to add because even if the complete format is very complex with all the medical modalities, its enough to test the first 132 bytes of image that should be:
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00DICM' 
Of course, its not enough to test that we have a valid DICOM image, but it is also not the case with other formats.

For example, with this simple corrupted jpeg image :
imghdr.what('dummy', h= b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\xff\xd9')
'jpeg' is returned.

That is why I strongly advocate in favor of adding DICOM format in imghdr.

Pierre-Alain Moret
History
Date User Action Args
2021-04-11 19:23:52pamsetrecipients: + pam, terry.reedy, berker.peksag, trrhodes, claw
2021-04-11 19:23:52pamsetmessageid: <1618169032.86.0.668627717653.issue42916@roundup.psfhosted.org>
2021-04-11 19:23:52pamlinkissue42916 messages
2021-04-11 19:23:52pamcreate