vseventer / sharp-cli

CLI for sharp.
MIT License
189 stars 20 forks source link

unix error: Is a directory #13

Closed KasiMaru closed 5 years ago

KasiMaru commented 6 years ago

Hi and thanks for the great cli! I've used it before and everything was ok, but now when I'm -i ./big/* -o ./mini resize 200 I'm getting:

vips__file_open_write: unable to open file "/Users/myname/Desktop/mini" for writing
unix error: Is a directory

Am I doing something wrong?

detj commented 6 years ago

I'm getting this error too. Trying to convert a png to jpg.

npx sharp-cli -i ~/Desktop/file.png -o ~/Desktop -f jpg

says

vips__file_open_write: unable to open file "/Users/detj/Desktop" for writing
unix error: Is a directory

And specifying a path

npx sharp-cli -i ~/Desktop/file.png -o ~/Desktop/file.jpg -f jpg

says

vips__file_open_write: unable to open file "/Users/detj/Desktop/file.jpg/file.jpg" for writing
unix error: Not a directory
pdehaan commented 5 years ago

Me too. I'm trying to resize a directory of images so they have a max-width of 100px and am getting the following error (where the output folder ./logos/ already exists):

$ npx sharp-cli -i public/img/logos/*.png -o logos/ resize 100

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.6.1/libvips-8.6.1-darwin-x64.tar.gz
vips__file_open_write: unable to open file "/Users/pdehaan/dev/github/../logos" for writing
unix error: Is a directory
vips__file_open_write: unable to open file "/Users/pdehaan/dev/github/../logos" for writing
unix error: Is a directory
joejemmely commented 5 years ago

Hi @pdehaan, you need the specifiy the output files. npx sharp-cli -i public/img/logos/*.png -o logos/{name}{ext} resize 100 --min

pdehaan commented 5 years ago

@joejemmely Thanks, that seems to get me closer! I didn't see the --min flag in the README, so I'll try digging through the code and see if I can figure out exactly what it's changing.

It seems like without the --min flag, my logos are now being cropped at 100px wide and 100px high (instead of 100px wide and a variable height w/ aspect ratio). If I do add the --min flag, it seems to resize my images so they are a minimum of 100px high (not just wide), so now some of my logos that were 233x26 (1,985 bytes) get resized up to 896x100 (87,308 bytes).

But as it turns out, specifying --max gives me exactly what I wanted! Thanks again!

detj commented 5 years ago

For folks stumbling here, following @joejemmely's comment, I solved my issue like this

$ npx sharp-cli -i ~/Desktop/file.png -o ~/Desktop/{name}.jpg -f jpg

And that did the trick! Thanks @joejemmely

mimecine commented 5 years ago

I wish the {name}{ext} was mentioned in the documentation and in one the examples...