• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

pngcrush for image optimization

by admin

Last time we talked about jpegoptim, jpegtran and optipng. Today we’re going to talk about pngcrush – an optimizer for PNG (Portable Network Graphics) files. pngcrush can be run from a command line in an MSDOS window, or from a UNIX or LINUX command line.

Installation of pngcrush

On Debian, this utility is included in packages:

# apt-get install pngcrush

Usage of pngcrush

For maximum compression without loss of quality use this command to compress a png file as much as possible:

# pngcrush -rem alla -rem text -reduce -brute in.png out.png

during this action, in.png file will be optimized and the result saved in out.png

Parameters

1. A simple option for automatic optimization:

# pngcrush -reduce -brute in.png out.png

2. Also, pngcrush can remove all color correction data from a file:

# pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB in.png out.png

3. Data that supported may also be deleted:

# pngcrush -rem alla -rem text in.png out.png

Optimization of all pictures in a folder

For maximum optimization of all images in a folder, use the following command:

for file in * .png
do 
    pngcrush -reduce -brute -rem alla -rem gAMA -rem cHRM -rem iCCP -rem sRGB "$ file" "$ {file% .png} -crushed.png" && mv "$ {file% .png} -crushed .png "" $ file "
done

Filed Under: Linux

Some more articles you might also be interested in …

  1. ncat Command Examples in Linux
  2. lvresize command examples in Linux
  3. Understanding OpenSSH Configuration Files
  4. CentOS / RHEL : How to make iptable rules persist across reboots
  5. Apache HTTP server – most commonly used containers (special configuration directives)
  6. How the BASH Shell load its configuration files in Linux
  7. Understanding rsyslog Filter Options
  8. nixos-container : Command Examples in Linux
  9. CentOS / RHEL : How to install Open Virtual Machine Tools for Virtual machines Hosted on VMWare
  10. pvcreate Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright