# HG changeset patch # User Alain Mazy # Date 1635419156 -7200 # Node ID ae643f66462821c43e9ee62953bcfac95e90704e # Parent 1eca4378d76180734129b754223ebe3a8209d11c new option returnUnsupportedImage for /preview & /rendered routes diff -r 1eca4378d761 -r ae643f664628 NEWS --- a/NEWS Mon Oct 25 14:15:20 2021 +0200 +++ b/NEWS Thu Oct 28 13:05:56 2021 +0200 @@ -6,6 +6,16 @@ * New configuration options: - "DicomThreadsCount" to set the number of threads in the embedded DICOM server +REST API +-------- + +* API version upgraded to 16 +* If an image can not be decoced, ../preview and ../rendered routes are now returning + unsupported.png only if the ?returnUnsupportedImage option is specified; otherwise, + it raises a 415 error code. + + + Maintenance ----------- diff -r 1eca4378d761 -r ae643f664628 OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake --- a/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake Mon Oct 25 14:15:20 2021 +0200 +++ b/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake Thu Oct 28 13:05:56 2021 +0200 @@ -37,7 +37,7 @@ # Version of the Orthanc API, can be retrieved from "/system" URI in # order to check whether new URI endpoints are available even if using # the mainline version of Orthanc -set(ORTHANC_API_VERSION "15") +set(ORTHANC_API_VERSION "16") ##################################################################### diff -r 1eca4378d761 -r ae643f664628 OrthancServer/OrthancExplorer/explorer.js --- a/OrthancServer/OrthancExplorer/explorer.js Mon Oct 25 14:15:20 2021 +0200 +++ b/OrthancServer/OrthancExplorer/explorer.js Thu Oct 28 13:05:56 2021 +0200 @@ -1113,7 +1113,7 @@ if (frames.length == 1) { // Viewing a single-frame image - jQuery.slimbox('../instances/' + pageData.uuid + '/preview', '', { + jQuery.slimbox('../instances/' + pageData.uuid + '/preview?returnUnsupportedImage', '', { overlayFadeDuration : 1, resizeDuration : 1, imageFadeDuration : 1 @@ -1125,7 +1125,7 @@ images = []; for (var i = 0; i < frames.length; i++) { - images.push([ '../instances/' + pageData.uuid + '/frames/' + i + '/preview' ]); + images.push([ '../instances/' + pageData.uuid + '/frames/' + i + '/preview?returnUnsupportedImage' ]); } jQuery.slimbox(images, 0, { @@ -1155,7 +1155,7 @@ images = []; for (var i = 0; i < instances.length; i++) { - images.push([ '../instances/' + instances[i].ID + '/preview', + images.push([ '../instances/' + instances[i].ID + '/preview?returnUnsupportedImage', (i + 1).toString() + '/' + instances.length.toString() ]) } diff -r 1eca4378d761 -r ae643f664628 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Mon Oct 25 14:15:20 2021 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Thu Oct 28 13:05:56 2021 +0200 @@ -755,6 +755,7 @@ .SetTag("Instances") .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest") .SetHttpGetArgument("quality", RestApiCallDocumentation::Type_Number, "Quality for JPEG images (between 1 and 100, defaults to 90)", false) + .SetHttpGetArgument("returnUnsupportedImage", RestApiCallDocumentation::Type_Boolean, "Returns an unsupported.png placeholder image if unable to provide the image instead of returning a 415 HTTP error (defaults to false)", false) .SetHttpHeader("Accept", "Format of the resulting image. Can be `image/png` (default), `image/jpeg` or `image/x-portable-arbitrarymap`") .AddAnswerType(MimeType_Png, "PNG image") .AddAnswerType(MimeType_Jpeg, "JPEG image") @@ -817,13 +818,20 @@ } else { - std::string root = ""; - for (size_t i = 1; i < call.GetFullUri().size(); i++) + if (call.HasArgument("returnUnsupportedImage")) { - root += "../"; + std::string root = ""; + for (size_t i = 1; i < call.GetFullUri().size(); i++) + { + root += "../"; + } + + call.GetOutput().Redirect(root + "app/images/unsupported.png"); } - - call.GetOutput().Redirect(root + "app/images/unsupported.png"); + else + { + call.GetOutput().SignalError(HttpStatus_415_UnsupportedMediaType); + } } return; }