how i decrease image sizes on the terminal (ffmpeg)

Stop Being an Amateur: Resize Your Images on Linux

Still uploading 5MB PNGs to your web portal? That’s not how you build a real product. You’re not optimizing, you’re just throwing resources at a problem like a junior dev. It’s inefficient, it’s slow, and it screams amateur hour. We’re going to fix this, right now, using the Linux terminal. No bloated GUI apps, just pure command-line efficiency.

Why Your Image Sucks

A 2048×2048, 5MB PNG for a web portal isn’t a feature, it’s a bug. This isn’t 1998, and users don’t have infinite bandwidth or patience. That massive file size kills page load times, burns through bandwidth, and will make your users click away faster than you can say “technical debt.” Your goal is speed and responsiveness. A 5MB image for a portal page is the opposite of that.

Choosing Your Dimensions

For a “portal page,” you’re not preparing a billboard. You’re displaying content on a screen, typically a browser. An 800px width is often more than sufficient for most web layouts, providing clarity without excessive data. We’ll maintain the aspect ratio automatically, because nobody wants a stretched or squashed image.

The FFmpeg Hammer

Forget slow, memory-hogging image editors. You’re a developer, so use the tools built for power and automation. ffmpeg isn’t just for video, it handles images with ease. It’s powerful, it’s fast, and it should be installed on your Ubuntu system, ready to go.

Here’s the command that cuts the fat from your PNG:

ffmpeg -i your_large_image.png -vf scale=800:-1 your_resized_image.png

Let’s break that down for the uninitiated:

  • ffmpeg: The command itself.
  • -i your_large_image.png: This specifies your input file. Replace your_large_image.png with the actual path to your monstrous PNG.
  • -vf scale=800:-1: This is the video filter that handles the scaling.
    • scale: The filter function.
    • 800: This sets the output width to 800 pixels.
    • -1: This is crucial. It tells ffmpeg to automatically calculate the height to maintain the original aspect ratio. No distortion.
  • your_resized_image.png: This is the name of your new, optimized output file. Choose something descriptive.

Run this command, and ffmpeg will churn out a web-ready image in seconds, significantly smaller in both dimensions and file size.

Verify Your Work

Don’t just trust the command. Verify.

After running the ffmpeg command, check the new file’s size and dimensions. You can use ls -lh to see the file size:

ls -lh your_resized_image.png

To quickly check the dimensions from the terminal, you might use file or exiftool if installed, or simply open the image to visually inspect it.

Conclusion

Overly large images are a drain on performance and a sign of poor optimization. By using the ffmpeg command with precise scaling, you can quickly transform bloated PNGs into web-friendly assets. This simple terminal command ensures your portal pages load fast, providing a better user experience.

Ready to stop wasting time and start building efficient systems? Connect with us to learn how to optimize your entire development workflow.