changeset 264:75d933374805 iiif

preparing to serve non-tiled images with IIIF
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Jul 2023 12:24:46 +0200
parents 14f182958ca7
children dab414e5b520
files ViewerPlugin/IIIF.cpp
diffstat 1 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ViewerPlugin/IIIF.cpp	Mon Jul 10 09:44:28 2023 +0200
+++ b/ViewerPlugin/IIIF.cpp	Mon Jul 10 12:24:46 2023 +0200
@@ -38,9 +38,9 @@
 static std::string  iiifPublicUrl_;
 
 
-static void ServeIIIFImageInfo(OrthancPluginRestOutput* output,
-                               const char* url,
-                               const OrthancPluginHttpRequest* request)
+static void ServeIIIFTiledImageInfo(OrthancPluginRestOutput* output,
+                                    const char* url,
+                                    const OrthancPluginHttpRequest* request)
 {
   std::string seriesId(request->groups[0]);
 
@@ -99,7 +99,7 @@
 
   Json::Value result;
   result["@context"] = "http://iiif.io/api/image/2/context.json";
-  result["@id"] = iiifPublicUrl_ + seriesId;
+  result["@id"] = iiifPublicUrl_ + "tiles/" + seriesId;
   result["profile"] = "http://iiif.io/api/image/2/level0.json";
   result["protocol"] = "http://iiif.io/api/image";
   result["width"] = locker.GetPyramid().GetLevelWidth(0);
@@ -134,7 +134,7 @@
 }
 
 
-static void ServeIIIFImageTile(OrthancPluginRestOutput* output,
+static void ServeIIIFTiledImageTile(OrthancPluginRestOutput* output,
                                const char* url,
                                const OrthancPluginHttpRequest* request)
 {
@@ -268,10 +268,10 @@
 
         if (regionX % physicalTileWidth == 0 &&
             regionY % physicalTileHeight == 0 &&
-            regionWidth <= physicalTileWidth &&
-            regionHeight <= physicalTileHeight &&
-            regionX + regionWidth <= pyramid.GetLevelWidth(0) &&
-            regionY + regionHeight <= pyramid.GetLevelHeight(0))
+            static_cast<unsigned int>(regionWidth) <= physicalTileWidth &&
+            static_cast<unsigned int>(regionHeight) <= physicalTileHeight &&
+            static_cast<unsigned int>(regionX + regionWidth) <= pyramid.GetLevelWidth(0) &&
+            static_cast<unsigned int>(regionY + regionHeight) <= pyramid.GetLevelHeight(0))
         {
           break;
         }
@@ -281,7 +281,7 @@
       {
         throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, "IIIF - Cannot locate the level of interest");
       }
-      else if (cropWidth > pyramid.GetTileWidth(level))
+      else if (static_cast<unsigned int>(cropWidth) > pyramid.GetTileWidth(level))
       {
         throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, "IIIF - Request for a cropping that is too large for the tile size");
       }
@@ -291,7 +291,7 @@
                                               regionX / GetPhysicalTileWidth(pyramid, level),
                                               regionY / GetPhysicalTileHeight(pyramid, level)));
 
-        if (cropWidth < pyramid.GetTileWidth(level))
+        if (static_cast<unsigned int>(cropWidth) < pyramid.GetTileWidth(level))
         {
           toCrop.reset(rawTile->Decode());
           rawTile.reset(NULL);
@@ -309,7 +309,7 @@
     else if (toCrop.get() != NULL)
     {
       assert(rawTile.get() == NULL);
-      assert(cropWidth < toCrop->GetWidth());
+      assert(static_cast<unsigned int>(cropWidth) < toCrop->GetWidth());
 
       Orthanc::ImageAccessor cropped;
       toCrop->GetRegion(cropped, 0, 0, cropWidth, toCrop->GetHeight());
@@ -360,12 +360,12 @@
   const std::string base = iiifPublicUrl_ + seriesId;
 
   Json::Value service;
-  service["id"] = base;
+  service["id"] = iiifPublicUrl_ + "tiles/" + seriesId;
   service["profile"] = "level0";
   service["type"] = "ImageService3";
 
   Json::Value body;
-  body["id"] = base + "/full/max/0/default.jpg";
+  body["id"] = iiifPublicUrl_ + "tiles/" + seriesId + "/full/max/0/default.jpg";
   body["type"] = "Image";
   body["format"] = Orthanc::EnumerationToString(Orthanc::MimeType_Jpeg);
   body["height"] = height;
@@ -418,7 +418,7 @@
 {
   iiifPublicUrl_ = iiifPublicUrl;
 
-  OrthancPlugins::RegisterRestCallback<ServeIIIFImageInfo>("/wsi/iiif/([0-9a-f-]+)/info.json", true);
-  OrthancPlugins::RegisterRestCallback<ServeIIIFImageTile>("/wsi/iiif/([0-9a-f-]+)/([0-9a-z,:]+)/([0-9a-z,!:]+)/([0-9,!]+)/([a-z]+)\\.([a-z]+)", true);
+  OrthancPlugins::RegisterRestCallback<ServeIIIFTiledImageInfo>("/wsi/iiif/tiles/([0-9a-f-]+)/info.json", true);
+  OrthancPlugins::RegisterRestCallback<ServeIIIFTiledImageTile>("/wsi/iiif/tiles/([0-9a-f-]+)/([0-9a-z,:]+)/([0-9a-z,!:]+)/([0-9,!]+)/([a-z]+)\\.([a-z]+)", true);
   OrthancPlugins::RegisterRestCallback<ServeIIIFManifest>("/wsi/iiif/([0-9a-f-]+)/manifest.json", true);
 }