Coder Social home page Coder Social logo

zmesror / imgopt Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5 KB

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: MIT License

Python 100.00%
image-optimisation image-optimizer image-webp image-website python python-script tinify tinify-api tinify-image tinypng

imgopt's Introduction

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

imgopt's People

Contributors

zmesror avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.