Skip to content
/ imgopt Public

Automatically optimize web images with TinyPNG API using this Python script. Reduce image file sizes for faster web page loading and improved user experience. Easy setup and API key integration.

License

Notifications You must be signed in to change notification settings

zmesror/imgopt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Image Optimization with TinyPNG API

Overview

This Python script automates the process of optimizing images for the web using the TinyPNG API. It's a simple yet powerful tool to reduce image file sizes for faster web page loading and improved user experience.

Features

  • Automatic Image Optimization: The script scans a specified directory, identifies image files, and optimizes them using the TinyPNG API.
  • Output Customization: You can specify the output directory for the optimized images or use default settings.
  • Error Handling: The script handles errors and provides informative error messages in case of issues with image optimization.
  • API Key Management: Easily manage your TinyPNG API key for seamless integration.

Prerequisites

  • Python: This script requires Python to run.
  • TinyPNG API Key: You need to obtain an API key from TinyPNG.

Installation

  1. Clone or download the repository to your local machine.

  2. Install tinify :

    pip install --upgrade tinify

Usage

Create a Configuration File config.json and Add Your TinyPNG API Key

{
    "api_key": "YOUR_API_KEY"
}

To use this script, you can specify the output folder and optional flags for overwriting the output folder.

  • input-folder: Directory containing the original images.
  • -o or --output-folder: Directory to save converted images.
  • -O or --overwrite-output: Overwrite the output folder if it already exists.

Here's an example of how to run the script:

python imgopt.py input_folder -o output_folder

About

Automatically optimize web images with TinyPNG API using this Python script. Reduce image file sizes for faster web page loading and improved user experience. Easy setup and API key integration.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages