Closed oupala closed 4 years ago
I'm turning this into a bug ticket. The dependency used for output format parsing, url-template, is not designed for path parsing. I need to figure out a different solution.
Thanks for adding this feature so fast!
Unfortunately, I did not manage to make it work:
$ npx sharp-cli resize 800 800 --withoutEnlargement true --optimise true --progressive true --withMetadata false --format input --fit inside --input './docs/images/*/.jpg' --output {dir}/{base} info sharp Using cached /home/user/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz ENOENT: no such file or directory, open '/home/user/path/to/website//home/user/path/to/website/docs/images/photos/chambre_balcon.jpg'
Specify --help for available options
As you can see, there seems to be a problem in the path mentionned in the error: the absolute path is considered as a relative one.
It looks like {dir}
is added twice.
My bad - should be fixed now.
It appears to work well.
I still have another problem, but this might require a new issue.
I also want sharp-cli to optimize images that are in a hidden directory.
With bash, I can set how bash behave with setting a specific shopt option:
$ shopt -u dotglob
$ ls docs/**/*.jpg
$
$ shopt -s dotglob
$ ls docs/**/*.jpg
docs/.hidden/image.jpg
$
Is there a way to set a similar option for sharp-cli? If not, could it be possible to add options to set how sharp-cli behave?
$ npx sharp-cli --include-hidden-files
$ npx sharp-cli --include-hidden-directory
It appears that sharp-cli is embedding url-template that allow to use pattern matching in its command line.
It would be great to document that in the README file so that one can discover how to optimize a whole tree hierarchy.
Imagine there is the following tree:
I want to use a command that looks like
npx sharp-cli resize 800 800 --format input --fit inside --input ./directory/**/*.{jpg|png} --output ./directory/
so that all jpg and png images are optimized and resized (if too big).I found that url-template documentation is much too light and does not give much information about available variables.
@vseventer proposed something like
--output "{dir}/{base}"
but I could not succeed to make it work.