Giter Club home page Giter Club logo

images-to-webp's Introduction

Image to WebP

A simple Python script that converts a batch of images of various formats into WebP format.

Formats

Current list of image formats:

  • .png
  • .jpg

Setup

Note: I recommend virtual environments (venv) unless you know what you're doing of course

See the folks here for a very good primer on venvs and how to create your own: RealPython - Python Virtual Environments: A Primer


Clone and Install

First, clone this repo (or download the file itself: main.py)

Afterwards, install the necessary library (Pillow for image manipulation) with your package manager (ie. pip).

$ pip install -r requirements.txt

Creating an input folder

This relies on reading all images within an input folder within the same directory as the script.

If you do not have an input folder, the script will throw an exception to remind you to create an input folder.

Place all images that requires converting into the input folder. Your working directory should look something like this:

py-image-to-webp/
├── input/
  ├── image1.png
  ├── image2.png
  ├── ...
  ├── imageX.jpg
├── requirements.txt
├── main.py         <--- main script!
├── ...

Running the script

Once you have loaded the input folder with your images, run the script. I use wsl to run my python script so your method / operating system will vary:

$ python3 main.py
$
$ Converting image1.jpg
$ Converting image2.jpg
$ ...
$ Converting imageX.png

The script will generator an output folder within the same directory as the script so you should see that folder. Within the output folder, you should see your batch of .webp files and that should be it!

images-to-webp's People

Contributors

hny-codes 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.