This is a command line program which is compatible with linux, mac and windows 10. This program can resize, optimize, and convert image files as single or bulk.
I needed to make changes to multiple image files for multiple times, so I developed this tool with node.js. It works great for me and I use it in my jobs, so I decided to share it with anybody needed this tool. Enjoy it freely and share your experience with me!
I appriciate Lovell Fuller and contributors for developing sharp package . Without their package i woudn't be able to develope this tool. Thank you guys for making my job easier.
Please pay attention, ALWAYS make a copy of your images before starting the process. I can't take any responsibility if you lose your images with this tool by making mistake in settings or because of program bugs.
If you already installed node.js and npm on your system, you can use this command for installing and using freely.
Usage without installing:
$ npx image-cli-tools [options]
Usage after installing (recommended):
## install
$ npm i -g image-cli-tools
# usage
$ image-cli-tools [options]
# or
$ image-tools [options]
- Download the lastest executable version for windows from here
- Extract zip file
- Copy image-cli-tools.exe into your [system root]
## windows system root: "c:\Windows\" ## or "c:\Windows\system32\"
- Now open your command prompt and enjoy it.
Switch | Simple Form | Description |
---|---|---|
--optimize |
-o | Compresses the images to the extent that the quality is not lost |
--recursive |
-rd | Searches image files in nested sub-directories based on the query |
--percentage |
-p | Used for reducing the size of all images with a certain percenage |
--rewrite |
-rw | Saves the changes on the original files |
--help |
-h | Shows help |
-png |
Converts output file formats to png | |
-jpeg |
-jpg | Converts output file formats to jpg |
-webp |
Converts output file formats to webp | |
-gif |
Converts output file formats to gif | |
-tiff |
Converts output file formats to tiff |
-
[file query]
Writes multiple queries for listing batch files with regex query. File query can be relative or absolute.
## Relative Path Query in Windows ".\images\*.png" ## Absolute Path Query in Windows "C:\images\*.png" ## Relative Path Query in Linux/mac "./images/*.png" ## absolute Path Query in Linux/mac "/home/Downloads/*.png"
-
out
Output file paths which can be either relative or absolute. Output file path can be relative or absolute. Default: ./modified/
- Relative output path will be related to input files path; not the current folder.
- If output path is set to a absolute path, it means that all of the output files are copied in it.
- This parameter can not be used with --rewrite switch simultaneously.
## Example of using patameter out=./resized/
-
width
The exact width of output images in pixel unit.
- If you use --percentage switch, this parameter shoud be 1 to 100 percentage
## Example of using patameter width=1024
-
height
This is exactly the same as width parameter
- If you use both width and height parameter together, your images might probably be cropped.
## Example using with width together width=256 height=256
-
maxwidth
The maximum width of output images in pixel unit. Only if your image width is larger than this limitation, your image will be resized othewise it is not affected
## Example maxwidth=1024
-
maxheight
-
This is exactly the same as maxwidth parameter
## Example maxheight=1024
You can makge changes in bulk images by using regex query inorder to identify which of the destination files get affected. Also you can write multiple destination queries.
All png files in Downloads folder and all gif files in usr directory are affected.
$ image-cli-tools "/home/Downloads/*.png" "/usr/*.gif" [switches and parameters]
All png,jpg,gif files in Downloads folder and sub-directories are affected (Swich -rd use for searching in nested sub-directories)
$ image-cli-tools "/home/Downloads/*.png" "/home/Downloads/*.jpg" "/home/Downloads/*.gif" -rd [switches and parameters]
All png files in current directory are affected.
$ image-cli-tools "./*.png" [switches and parameters]
This tool can resize multiple files simultaneously.
This method keeps images dimensions ratio.
$ image-cli-tools /home/Downloads/*.png width=128
If you want to resize images to certain dimensions you can use width and height together.
$ image-cli-tools /home/Downloads/*.png width=128 height=128
If you want to resize images by percentage you can use width with -p switch together.
$ image-cli-tools /home/Downloads/*.png width=50 -p
If you want to resize images to limited dimensions you can use maxwidth and/or maxheigth.
$ image-cli-tools /home/Downloads/*.png maxwidth=128
This tool can convert png/gif/jpeg/tiff/webp files to eachother.
$ image-cli-tools "./*.tiff" -png
$ image-cli-tools "./*.tiff" "./*.png" "./*.jpg" -webp
$ image-cli-tools "./*.webp" -png out=./converted/
If you want to optimize your images and save more spaces, you can use (-o) switch. This switch can be used with any other parameters and switches simultaneously.
$ image-cli-tools "./*.png" -png
$ image-cli-tools "./*.png" -webp -o
Please open a new issue on GitHub
Image-CLI-Tools is OpenSource and licensed under the Terms of Apache License, Version 2.0. You're welcome to contribute!
Copyright 2021 Ryan @archi
Powered by sharp https://github.com/lovell/sharp
Copyright 2021 Lovell Fuller and contributors.