Closed regnete closed 1 year ago
Do you know if absolute paths are accepted on Windows and Mac ? Something like in posix format
sharp -i F:/path with spaces/source.jpg -o F:/path with spaces/cache/thumb.jpg
@regnete Under the hood, glob
is used to grab the input files, which according to their docs requires: "Glob patterns should always use / as a path separator, even on Windows systems".
@toomanylogins Try quoting the arguments, e.g. sharp -i "F:/path with spaces/source.jpg" -o "F:/path with spaces/cache/thumb.jpg"
@regnete Under the hood,
glob
is used to grab the input files, which according to their docs requires: "Glob patterns should always use / as a path separator, even on Windows systems".
Thanks for this additional info. I assume that simply replacing \
with /
when running on Windows platform won't fix this issue due to escaping/quoting and glob syntax requirements.
Why are backslashes supported when specifying the output file?
What about exiting the process with an error code when to input file cannot be accessed? Currently the process silently exits without creating output file.
Thanks for reply. I am doing as follows on win10 command prompt. No file is output and no error.
F:>cd youdocms_source\node
F:\youdocms_source\node>node sharp -i "F:/youdocms_source/node/test.jpg" -o "F:/youdocms_source/node/cache/test.jpg" resize 200 200
F:\youdocms_source\node>npm list node@ F:\youdocms_source\node +-- firebase-tools@0.1.6 +-- html-minifier@4.0.0 +-- html-to-text@9.0.4 +-- phpunserialize@1.3.0 +-- readability-checker@0.2.1 `-- sharp-cli@4.1.1
F:\youdocms_source\node>
@toomanylogins Exactly. The process should quit with an error code in this case.
process.exit(1);
Makes sense - I'll generalize this and throw an error when there are no input files.
Description
On a Windows cmd shell the input file (
-i
) cannot be specified with backslash in the path.Reproduction
This command will not create
out.jpg
. It silently fails.sharp -i .\source.jpg -o ./out.jpg resize --width 800 --height 800
This command will create
out.jpg
.sharp -i ./source.jpg -o ./out.jpg resize --width 800 --height 800
Expected behaviour
Command
sharp -i .\source.jpg -o ./out.jpg resize --width 800 --height 800
should createout.jpg
Remarks
-o
) are currently already supported. So it should not be hard to fix this issue.sharp -i .\source.jpg -o ./out.jpg resize --width 800 --height 800
fails I expect it to return an error code. Currently it silently fails.