-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add zoom-format #227
base: master
Are you sure you want to change the base?
Add zoom-format #227
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,9 @@ pub struct Arguments { | |
/// retrying partially failed downloads, or stitching the tiles with an external program. | ||
#[arg(short = 'c', long = "tile-cache")] | ||
pub tile_storage_folder: Option<PathBuf>, | ||
/// A zoom_level image format suffix eg.default.png or default.jpg | ||
#[arg(short = 'f', long = "zoom-format", default_value = "auto")] | ||
pub zoom_format: String, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the option is specific to IIIF, then its name should probably reference it. Maybe something like |
||
} | ||
|
||
impl Default for Arguments { | ||
|
@@ -140,6 +143,7 @@ impl Default for Arguments { | |
connect_timeout: Duration::from_secs(6), | ||
logging: "warn".to_string(), | ||
tile_storage_folder: None, | ||
zoom_format: "".to_string(), | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,13 +54,27 @@ pub struct TileDownloader { | |
pub retries: usize, | ||
pub retry_delay: Duration, | ||
pub tile_storage_folder: Option<PathBuf>, | ||
pub zoom_format: String, | ||
} | ||
|
||
impl TileDownloader { | ||
pub async fn download_tile( | ||
&self, | ||
tile_reference: TileReference, | ||
mut tile_reference: TileReference, | ||
) -> Result<Tile, TileDownloadError> { | ||
if !"auto".eq(&self.zoom_format) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably not the right place to handle that. This option is specific to the iiif dezoomer, isn't it? If it is, then it should be handled in the dezoomer. |
||
if let Ok(regx) = regex::Regex::new(r"default.*") { | ||
let url = regx | ||
.replace( | ||
&tile_reference.url, | ||
&format!("default.{}", self.zoom_format), | ||
) | ||
.to_string(); | ||
|
||
tile_reference.url = url | ||
}; | ||
} | ||
|
||
// The initial delay after which a failed request is retried depends on the position of the tile | ||
// in order to avoid sending repeated "bursts" of requests to a server that is struggling | ||
let n = 100; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type probably shouldn't be String if not all strings are valid. The documentation should explain precisely what this does.