Skip to content
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

Possible to generate new extra image sizes only? #56

Open
rlskoeser opened this issue Sep 8, 2022 · 2 comments
Open

Possible to generate new extra image sizes only? #56

rlskoeser opened this issue Sep 8, 2022 · 2 comments

Comments

@rlskoeser
Copy link

Once again I find myself with a good use case for static iiif image content and I'm so glad the spec supports it and this library exists.

I'm wondering if there's a way to generate only the tiles that don't already exist? Specific use case is if I need to add a new extra size across a collection of images — I only want to generate the new one, not regenerate all the others. Maybe that logic could apply to any existing tiles by default? I don't have a sense of how much that would save in terms of processing time.

If it matters, I'm calling from python directly rather than using the command line script (modeled on what the script does). I may be able to contribute code if you're open to a PR and can suggest how this should be done.

@zimeon
Copy link
Owner

zimeon commented Sep 13, 2022

I don't think I'd ever thought of quite this use case. The code and command line script does have the ability to create --extra static files along with the tiles etc.:

> ./iiif_static.py -h
Usage: iiif_static.py [options] file [[file2..]] (-h for help)

IIIF Image API static file generator

Options:
...
  -e EXTRA, --extra=EXTRA
                        Extra request parameters to be used to generate static
                        files, may be repeated (e.g. '/full/90,/0/default.jpg'
                        for a 90 wide thumnail)
...

but no way to exclude the normal tile/scaled image generation. Reminding myself of the code I see that in https://github.com/zimeon/iiif/blob/main/iiif/static.py this is all wrapped up in the generate method, without a way to do some parts and not others. If doing it from code then perhaps you can just call generate_file for the specific requirements.

I'm open to PRs if you want to add the functionality in more generally

@rlskoeser
Copy link
Author

@zimeon yes, I was delighted to find the --extra arg, super helpful for my use case.

Oh, yes, I see I could call generate_file directly if necessary. That could be sufficient.

Right now it seems that the static iiif logic generates all tiles even if some of the files already exist. Would it be reasonable to add a check to see if image files already exist before generating, and skip generating if so? Could be optional / non-default behavior (I guess it should probably not be the default since it's a change from current behavior). I see that there is a check to see if the file exists, but it only comes after the image processing has already been done. What are the potential downsides of skipping regenerating existing derivative image files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants