Image processor
Project description
⭐ Give a Star!
If you liked my work and want to support me, please give it a star. Thanks!
The problem
When I was starting at the IT area, I pick up some website building projects and then I recognize that performance is a really good issue to improove the amout of leads at your site.
When we are talking about website performance one of the most important thing is the images, images can be a really good vilain because in some scenarious we use a bad format or a incorrect size.
Ideally, we shoud have a single image in some low-size format like WEBP and a common format like JPEG as a fallback, but not only the format is important, if you will open a website at a 1920x1080 pixels screen and the website has a banner image, that image should be 1080 pixels wide, but, if you acess the same site from a smartphone with screen size of 390x844 pixels, doesn't make sense you load an image that are 1080 pixels wide.
So, to have a performance optimized website we should have each userd image in multiples formats and sizes.
What Pymage do?
That project was created with the objective to make that process of resize and reformat images easier, with a single command, you create some versions with different sizes and formats from an image.
🧩 Features
- Resize images.
- Generate images with multiple sizes
- Change image format
- Generate images with multiple formats
- Change image quality
📕 Using
Install (Requires Python >= 3.8)
pip install pymage-processor
Running
After the installation, if you run the command above in your terminal, you should see the manual of usage.
pymage
Output:
usage: pymage [image_files | folder] [-f] [-w] [-q] [-o]
optional arguments:
-h, --help show this help message and exit
args:
-f --format Set the output image formats | -f webp jpeg
-w --width Set the output image sizes | -w 300 600 900
-q --quality Set the output image quality | -q 100
-o --output Set the output dir name for processed images
-v --version Print version info
Enjoy the program! :)
Example of usage:
pymage './images/' -f jpeg webp -w 180 -q 100 -o ./images_processed'
If, when executing this command, you do not see the help command, refer to the item below.
Problem running The installation process put the app in the ~/.local/bin directory so check if you have that directory in the PATH variable.
You can do this by running this command, but you will need to put it in your .bashrc file or equivalent so you don't have to do it every time you open a new terminal
export PATH="$HOME/.local/bin:$PATH"
🧹 Uninstall
pip uninstall pymage-processor
🛠️ Run Locally
1. Clone the project
git clone https://github.com/pymage/pymage.git
2. Go to the project directory
cd pymage
3. Install and run virtualenv
sudo pip3 install virtualenv
mkdir venv
which python3
virtualenv --python='/path/to/python3' venv
source venv/bin/activate
4. Install dependencies
pip install -r requirements.txt
5. Running
python -m src.pymage [pathToImage] -f [formats] -w [sizes] -q [quality]
5.1. Commands
# Help!
python src/pymage --help
# Output
usage: pymage [image_files | folder] [-f] [-w] [-q] [-o]
optional arguments:
-h, --help show this help message and exit
args:
-f --format Set the output image formats | -f webp jpeg
-w --width Set the output image sizes | -w 300 600 900
-q --quality Set the output image quality | -q 100
-o --output Set the output dir name for processed images
-v --version Print version info
Enjoy the program! :)
To stop the virtual environment run: deactivate
Top remove all dependencies run: rm -r venv
🧪 Running Tests
To run tests, run the following command
source venv/bin/activate
pip install -r requirements_dev.txt
pytest -s
🚨 Suport and Bugs Report
If you found a bug, have a feature need, feedback or doubt, just open a issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymage_processor-1.1.1.tar.gz.
File metadata
- Download URL: pymage_processor-1.1.1.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c324f556206472614d9fa0100188944671c5100525cd96cd5df1eeb16527984d
|
|
| MD5 |
e17b83e8d4b0a3c6bced338d08632743
|
|
| BLAKE2b-256 |
9d6eec4da238e76ee2a94197ac2e5cb18f8e2473babede08f4aa642535a85e1f
|
File details
Details for the file pymage_processor-1.1.1-py3-none-any.whl.
File metadata
- Download URL: pymage_processor-1.1.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8423420d1454e56b0f9636510984a645b05b2b89ef7185703426e493e0f657bd
|
|
| MD5 |
660329dc0b8dba1c27b6bd91b40028e1
|
|
| BLAKE2b-256 |
83253cd896ede55bf968024ded62d315ae59c23e4a73c5ff2668b61d9f360eb1
|