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

When using --output have option to preserve directory structure #8

Open
pbowyer opened this issue Mar 21, 2022 · 1 comment
Open

When using --output have option to preserve directory structure #8

pbowyer opened this issue Mar 21, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@pbowyer
Copy link
Contributor

pbowyer commented Mar 21, 2022

Thanks for writing this script!

When using

npx avif --input="/path/to/www/assets/**/*.*" --output=/path/to/www/assets-avif --verbose

It would be really nice if there was a built-in way to preserve the input directory structure in the output directory.

We don't want to save the AVIFs to the same folder as the source images as the CMS media browser will show both, but for easy try_files configuration we'd like to mirror the directory structure in the destination. Plus it keeps the folders with a manageable number of images in them.

Example:

/path/to/www/assets/images/foo/bar/baz.jpg => /path/to/www/assets-avif/images/foo/bar/baz.avif

(Having an option to append .avif would also be cool, to mirror how our bash script has been doing it. So the output file name is baz.jpg.avif. That way the try_files usage stays simple.

@lovell
Copy link
Owner

lovell commented Mar 21, 2022

Hi Peter, these are great ideas, very happy to accept a PR for either/both.

The use of input structure to determine output structure should probably be the default behaviour anyway, and therefore a semver major bump.

Making the use of try_files easier is a nice touch but should be opt-in, perhaps via something like an --append-extension or more explicit --try-files option or similar.

@lovell lovell added the enhancement New feature or request label Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants