diff --git a/lib/dicom.go b/lib/dicom.go index 7640c3e..700f997 100644 --- a/lib/dicom.go +++ b/lib/dicom.go @@ -832,10 +832,21 @@ func getTransferSyntax(data []byte) string { } func isCompressedTransferSyntax(ts string) bool { - return strings.HasPrefix(ts, "1.2.840.10008.1.2.4") + // JPEG family: 1.2.840.10008.1.2.4.x (baseline, extended, lossless, JPEG 2000, etc.) + // JPEG-LS: 1.2.840.10008.1.2.4.80 / .81 + // JPEG 2000 Lossless: 1.2.840.10008.1.2.4.90 + // JPEG 2000 Lossy: 1.2.840.10008.1.2.4.91 + // JPEG 2000 Multi: 1.2.840.10008.1.2.4.92 / .93 + // RLE Lossless: 1.2.840.10008.1.2.5 + // Deflated: 1.2.840.10008.1.2.1.99 + return strings.HasPrefix(ts, "1.2.840.10008.1.2.4") || + ts == "1.2.840.10008.1.2.5" || + ts == "1.2.840.10008.1.2.1.99" } -// decompressDICOM uses gdcmconv to decompress any JPEG-compressed DICOM. +// decompressDICOM uses gdcmconv to decompress any compressed DICOM transfer +// syntax (JPEG, JPEG 2000 Lossless/Lossy, JPEG-LS, RLE, Deflated). +// Requires gdcmconv from libgdcm-tools (apt install libgdcm-tools). func decompressDICOM(dicomPath string) ([]byte, error) { tmpFile := fmt.Sprintf("/tmp/dcm_%d_%d.dcm", os.Getpid(), time.Now().UnixNano()) defer os.Remove(tmpFile)