diff ViewerPlugin/IIIF.cpp @ 314:9dc7f1e8716d

reverse the order of the "sizes" field in the IIIF manifest
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Aug 2024 15:52:13 +0200
parents 0683312e21ba
children 8ad12abde290
line wrap: on
line diff
--- a/ViewerPlugin/IIIF.cpp	Wed Aug 14 15:43:28 2024 +0200
+++ b/ViewerPlugin/IIIF.cpp	Wed Aug 14 15:52:13 2024 +0200
@@ -127,6 +127,18 @@
     }
   }
 
+  /**
+   * Reversing the order of the "sizes" field seems to be necessary
+   * for recent version of OpenSeadragon (>= 4.1.0) and Mirador (>=
+   * 4.0.0). This fix was included in release 2.1 of the WSI plugin.
+   * https://github.com/openseadragon/openseadragon/issues/2379
+   **/
+  Json::Value reversedSizes = Json::arrayValue;
+  for (Json::Value::ArrayIndex i = sizes.size(); i > 0; i--)
+  {
+    reversedSizes.append(sizes[i - 1]);
+  }
+
   Json::Value tiles;
   tiles["width"] = pyramid.GetTileWidth(0);
   tiles["height"] = pyramid.GetTileHeight(0);
@@ -141,7 +153,7 @@
   result["id"] = iiifPublicUrl_ + "tiles/" + seriesId;
   result["width"] = pyramid.GetLevelWidth(0);
   result["height"] = pyramid.GetLevelHeight(0);
-  result["sizes"] = sizes;
+  result["sizes"] = reversedSizes;
   result["tiles"].append(tiles);
 
   std::string s = result.toStyledString();