Mercurial > hg > orthanc-tests
changeset 569:201e69006cff
WSI: added test_iiif
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 13 Jul 2023 13:33:19 +0200 |
parents | 6399d3a1cd30 |
children | 9d41b7f18be8 |
files | Plugins/WSI/Run.py |
diffstat | 1 files changed, 91 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/WSI/Run.py Thu Jul 13 13:06:38 2023 +0200 +++ b/Plugins/WSI/Run.py Thu Jul 13 13:33:19 2023 +0200 @@ -436,6 +436,97 @@ TestDefaultAccept(s, 'PNG') TestForceAccept(s) + def test_iiif(self): + CallDicomizer([ GetDatabasePath('LenaGrayscale.png'), # Image is 512x512 + '--levels=3', '--tile-width=128', '--tile-height=128' ]) + + self.assertEqual(3, len(DoGet(ORTHANC, '/instances'))) + + s = DoGet(ORTHANC, '/series') + self.assertEqual(1, len(s)) + + uri = '/wsi/iiif/tiles/%s' % s[0] + info = DoGet(ORTHANC, '%s/info.json' % uri) + self.assertEqual('http://iiif.io/api/image/3/context.json', info['@context']) + self.assertEqual('http://iiif.io/api/image', info['protocol']) + self.assertEqual('http://localhost:8042%s' % uri, info['id']) + self.assertEqual('level0', info['profile']) + self.assertEqual('ImageService3', info['type']) + self.assertEqual(512, info['width']) + self.assertEqual(512, info['height']) + + self.assertEqual(3, len(info['sizes'])) + self.assertEqual(512, info['sizes'][0]['width']) + self.assertEqual(512, info['sizes'][0]['height']) + self.assertEqual(256, info['sizes'][1]['width']) + self.assertEqual(256, info['sizes'][1]['height']) + self.assertEqual(128, info['sizes'][2]['width']) + self.assertEqual(128, info['sizes'][2]['height']) + + self.assertEqual(1, len(info['tiles'])) + self.assertEqual(128, info['tiles'][0]['width']) + self.assertEqual(128, info['tiles'][0]['height']) + self.assertEqual([ 1, 2, 4 ], info['tiles'][0]['scaleFactors']) + + # The list of URIs below was generated by "orthanc-wsi/Resources/TestIIIFTiles.py" + + # Level 0 + GetImage(ORTHANC, '/%s/0,0,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/128,0,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/256,0,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/384,0,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/0,128,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/128,128,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/256,128,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/384,128,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/0,256,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/128,256,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/256,256,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/384,256,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/0,384,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/128,384,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/256,384,128,128/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/384,384,128,128/128,128/0/default.jpg' % uri) + + # Level 1 + GetImage(ORTHANC, '/%s/0,0,256,256/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/256,0,256,256/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/0,256,256,256/128,128/0/default.jpg' % uri) + GetImage(ORTHANC, '/%s/256,256,256,256/128,128/0/default.jpg' % uri) + + # Level 2 + i = GetImage(ORTHANC, '/%s/0,0,512,512/128,128/0/default.jpg' % uri) + self.assertEqual(128, i.width) + self.assertEqual(128, i.height) + + uri2 = '/wsi/iiif/series/%s/manifest.json' % s[0] + manifest = DoGet(ORTHANC, uri2) + self.assertEqual('http://iiif.io/api/presentation/3/context.json', manifest['@context']) + self.assertEqual('http://localhost:8042%s' % uri2, manifest['id']) + + self.assertEqual(1, len(manifest['items'])) + self.assertEqual(1, len(manifest['items'][0]['items'])) + self.assertEqual(1, len(manifest['items'][0]['items'][0]['items'])) + + self.assertEqual('Manifest', manifest['type']) + self.assertEqual('Canvas', manifest['items'][0]['type']) + self.assertEqual('AnnotationPage', manifest['items'][0]['items'][0]['type']) + self.assertEqual('Annotation', manifest['items'][0]['items'][0]['items'][0]['type']) + + self.assertEqual(512, manifest['items'][0]['width']) + self.assertEqual(512, manifest['items'][0]['height']) + + body = manifest['items'][0]['items'][0]['items'][0]['body'] + self.assertEqual(1, len(body['service'])) + self.assertEqual('image/jpeg', body['format']) + self.assertEqual('Image', body['type']) + self.assertEqual(512, body['width']) + self.assertEqual(512, body['height']) + self.assertEqual('level0', body['service'][0]['profile']) + self.assertEqual('ImageService3', body['service'][0]['type']) + self.assertEqual('http://localhost:8042%s' % uri, body['service'][0]['id']) + + try: print('\nStarting the tests...') unittest.main(argv = [ sys.argv[0] ] + args.options)