This article mainly introduces Python to use Guetzli batch compressed pictures, detailed introduction of Google's Open source image compression Tool Guetzli, very practical value, the need for friends can refer to.
Google also open source, this time an open source of an image algorithm tool Guetzli. Guetzli, a "cookie" in Swiss German, is a JPEG encoder for digital images and web images, capable of achieving a faster online experience by generating smaller JPEG files, while maintaining compatibility with current browsers, image processing applications and JPEG standards. Google says Guetzli creates a high-quality JPEG image file that is 35% smaller than the current compression method.
Today played under the Google's Open source image compression Tool Guetzli, found that the single picture compression effect is still good, wrote a simple Python script, batch compressed pictures
Pre-conditions
1. Install Guetzli, you can use the command line tool
2.python Environment
A simple code
#-*-coding:utf-8-*-import osdir_name = "Picture folder of your choice" Def get_file_name (File_dir): For root, dirs, files in Os.walk (fi Le_dir): print (root) # print (dirs) # Print (files) return filesfiles = Get_file_name (dir_name) print ( files) Os.chdir (dir_name) for file in files: cmd = "Guetzli--quality--verbose" + file + "" + File Os.system (c md
Effect
Before compressing
After compression