Mercurial > hg > orthanc
changeset 4804:ae643f664628
new option returnUnsupportedImage for /preview & /rendered routes
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 28 Oct 2021 13:05:56 +0200 |
parents | 1eca4378d761 |
children | 0a38000b086d |
files | NEWS OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake OrthancServer/OrthancExplorer/explorer.js OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp |
diffstat | 4 files changed, 27 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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 -----------
--- 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") #####################################################################
--- 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() ]) }
--- 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; }