These are chat archives for openseadragon/openseadragon

27th
Apr 2017
Joohansson
@Joohansson
Apr 27 2017 08:00
Hi,
I'm using custom tiles via getTileUrl in tileSources. That works fine, even with tiles on a remote server. Problem arise when the tiles are protected with .htaccess and basic auth. How can I add username and password in my code? I'm using php. I'm looking at the ajaxWithCredentials parameter but I don't understand how to use it or what it's used for. Please help. If I access one tile in browser and enter username and password manunally, the browser remembers the credentials as long as the browser is open and openseadragon works as well. I need a way to enter username/password programetically.
Joohansson
@Joohansson
Apr 27 2017 09:57
I also found this: openseadragon/openseadragon#1055
I'm currently running stable build 2.2.1. Is it possible to build from latest github and use this function?
Joohansson
@Joohansson
Apr 27 2017 13:22

I manage to build this one using grunt: https://github.com/seanich/openseadragon/tree/ajax-tile-loading
Then added this to the viewer:
ajaxWithCredentials: true,
loadTilesWithAjax: true,
ajaxHeaders: {
Authorization: 'Basic '+btoa('username:password')
}

But I stil get 401 (Unauthorized) from the server

foobarable
@foobarable
Apr 27 2017 13:23
Can you check if the headers are sent to the server?
Joohansson
@Joohansson
Apr 27 2017 13:23
I'm nut sure how to do that, it's apache
This is what I get from the server if I try a GET with a REST-console and same authentication and url:
Status Code: 200
Date: Thu, 27 Apr 2017 13:26:28 GMT
Last-Modified: Wed, 29 Mar 2017 12:55:21 GMT
Server: Apache/2.4.10 (Debian)
ETag: "1c6-54bde16da097a"
Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS
Content-Type: image/png
Access-Control-Allow-Credentials: true
Connection: Keep-Alive
Accept-Ranges: bytes
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Content-Length: 454
Keep-Alive: timeout=5, max=100
I think it's correctly set up for CORS
I must go, I'll be back in 16 hours
foobarable
@foobarable
Apr 27 2017 13:28
You can check it in the network console of your browser
Joohansson
@Joohansson
Apr 27 2017 13:31
Cant find in chrome, will try tomorrow with firefox. This is from console: XMLHttpRequest cannot load https://xxxxx Response for preflight has invalid HTTP status code 401
Mike Pence
@mikepence
Apr 27 2017 16:23
is there a setting that I could use to encourage seadragon to preload and cache as many tiles as possible, given a DZI tile source?
Ian Gilman
@iangilman
Apr 27 2017 16:32
@Joohansson I'm afraid I don't know much about what the server wants in this scenario... presumably it is some sort of header. It seems like the Ajax tile loading is the way to go. I'm glad to hear you got grunt building. You're using the #1055 branch, not master, right? And have you verified that the header you're using is the right one to satisfy the .htaccess?
Samuel Allen
@dehuszar
Apr 27 2017 16:35
@iangilman I'm also trying to do something similar, but not user name and password, just a regulary header.Authorization token. Is there a way to add such a header? I'd prefer not to use the forked version, and have seen this: https://github.com/openseadragon/openseadragon/issues/672#issuecomment-116467744, but can't find any documentation around how or where I would add such a header
Ian Gilman
@iangilman
Apr 27 2017 16:36
@mikepence OSD doesn't really have a feature like that. This patch is in the works: openseadragon/openseadragon#1071 ... but it only preloads a specific view. I suppose one hack would be to navigate through a variety of views and preload them all (without showing anything to the user).
@dehuszar are you wanting to load tiles with this header or the DZI file itself? The existing ajaxWithCredentials only works for DZI files and similar (e.g. XML, JSON, etc.) not image files (i.e. the tiles themselves). #1055 is about loading the actual tiles with headers
Samuel Allen
@dehuszar
Apr 27 2017 16:41
@iangilman Yeah, I am in the process of locking down access to the S3 bucket where the tiles live, and I need to be able to demonstrate permissions via an AWS authorization token
Mike Pence
@mikepence
Apr 27 2017 16:42
thanks @iangilman. initializing an invisible OSD instance and programmatically zooming to various levels could work. you can constrain zoom levels for the end user, I assume?
our potential issue is that this app will one day face FDA scrutiny, so we want to avoid as much visual distortion as possible.
Ian Gilman
@iangilman
Apr 27 2017 16:43
@dehuszar Then I think #1055 is your only option, sorry to say. I suppose it's time I ping the author again about finishing it up (unless someone else wants to take on the last bits) so we can merge it in
Mike Pence
@mikepence
Apr 27 2017 16:46
ah, that is answered here, openseadragon/openseadragon#937
Ian Gilman
@iangilman
Apr 27 2017 16:47
@mikepence Distortion such as the blur that shows while a tile is loading? Or distortion from being between exact zoom levels? You can be notified when the user changes zoom level and then you can force the zoom level to one of the natural ones (using a similar formula to what's in #937).
That way you can handle more than just two zoom levels
Mike Pence
@mikepence
Apr 27 2017 16:48
yeah, tile loading blur
Samuel Allen
@dehuszar
Apr 27 2017 16:48
@iangilman Hmm... Those seem like pretty small changes. I have a few more things I need work on before I need to implement the tiles piece. If you haven't heard back from @seanich by then, I may be able to convince my team to allow me the time.
Ian Gilman
@iangilman
Apr 27 2017 16:49
@dehuszar Right on
@mikepence OSD doesn't have a facility to disable showing the low res tiles while the higher res tiles are loading... I guess you'd just show blank space at that time? There is the immediateRender flag, which does so for the initial load, but not for subsequent zooming. Of course pre-caching is probably a good strategy around the whole thing
(Assuming you have the space for it)
If you're really dedicated you could even bring up a "loading" progress bar and not even show anything until all the tiles you want are pre-cached
Mike Pence
@mikepence
Apr 27 2017 16:53
true
I imagine that if, on load of a dzi, I created multiple invisible instances of OSD at the various zoom levels, it would effectively load those tile images into the browser's cache.
just trying to put a finger to the wind of possible solutions, eventually.
or maybe there is even a way to query the dzi data directly and gather a list of images to be fetched. IDK.
in which case, since I am using clojurescript with core.async, it could do that in the background, concurrently.
Ian Gilman
@iangilman
Apr 27 2017 16:58
Indeed... it wouldn't be too hard to run through the DZI and load all the tiles in the background. The DZITileSource can probably even help with getting all the tile URLs
Mike Pence
@mikepence
Apr 27 2017 16:59
noted, thanks
Ian Gilman
@iangilman
Apr 27 2017 16:59
You don't need to create multiple OSD viewers, btw... you can load the same image multiple times into the viewer and resize it in various ways if you prefer
(as another way of getting to all the views of the image)
Of course if you make an off-screen viewer you're not bound by the size of the window
Anyway, if you seriously want all the tiles, just going through the DZI and loading them all yourself might be the most straightforward
Mike Pence
@mikepence
Apr 27 2017 17:00
yeah
Ian Gilman
@iangilman
Apr 27 2017 17:00
You're at the mercy of the browser's cache, but that should be good enough I hope?
Mike Pence
@mikepence
Apr 27 2017 17:01
should be. one does not know what the FDA objects to, until they do. that is way in the future anyway.
Ian Gilman
@iangilman
Apr 27 2017 17:04
Cool... good to look ahead to it though!