Howto

Come ottimizzare le immagini png in linux – linea di comando.

Ottimizziamo le immagini PNG da linea di comando.

Lo so , ci sono software con bellissime gui  che effettuano questa operazione, ma la linea di comando ha sempre il suo fascino ! Quindi vediamo Come ottimizzare immagini PNG.

OptiPNG is a command line tool usato per ottimizzare e comprimere i file  PNG (portable network graphics)  senza perdita della originaria qualità.

Per  Debian e le sue derivate

# apt-get install optipng
o
$ sudo apt-get install optipng

Su  Sistemi RedHat 

# yum install optipng
# dnf install optipng    [su Fedora 22+ versioni]
Ottimizzare immagini PNG
Come ottimizzare immagini PNG

Attenzione: Devi avere epel repository enabled sul tuo  RHEL/CentOS  per installare optipng .

Come si usa

( Ottimizzare immagini PNG )

La sintassi “generale” è la seguente :

$ optipng nomefile.png
$ optipng [options] nomefile.png

Prima di comprimere aiutocomputerhelp.png ,  controlliamo il sup “peseo”:

ls -lh aiutocomputerhelp.png -rw------- 1 help help 350K Jan 19 12:54 aiutocomputerhelp.png

circa s 350K, ora ottimizziamola:

optipng aiutocomputerhelp.png
 OptiPNG 0.6.4: Advanced PNG optimizer. Copyright (C) 2001-2010 Cosmin Truta. ** Processing: tecmint.png 1493x914 pixels, 4x8 bits/pixel, RGB+alpha Reducing image to 3x8 bits/pixel, RGB Input IDAT size = 357525 bytes Input file size = 358098 bytes Trying: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 249211 Selecting parameters: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 249211 Output IDAT size = 249211 bytes (108314 bytes decrease) Output file size = 249268 bytes (108830 bytes = 30.39% decrease)

Fatto !

Convertire l’intero contenuto di una cartella

cd img/
~/img $ optipng *.png
OptiPNG 0.6.4: Advanced PNG optimizer.
Copyright (C) 2001-2010 Cosmin Truta.
** Processing: pippo.png
720x345 pixels, 3x8 bits/pixel, RGB
Input IDAT size = 95151 bytes
Input file size = 95429 bytes
Trying:
zc = 9  zm = 8  zs = 0  f = 0		IDAT size = 81388
Selecting parameters:
zc = 9  zm = 8  zs = 0  f = 0		IDAT size = 81388
Output IDAT size = 81388 bytes (13763 bytes decrease)
Output file size = 81642 bytes (13787 bytes = 14.45% decrease)
** Processing: pluto.png
720x345 pixels, 4x8 bits/pixel, RGB+alpha
Reducing image to 3x8 bits/pixel, RGB
Input IDAT size = 259678 bytes
Input file size = 260053 bytes
Trying:
zc = 9  zm = 8  zs = 0  f = 5		IDAT size = 222479
zc = 9  zm = 8  zs = 1  f = 5		IDAT size = 220311
zc = 1  zm = 8  zs = 2  f = 5		IDAT size = 216744
Selecting parameters:
zc = 1  zm = 8  zs = 2  f = 5		IDAT size = 216744
Output IDAT size = 216744 bytes (42934 bytes decrease)
Output file size = 217035 bytes (43018 bytes = 16.54% decrease)

ah .. c'è sempre il mitico  man optipng

Download