zimeon / iiif

IIIF Image API reference implementation and Python library
GNU General Public License v3.0
55 stars 15 forks source link

iiif_static.py tile sizes & mirador #4

Closed edsu closed 9 years ago

edsu commented 9 years ago

I started this in a discussion over on iiif discussion list but perhaps it's easier to track here.

I generated tiles for a 5117 x 3467 JPG using your v0.6.0 branch:

 python iiif_static.py --api-version 2.0 001.jpg --dst 001

Which seemed to work fine. Then I put together a minimal manifest that references the tiles, and pushed it all up to GitHub, with the latest build of mirador (master):

https://edsu.github.io/mirador-test/

It almost seems to work, but Mirador appears to be requesting tile sizes that are slightly different than what are available. For example I can see in the console that Mirador is requesting these URLs that 404:

Did I configure the service incorrectly? Or perhaps there’s a mismatch between Mirador and iiif_static.py regarding tile sizes?

zimeon commented 9 years ago

Can you share the raw image and then I can check with the image and OpenSeadragon alone?

edsu commented 9 years ago

Sure it's up on Github too:

https://github.com/edsu/mirador-test/blob/master/001.jpg

zimeon commented 9 years ago

Hmmm... there do seem to be problems with the right-edge tiles when I run with just OSD : http://resync.library.cornell.edu/iiif/demo-static/001.html . Can see by loading, clicking (+) once, and see there aren't the zoomed tiles for right-hand edge.

The problem is that I'm trying to recreate the client's tile calculation algorithm (including rounding). Need too look at the mismatches in detail...

edsu commented 9 years ago

I happened to notice that mirador (master) builds with openseadragon v1.1.1

https://github.com/IIIF/mirador/blob/master/js/lib/openseadragon.min.js

Is that the version of OpenSeadragon that you tested with @zimeon? I updated my demo to use the latest openseadragon (v2.0.0) and it seems to load the missing tiles, but in a blurred state.

zimeon commented 9 years ago

@edsu - thanks for the patch. Has this continued to work well for you?

I was using OSD 2.0.0 for testing. My inclination is to merge your patch, develop some tests for the sizes it generates and then rework to do the same using integer math (kind of an aesthetic thing for me to avoid floats unless necessary).

edsu commented 9 years ago

Yes, thanks @zimeon. It has been working well. I've generated tiles for about 4000 images so far, and they seem to be working fine w/ the latest Mirador, which is currently bundled with OpenSeadragon v1.1.1. Here are some examples if you want to see them:

If you want I can update it to OpenSeadragon v2 to see how it works? I like the idea for having some tests for this stuff, since visual spot checking isn't really scalable.

zimeon commented 9 years ago

Have run test with current code (42a146c51781372735fc58c0c6ca14947c8e9827) on the 001.jpg image that had problems with before, using OSD v2.0.0-0-472ab42. The logs show show no 404's in tile requests implying that all the tiles OSD is looking for are present.

Details in https://gist.github.com/zimeon/d97bc554ead393b7588d

edsu commented 9 years ago

Nice!

zimeon commented 9 years ago

Integer math version of int(math.ceil(rw/float(sf))) is (rw+sf-1)/sf, sanity check with:

simeon@Cider iiif>more a.py
import math
correct = 0
wrong = 0
for sf in range(1,4000):
    for rw in range(1,4000):
        sw_float = int(math.ceil(rw/float(sf)))
        sw_int = (rw+sf-1)/sf
        if (sw_float==sw_int):
            correct += 1
        else:
            wrong += 1
            print "sf=%d rw=%d sw_float=%d sw_int=%d" % (sf,rw,sw_float,sw_int)
print "Got %d correct, %d wrong" % (correct,wrong)
simeon@Cider iiif>python a.py
Got 15992001 correct, 0 wrong
zimeon commented 9 years ago

Have redone test in https://gist.github.com/zimeon/d97bc554ead393b7588d with the integer math version and still seems fine. Concluding that tile sizes are good (until evidence to the contrary...). Ready for 0.6 release

edsu commented 9 years ago

Let me know if you want me to test, once it's merged in.