A Python application that resizes images to specific dimensions while maintaining their aspect ratio.
This project consists of three main components:
app.py: The main application file that uses theimage_toolsmodule to resize images.image_tools.py: A module that provides functions for resizing images and describing their content using a machine learning model.test.py: A test file that contains unit tests for theimage_toolsmodule.
The application can resize images to specific dimensions (e.g., 11x14, 8x10, 5x7) while maintaining their aspect ratio. It uses the image_tools module to perform the resizing and also provides a function to describe the content of an image using a machine learning model.
To use the application, simply run the app.py file and provide the input image path, output image path, and desired dimensions as arguments.
python app.py --input_image images/cat.png --output_image images/output/cat_11x14.png --width 3300 --height 4200This will resize the cat.png image to 11x14 inches (3300x4200 pixels) and save the output image as cat_11x14.png in the images/output directory.
The test.py file contains unit tests for the image_tools module. To run the tests, simply execute:
python -m unittest test.pyTo install the dependencies required by your project, you can use the following command:
pip install -r requirements.txtAlternatively, you can install the dependencies individually using the following commands:
pip install ollama
pip install pydantic
pip install Pillow