Open quentinmit opened 4 years ago
This would indeed be very cool! Would you be interested in implementing that and making a pull request? I can provide help and guidance.
I don't know Rust at all so it might be quite difficult. It looks like I would need to change find_zoomlevel
to find_zoomlevels
and return a list of all zoom levels less than or equal to the desired zoom level, and then after a fetch of one zoom level finishes with one or more missing tiles, start over again with a new canvas at the next-smaller zoom level (optimally only downloading tiles that overlap with the missing tiles), then imageops::resize
that up to the larger size, and then imageops::overlay
the two canvases together. (And potentially, repeat this for the next-larger zoom level until all the gaps are filled.)
I think it's probably important to draw the next zoom level to a canvas instead of just trying to resize and clip a single tile, because resizing the tiles separately could produce artifacts at tile edges.
Yes, all of these steps make sense.
Ideally we would break up the huge dezoomify function that currently drives the whole dezoomifying process. We could have a function that accepts a zoom level, a canvas, and the coordinates of the rectangle to fill, and call it repetitively : initially with a rectangle covering the whole image, then with the same canvas and only the missing rectangles, until we have no missing rectangles or no more zoom levels. This represents a consequent amount of work, but would also make it very easy to then implement seemingly unrelated features such as downloading only a small region of an image.
Sometimes there is something wrong upstream and one or more tiles are missing:
It would be really nice if dezoomify-rs could fill in the missing tile with an upscaled version of the next lower zoom, instead of the current black square.