Support Online
Skip to main content

Linux Image Size Reduction: Command Line and Interface Methods

Reis, as the images grow, the disk fills up and the site slows down.
In this guide, we clearly explain the most effective CLI and GUI methods to reduce image file size in Linux.

What Will You Learn in This Guide?

  • Fast and flexible image compression with ImageMagick
  • Optimizing tools specific to PNG and JPG files
  • Drag-and-drop compression with graphical interface
  • Batch image processing logic

1. Reducing Image Size with ImageMagick

ImageMagick is one of the most powerful visual toolsets in the Linux world.
Provides full control with convert and mogrify commands.

Installation

sudo apt install imagemagick -y
  • This command installs the ImageMagick package on Debian/Ubuntu systems.

Compressing by Reducing Quality


convert girdi.jpg -quality 10% cikti.jpg
  • This command reduces the quality, significantly reducing the file size.

To check file sizes:


du -h girdi.jpg cikti.jpg
  • This script shows the space occupied by the files.

Changing Pixel Size (Resize)


convert ornek.png -resize 200x200 yeni_resim.png
  • This command reduces the image to fit the specified dimensions.

If you don't care about aspect ratio:


convert ornek.png -resize 200x200! yeni_resim.png
  • This command ignores the ratio and applies one-to-one measurement.

Changing Image Format


convert gorsel.png gorsel.jpg
  • This command converts the PNG file to JPG format and reduces the size.

2. File Type-Specific Optimization Tools

  1. In some scenarios, format-specific tools are more efficient.

For PNG Files: pngcrush

  • pngcrush optimizes PNG files losslessly.
Installation

sudo apt install pngcrush -y
  • This command installs the pngcrush tool.

Usage

pngcrush -brute girdi.png cikti.png
  • This command passes the PNG file through dozens of compression filters.

For JPG Files: jpegoptim
  • jpegoptim stands out with its ability to determine the target file size.
Installation

sudo apt install jpegoptim -y
  • This command installs the jpegoptim tool.

Compressing by Target Size

jpegoptim --size=20k fotograf.jpg
  • This command tries to reduce the JPG file to approximately 20KB in size.


3. Graphical Interface (GUI) Method with Trimage

  1. Perfect for those who do not want to deal with the terminal.

Setup


sudo apt install trimage -y
  • This command installs the Trimage graphical interface tool.

  1. Open the application, drag and drop the images.
  • Trimage automatically compresses files losslessly.

Frequently Asked Questions (FAQ)

1. Which method saves the most space? The convert -quality method provides the most aggressive reduction.

2. How to batch image? The mogrify command is ideal:


mogrify -quality 80 *.jpg

3. Does changing the format make a difference? Yes. PNG → JPG conversion often provides serious gains.

4. Which one is recommended for servers? CLI tools are faster and automatic.


Result

Reducing the image size in Linux provides both storage and performance. By choosing the right tool, you can maintain quality and increase upload speed.

You can try visual optimization and performance tests with peace of mind on the GenixNode infrastructure 🚀