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

Input file specification on windows - Backslash #83

Closed
regnete opened this issue Apr 20, 2023 · 6 comments
Closed

Input file specification on windows - Backslash #83

regnete opened this issue Apr 20, 2023 · 6 comments

Comments

@regnete
Copy link

regnete commented Apr 20, 2023

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 create out.jpg

Remarks

  • Backslashes in the path of the outut file (-o) are currently already supported. So it should not be hard to fix this issue.
  • When the command 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.
@toomanylogins
Copy link

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

@vseventer
Copy link
Owner

@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
Copy link
Author

regnete commented Apr 24, 2023

@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.

@toomanylogins
Copy link

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>

@regnete
Copy link
Author

regnete commented Apr 24, 2023

@toomanylogins Exactly. The process should quit with an error code in this case.

process.exit(1);

@vseventer
Copy link
Owner

Makes sense - I'll generalize this and throw an error when there are no input files.

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

No branches or pull requests

3 participants