# HG changeset patch # User Sebastien Jodogne # Date 1687851331 -7200 # Node ID f5cb6310e0dc3b524752d4c27343c606898db4b6 # Parent f294780f06420f9c62fe0c021d0e971422c7c851 fix handling of DICOM files without pixel data diff -r f294780f0642 -r f5cb6310e0dc OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Mon Jun 26 13:04:42 2023 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Tue Jun 27 09:35:31 2023 +0200 @@ -4456,9 +4456,9 @@ if (params.mode == OrthancPluginLoadDicomInstanceMode_EmptyPixelData) { - ValueRepresentation vr = parsed->GuessPixelDataValueRepresentation(); - - // Try and retrieve the VR of pixel data from the metadata of the instance + bool hasPixelData = false; + ValueRepresentation pixelDataVR = parsed->GuessPixelDataValueRepresentation(); + { PImpl::ServerContextLock lock(*pimpl_); @@ -4468,13 +4468,14 @@ s, revision, params.instanceId, ResourceType_Instance, MetadataType_Instance_PixelDataVR)) { + hasPixelData = true; if (s == "OB") { - vr = ValueRepresentation_OtherByte; + pixelDataVR = ValueRepresentation_OtherByte; } else if (s == "OW") { - vr = ValueRepresentation_OtherWord; + pixelDataVR = ValueRepresentation_OtherWord; } else { @@ -4482,9 +4483,24 @@ << params.instanceId << ": " << s; } } + else if (lock.GetContext().GetIndex().LookupMetadata( + s, revision, params.instanceId, + ResourceType_Instance, MetadataType_Instance_PixelDataOffset)) + { + // This file was stored by an older version of Orthanc, + // "PixelDataVR" is not available, so use the guess + hasPixelData = true; + } + else + { + hasPixelData = false; + } } - - parsed->InjectEmptyPixelData(vr); + + if (hasPixelData) + { + parsed->InjectEmptyPixelData(pixelDataVR); + } } target.reset(new DicomInstanceFromParsed(parsed.release()));