Skip to content

Latest commit

 

History

History
57 lines (33 loc) · 2.66 KB

File metadata and controls

57 lines (33 loc) · 2.66 KB

PNG Image Compression Tool

Description

The PNG Image Compression Tool is a Python program that helps you identify and compress uncompressed PNG image files in a specified folder. It checks each PNG image file in the folder and determines whether it is compressed or uncompressed based on the presence of an alpha channel. Uncompressed images are then automatically compressed using the pngquant command-line tool.

Features

  • Automatic identification of uncompressed PNG image files
  • Compression of uncompressed images using the pngquant command-line tool
  • Supports both Unix-like systems and Windows

Requirements

  • Python 3.x
  • Pillow library (install with pip install Pillow)
  • pngquant command-line tool (available for Unix-like systems and Windows)

Usage

  1. Ensure that Python 3.x is installed on your system.

  2. Install the required Pillow library by running the following command:

    pip install Pillow
    
  3. Install the pngquant command-line tool using the appropriate method for your operating system. Visit the pngquant website for installation instructions.

  4. Download the PNG Image Compression Tool code and save it to your desired location.

  5. Open a command-line interface (Terminal, Command Prompt, etc.) and navigate to the directory where the PNG Image Compression Tool is saved.

  6. Run the program using the following command:

    python png_image_compression.py
    
  7. When prompted, enter the path of the folder containing the PNG images you want to compress.

  8. The program will list the uncompressed image files found in the specified folder.

  9. The program will automatically compress the uncompressed images using the pngquant command-line tool. The original image files will remain, while the compressed image file will have "-fs8" appended to the filename.

  10. Once the compression process is complete, the program will display a message indicating the completion.

Important Notes

  • The PNG Image Compression Tool relies on the pngquant command-line tool for compression. Ensure that pngquant is properly installed and accessible in the command-line environment.

  • It's recommended to make a backup of your original images before running the PNG Image Compression Tool in case you need to revert to the uncompressed versions.

  • The program currently supports PNG images with or without an alpha channel. It detects uncompressed images by examining the image mode. If you have specific requirements for determining compression, you can modify the code accordingly.

  • The code in this program was generated by ChatGPT.