Code Monkey home page Code Monkey logo

python-image-conversion's Introduction

Image Conversion with Python

Convert all images in a specified directory to a specified file type (.png | .jpg).

  • To specify the directory that has all the images you want to convert, change the INPUT_PATH variable in ./constants/constants.py. This can be anything, as long as it is a valid path ๐Ÿ˜„.
  • To specify the directory that will contain all the converted images, change the OUTPUT_PATH variables in ./constants/constants.py. Again this can be anything, as long as it is a valid path ๐Ÿ˜„.
  • To specify the output type of all the converted images, change the OUTPUT_FILE_TYPE variable in ./constants/constants.py. This can be any file type supported by the Wand pip library and the ImageMagick suite, which are detailed here:

Installation

  • In your terminal, create a virtual environment (venv) through the following command. Remember to replace the venv's name:
    • python3 -m venv <NAME_OF_YOUR_VIRTUAL_ENVIRONMENT_HERE>
  • Activate your virtual environment with the following command:
    • source <NAME_OF_YOUR_VIRTUAL_ENVIRONMENT_HERE>/bin/activate
  • Once your venv is activated, install all the necessary pip packages detailed in requirements.txt. You can do this by using this command:
    • pip install -r requirements.txt
  • Once this command succeeds, specify the necessary parameters in ./constants/constants.py as detailed above.
  • Run the command below. This will start your image conversion!
    • python image_conversion.py

Notes

  • This script uses python's multiprocessing library as a workaround to the GIL. This helps with scalability, given a case where you have hundreds of images (or more) that you want to convert from one file type to another. This gives a noticeable performance boost :)
  • If you have any suggestions on how to make this script better, please add an issue here:

python-image-conversion's People

Contributors

espitiaandres 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.