• 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. Image optimization with webp
  2. How to move /var on a separate disk as a separate mount point (Online)
  3. rm: cannot remove ‘doc/by-app’: Function not implemented (CentOS/RHEL 7)
  4. logname Command Examples in Linux
  5. pvdisplay Command Examples in Linux
  6. How to Change Default Port of Apache On RHEL/CentOS 7
  7. All Linux Compress/Decompress Commands
  8. Difference between the Java heap and native C heap
  9. Understanding SELinux Policies in Linux
  10. How to view past performance with sar in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright