Mengoptimalkan gambar dapat menjadi cara yang cepat dan mudah untuk mengecilkan ukuran file gambar jpeg, menghapus data yang tidak dibutuhkan dalam file. Hal ini dapatmengurangi waktu yang dibutuhkan pengguna untuk men-load gambar ketika mereka berada di web server.
Hal ini juga dapat digunakan untuk menghapus komentar dan exif data dari file, sehingga tidak ada informasi tambahan dalam file, selain gambar itu sendiri.
Jpegoptim
“Jpegoptim” adalah aplikasi gratis yang dapat digunakan untuk mengoptimalkan file gambar jpeg.
untuk instalasi jpegoptim pada server Debian sbb:
$ sudo apt-get install jpegoptim
Menggunakan jpegoptim:
Strip semua exif dan komen
$ jpegoptim --strip-all -t *.jpg
Contoh penggunaannya:
$ jpegoptim --strip-all -t [folder file]/*.jpg image1.jpg 150x129 24bit JFIF [OK] 6225 --> 5543 bytes (10.96%), optimized. image2.jpg 150x23 24bit JFIF [OK] 1822 --> 1437 bytes (21.13%), optimized. image3.jpg 300x47 24bit JFIF [OK] 4970 --> 4533 bytes (8.79%), optimized. image4.jpg 400x63 24bit JFIF [OK] 7601 --> 7079 bytes (6.87%), optimized. image5.jpg 810x129 24bit JFIF [OK] 36794 --> 32829 bytes (10.78%), optimized. Average compression (5 files): 11.70% (6k)
Recursively optimize semua jpeg files:
$ find . -name '*.jpg' | xargs jpegoptim --strip-all
Full Usage Options:
jpegoptim v1.2.3 Copyright (c) Timo Kokkonen, 1996-2009. Usage: jpegoptim [options] -d, --dest= specify alternative destination directory for optimized files (default is to overwrite originals) -f, --force force optimization -h, --help display this help and exit -m[0..100], --max=[0..100] set maximum image quality factor (disables lossless optimization mode, which is by default on) -n, --noaction don't really optimize files, just print results -o, --overwrite overwrite target file even if it exists -p, --preserve preserve file timestamps -q, --quiet quiet mode -t, --totals print totals after processing all files -v, --verbose enable verbose mode (positively chatty) -V, --version print program version --strip-all strip all (Comment & Exif) markers from output file --strip-com strip Comment markers from output file --strip-exif strip Exif markers from output file --strip-iptc strip IPTC markers from output file --strip-icc strip ICC profile markers from output file
OptimPNG
“OptimPNG” adalah aplikasi gratis yang dapat digunakan untuk mengoptimalkan file gambar PNG.
Instalasi OptimPNG pada server Debian sbb:
root@server:~# apt-get install optipng Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: Â optipng 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 90.3 kB of archives. After this operation, 216 kB of additional disk space will be used. Get:1 http://security.debian.org/ wheezy/updates/main optipng amd64 0.6.4-1+deb7u2 [90.3 kB] Fetched 90.3 kB in 0s (241 kB/s) perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = (unset) are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory Selecting previously unselected package optipng. (Reading database ... 56895 files and directories currently installed.) Unpacking optipng (from .../optipng_0.6.4-1+deb7u2_amd64.deb) ... Processing triggers for man-db ... locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory Setting up optipng (0.6.4-1+deb7u2) ...
Proses Selanjutnya Optimalisasi:
root@server:/var/www# optipng data/images/*.png OptiPNG 0.6.4: Advanced PNG optimizer. Copyright (C) 2001-2010 Cosmin Truta. ** Processing: data/images/LiveStream.png 245x220 pixels, 8 bits/pixel, 256 colors (4 transparent) in palette Input IDAT size = 25225 bytes Input file size = 26130 bytes Trying: Â zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 25225 Â Output IDAT size = 25225 bytes (no change) Output file size = 26094 bytes (36 bytes = 0.14% decrease) ** Processing: data/images/captcha.png 168x128 pixels, 8 bits/pixel, 256 colors in palette Input IDAT size = 6513 bytes Input file size = 7366 bytes Trying: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 6513 Â data/images/captcha.png is already optimized. ** Processing: data/images/dot.png 2x2 pixels, 1 bit/pixel, 2 colors (2 transparent) in palette Input IDAT size = 12 bytes Input file size = 101 bytes Trying: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 12 zc = 9 zm = 8 zs = 1 f = 0 IDAT size = 12 zc = 1 zm = 8 zs = 2 f = 0 IDAT size = 12 zc = 9 zm = 8 zs = 3 f = 0 IDAT size = 12 zc = 9 zm = 8 zs = 0 f = 5 IDAT size = 12 zc = 9 zm = 8 zs = 1 f = 5 IDAT size = 12 zc = 1 zm = 8 zs = 2 f = 5 IDAT size = 12 zc = 9 zm = 8 zs = 3 f = 5 IDAT size = 12 data/images/dot.png is already optimized.
Semoga Bermanfaat…