yBatch is a command-line tool for batch processing images. It allows users to resize images and convert them to WebP format efficiently.
- Batch process images in a directory
- Resize images to specified dimensions
- Convert images to WebP format
- Support for lossless WebP encoding
- Configurable output directory
- Go (version 1.22.0 or later)
- Git
To install yBatch locally:
-
Clone the repository:
git clone https://github.com/Tucupy-Tecnologia/yBatch.git
-
Navigate to the project directory:
cd yBatch
-
Build the project:
go build -o ybatch cmd/main.go
This will create an executable named ybatch
in your current directory.
To use ybatch
from any directory, you can install it globally. The process varies depending on your operating system.
-
Build the program (if you haven't already):
go build -o ybatch cmd/main.go
-
Move the executable to a directory in your PATH:
sudo mv ybatch /usr/local/bin/
-
Set the correct permissions:
sudo chmod +x /usr/local/bin/ybatch
-
Update your shell configuration. For Zsh (default in macOS and Warp):
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
-
For Warp terminal users, you might need to update the Warp configuration:
echo 'env:' >> ~/.warp/launch_configurations.yml echo ' PATH: /usr/local/bin:$PATH' >> ~/.warp/launch_configurations.yml
-
Restart your terminal or Warp application.
-
Verify the installation:
which ybatch
This should output
/usr/local/bin/ybatch
.
-
Build the program:
go build -o ybatch cmd/main.go
-
Move the executable to a directory in your PATH:
sudo mv ybatch /usr/local/bin/
-
Set the correct permissions:
sudo chmod +x /usr/local/bin/ybatch
-
Update your shell configuration (for bash):
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
-
Build the program:
go build -o ybatch.exe cmd/main.go
-
Move the
ybatch.exe
file toC:\Windows\
or another directory in your PATH. -
You may need to restart your command prompt or PowerShell for the changes to take effect.
The basic syntax for using yBatch is:
ybatch <path_to_image_directory> [flags]
-w
: Width of the output images (int)-h
: Height of the output images (int)--output
: Output directory for the processed images (string)--format
: Output format for the images (default "webp")--ar
: Aspect ratio for the output images (e.g., "16:9")--lossless
: Enable lossless WebP encoding (bool)
-
Resize images to 400x400 pixels:
ybatch /path/to/images -w 400 -h 400
-
Convert images to WebP format without resizing:
ybatch /path/to/images
-
Use lossless encoding:
ybatch /path/to/images --lossless
-
Specify an output directory:
ybatch /path/to/images --output /path/to/output
- The program takes the first argument as the path to the directory containing images.
- It then parses the remaining flags to determine the processing options.
- Each image in the specified directory is processed concurrently:
- If width and height are specified, the image is resized.
- The image is then converted to WebP format (either lossless or lossy, depending on the
--lossless
flag).
- Processed images are saved to the output directory (if specified) or to a new directory named "yBatch-output-[original_directory_name]" in the parent directory of the input.
yBatch uses the following external libraries:
- github.com/kolesa-team/go-webp: For WebP encoding
- github.com/nfnt/resize: For image resizing
Contributions to yBatch are welcome! Please feel free to submit a Pull Request.
yBatch is licensed under the MIT License.
If you have any questions, concerns, or need assistance with yBatch, please don't hesitate to reach out to us. We're here to help!
Email: [email protected] GitHub Issues: https://github.com/Tucupy-Tecnologia/yBatch/issues
If you are enjoying some this project in your company, I'd really appreciate a sponsorship, a coffee or a dropped star. That gives me some more time to improve it to the next level.
If you're having trouble running ybatch
after installation:
-
Ensure the executable is in a directory listed in your PATH:
echo $PATH
-
Verify the installation location:
which ybatch
-
Check if the executable has the correct permissions:
ls -l $(which ybatch)
-
If you've made changes to your shell configuration or Warp configuration, make sure to restart your terminal or source the updated configuration file.
If problems persist, please open an issue on the GitHub repository with details about your system and the error you're encountering.