Logo

dev-resources.site

for different kinds of informations.

How “Silicon Valley” Inspired Me to Create a Photo Compressor CLI for Web Developers

Published at
1/15/2025
Categories
programming
webdev
javascript
node
Author
j3rry320
Author
8 person written this
j3rry320
open
How “Silicon Valley” Inspired Me to Create a Photo Compressor CLI for Web Developers

Hey there! So I was binging the famous _HBO TV series Silicon Valley _and got inspired to build something related to compression. And here's a thought – have you ever struggled with optimizing images for your website or project? If so, After hacking around for half a day 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.

Photo Compressor

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. I understand it's just a wrapper around sharp but we will be adding features and further optimization down the line

Why Use photo-compressor?

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.

Installation: Get Started in No Time

Installing photo-compressor is a breeze. Choose your favourite package manager:

npm install -g photo-compressor
Enter fullscreen mode Exit fullscreen mode

Or, if you’re a Yarn fan:

yarn global add photo-compressor
Enter fullscreen mode Exit fullscreen mode

Don’t want to install anything globally? No problem! Run it directly using npx:

npx photo-compressor
Enter fullscreen mode Exit fullscreen mode

How to Use It: Commands and Options

Using photo-compressor is straightforward. Here’s the rundown of its commands and options.

Common Options

  • -h, --help: Display help information.

  • -V, --version: Check the current version of the package.

Commands

1. Optimize Local Images

Easily compress images from a local directory:

photo-compressor local --dir <path_to_directory> --output <path_to_output_directory>
Enter fullscreen mode Exit fullscreen mode

Options:

  • -d, --dir <path>: Directory to scan for images (required).

  • -o, --output <path>: Output directory for optimized images (default: ./optimized).

2. Optimize Cloud Images

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>
Enter fullscreen mode Exit fullscreen mode

Options:

  • -u, --url <url>: URL of the image or an array of image URLs (required).

  • -o, --output <path>: Output directory for optimized images (default: ./optimized).

Real-World Examples

Here are some practical examples to get you started:

Optimize Local Images

photo-compressor local --dir ./images --output ./optimized
Enter fullscreen mode Exit fullscreen mode

Optimize Cloud Images

photo-compressor cloud --url ['https://example.com/image1.jpg', 'https://example.com/image2.jpg'] --output ./optimized
Enter fullscreen mode Exit fullscreen mode

A Quick Backstory

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!)

Join the Fun

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.

node Article's
30 articles in total
Favicon
Breaking the Scale Barrier: 1 Million Messages with NodeJS and Kafka
Favicon
assert in Nodejs and its usage in Grida source code
Favicon
Understanding Node.js Cluster: The Core Concepts
Favicon
🌟 A New Adventure Begins! 🛵🍕
Favicon
How “Silicon Valley” Inspired Me to Create a Photo Compressor CLI for Web Developers
Favicon
How Does This Jewelry Customization Site Work? Need Insights!
Favicon
Building a Secure Authentication API with TypeScript, Node.js, and MongoDB
Favicon
Understanding OAuth 1.0a Signature Generation: Postman vs. Node.js Library and Custom Implementation
Favicon
How to Fix the “Record to Delete Does Not Exist” Error in Prisma
Favicon
[Boost]
Favicon
Run NextJS App in shared-hosting cPanel domain!
Favicon
Construindo uma API segura e eficiente com @fastify/jwt e @fastify/mongodb
Favicon
New ways to engage with the stdlib community!
Favicon
Sore Throat: Causes, Symptoms, and Treatment
Favicon
Back to MonDEV 2025
Favicon
🌟 How to Fix Node.js Path Issues in VS Code (Step-by-Step Guide)
Favicon
How to write unit tests and E2E tests for NestJS applications
Favicon
Cookies auto clearing after browser refresh issue , CORS related express cookies issue
Favicon
Exploring TypeScript Support in Node.js v23.6.0
Favicon
Mastering Backend Node.js Folder Structure, A Beginner’s Guide
Favicon
how to setup express api from scratch
Favicon
Load Balancing Node.js Applications with Nginx Upstream Configuration
Favicon
Using LRU Cache in Node.js and TypeScript
Favicon
Welcome to Siitecch! Your Go-To Platform for Beginner-Friendly Full-Stack JavaScript Learning.
Favicon
I Really like Middleware in NodeJs/Express.
Favicon
Your own Telegram bot on NodeJS with TypeScript, Telegraf and Fastify (Part 3)
Favicon
Understanding Node.js Cluster: The Core Concepts
Favicon
JWT Authentication With NodeJS
Favicon
Stream de Arquivo PDF ou Imagem S3 - AWS
Favicon
Understanding Node.js Alpine Versions: A Lightweight Choice for Your Projects

Featured ones: