Hey there! Have you ever struggled with optimizing images for your website or project, I’ve got something exciting: photo-compressor. It’s a command-line tool designed to compress and convert images to the super-light .webp format seamlessly.
This tool is powered by Sharp, which makes it fast and reliable. It helps you optimize media like a pro. Whether you’re working with local files or cloud-hosted images, photo-compressor has your back.
Here’s why you’ll love it:
Optimize Local Images: Compress images in a local directory effortlessly.
Optimize Cloud Images: Process images directly from URLs or even a directory of image URLs.
No Naming Headaches: It’ll automatically handle file name conflicts for you.
Detailed Logs: Get insights on savings and processing time.
Installing photo-compressor is a breeze. Choose your favourite package manager:
npm install -g photo-compressor
Or, if you’re a Yarn fan:
yarn global add photo-compressor
Don’t want to install anything globally? No problem! Run it directly using npx:
npx photo-compressor
Using photo-compressor is straightforward. Here’s the rundown of its commands and options.
-h, --help: Display help information.
-V, --version: Check the current version of the package.
Easily compress images from a local directory:
photo-compressor local --dir <path_to_directory> --output <path_to_output_directory>
Options:
-d, --dir
-o, --output
Do you have images hosted online? Compress them like this:
photo-compressor cloud --url <image_url_OR_array_of_images> --output <path_to_output_directory>
Options:
-u, --url
-o, --output
Here are some practical examples to get you started:
npm install -g photo-compressor
yarn global add photo-compressor
Why did I create this tool? Honestly, I was binge-watching Silicon Valley and got inspired to build something related to compression. It turns out, it’s a neat solution for web developers who need to quickly optimize images for better web performance. (P.S. I’m still a noob, so feedback is always welcome!)
The development community is all about collaboration. If you’ve got ideas to improve this tool or find any bugs, head over to our GitHub repository and contribute!
Happy Coding! Let me know in the comments what you think about the package.
The above is the detailed content of I Created a Photo Compressor CLI Tool. For more information, please follow other related articles on the PHP Chinese website!