-
Notifications
You must be signed in to change notification settings - Fork 21
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
resize but keep proportion #23
Comments
I was looking for something like this imagemagick command:
|
Try using the |
Thanks a lot, that was what I was looking for. Is there a way to overwrite the input file, or to set a pattern for naming the out files (something like ${original_name}-resized.jpg)? All what I saw on the README file is that sharp-cli is made for one file at a time (even if bash car use jokers to change multiple files at a time). You can have an example of such pattern in the imagemagick command above. And it seems that overwriting is explicitly forbidden by the cli. Here is an error of the cli when trying to overwrite an input file:
|
You can use url-templates for this - for example |
Is there a way to use sharp and url-templates directly in a CLI? Or is it mandatory to create a js script to use both of them in cunjunction? |
Yes, you can use this right from the CLI - see my last reply for an example. |
You mean, I juste have to install url-templates globally, then to enter the following command: sharp resize 800 600 --fit inside -i ./src/*.jpg -o ./dest/{name}{ext} and It is still not possible to overwrite the source file with this solution, right? |
Everything already comes with the CLI - just try and run the command in my example above. Overwriting the source file is not supported. |
You're right, I tested it and it works perfectly, impressive! Is this feature documented somewhere? The only thing I am missing is overwriting. What a pity... I'll have to find a workaround. |
The CLI used to be able to do that, but I removed support for it since it led to problems with large files. Large files work great with streams, but we cannot use streams when saving to the same file. I might be able to add a |
I understand the limitation that you encountered. But I would be very happy to see this feature back in sharp. |
I created this request in #24. Closing this. |
you could pipe output to 'sponge' and save as same file. Otherwise, input file gets destroyed before reading |
I want to resize a serie of images that are in a directory. I'm using the following command:
Images smaller than 800x800 are just copied in the output directory.
But bigger image are resized to 800x800 (square). What I wanted is that when an image is resized, its ratio is keeped: 800x600 for a landscape, and 600x800 for a portrait.
Have I missed something?
When I have a look at the documentation, I'm not sure if I have to use a height or width parameter or not:
The text was updated successfully, but these errors were encountered: