A Collection of Utilities. Not even can be described.
Project description
Elemental Tools
Here you can find a lot of useful tools for designers and developers.
Install guide:
pip install elemental_tools
API
Installation
In order to install and configure the API and the Database, please use the CLI tools as described below:
Generate Environment File
elemental -generate_env -name "Your Company Name"
Now you have to configure the self generated .env to allow access to your database. And activate the tools that you want.
Generate Python Files
elemental -g_api -path "/path/to/output"
Database Installation
After this, you can run the database instructions with the CLI command:
elemental -i -e "path/to/.env"
Now your database and API are configured, but you're still missing the basic project structure.
Extra CLI Commands
Docker Instance
If you're going to run it on a docker container, you can use the command below to make it faster and simple.
elemental -docker -name "Your Company Name"
It will also generate a docker.env file to make easier to run with different settings.
Tools
Image - CLI
One of the greatest advantages is that you're allowed to perform batch changes on image files, or multiple files in a folder.
Supported File Extensions
- png
- jpg
- bmp
- webp
- tiff
- tif
- jp2
- gif
The img command line works with a single file as input or a folder, to allow you to perform recursive operations through image files.
Here is the simple structure of a command using this tool:
img --crop_left 10 --min_scale 50 --file_size 1mb --min_size 1920x1080 "/input/path" -o "/output/path"
In the command above, the tool will crop the image, and reduce it to the desired size which in this case has been set to 1mb.
To make it work smarter, the other parameters such --min_scale and
--min_size were set to avoid that the image gets too much compression and escape our requirements for the project.
Remeber that if we want to also convert the files on this "/input/path" directory, we can simply add the -fmt followed by one of the supported file extensions and voilá!
See the CLI Guide bellow for further information.
Image Tools - CLI Guide
Convert Images:
img -fmt webp "/input/path" -o "/output/path"
With the -fmt or -format arg, you can set any of the available formats such as: png, jpg, bmp, webp, tiff, tif and jp2;
Crop Images:
img --crop_top 50 --crop_bottom 100 --crop_left 680 --crop_right 680 "/input/path" -o "/output/path"
This allows you to crop image in any direction from border to center;
Scale Images:
img -s 200 "/input/path" -o "/output/path"
This allows you to scale images by providing percentage as in the example above;
Compress Images:
The compression algorithm work with scale, dimension and quality parameters
In some cases we need to compress files to a target size. In order to achieve this you can follow the example:
img --max_file_size 1MB "/input/path" -o "/output/path"
You can set a value in MB as the example or in bytes, by providing an integer such as:
img --max_file_size 100000 "/input/path" -o "/output/path"
The algorithm will scale your image to reach the target size. If you want to set a safety zone.
You can set the arguments:
-
--min_scaleLowest scale you want that the compression algorithm applies to your file.
img "/input/path" -o "/output/path" --min_scale 90 --file_size 1mb
-
--min_dimensionLowest Height x Width you want that the compression algorithm applies to your file.
img "/input/path" -o "/output/path" --min_dimension 1920x1080 --file_size 1mb
You can also use the --min_file_size
parameter to set the minimum size you want your files to have.
I hope you enjoy this feature, any suggestions are welcome!
Change Images Quality:
Quality can influence the size of your output file. Although it may vary over different file extensions, you can also control it with our CLI.
img --q 50 "/input/path" -o "/output/path"
You can set a value from 1 to 100 on the -q argument to set the output quality.
Take in charge that the compression algorithm can also change the quality of the output file
Additional Flags and Args
- ``
-R
``
Recursive parameter that allow the program to search nested folders for images to modify
-y
Force any prompt to be bypassed
-y
Force any prompt to be bypassedInternal Packages - Documentation
Featuring:
-
elemental_tools.code:
- countlines: It receives a path and iterates through all .py files in order to count the overall number of lines in the code;
-
elemental_tools.logger:
- Logger: A log module, that has a special feature. It saves the log to a specified file path, separating them by date of occurrence;
-
elemental_tools.db:
In these module you will find a common syntax for the following databases:- mongo: Database abstraction for mongoDB;
- couch: Database abstraction for couchDB;
-
elemental_tools.design:
Provides some useful stuff for designers such as:- video.compressor: It works with a desired size, to compress media files;
- unicode_colors: Provides some unicode colors. To instead of writing '\033[34m' you can just use unicode_colors.blue;
-
elemental_tools.file_manager:
- copytree_with_error_handling: Copy everything in a dir skipping and prompting for errors;
-
elemental_tools.path:
- Relative: Tired of writing relative path functions? Here's a quick way to use it without needing to write and rewrite it.
-
elemental_tools.patterns:
- Patterns: In the patterns class of the
Audio
A python package that will allow you:
audio_path = AudioPath('/path/to/audio.mp3')
recognizer = AudioRecognition(audio_path)
recognizer.language = 'en'
audio_as_string = recognizer.to_string()
Usage Examples:
Logger:
Example:
from elemental_tools.logger import Logger
log_path = "path/to/log" # If you want to generate a log file. Just set the path, and will separate in different files by date automatically.
logger = Logger(app_name='test-app', owner='example', log_path=log_path).log
logger('info', "I miss you.", additional_props='hearth')
# Whenever you add some kwarg to the logger call, it will be encloused in brackets. Like in the output bellow:
Output:
27-11-2023 10:22:17 - [TEST-APP] [EXAMPLE] [HEARTH] [INFO]: I miss you.
Brainiac:
Example:
# Create a Brainiac instance with Grimoire instances
brainiac_instance = Brainiac(grimoire1, grimoire2, threshold_skill=0.60)
# Access the suggested_skill list
print(brainiac_instance.suggested_skill)
# Access the default error message
brain.default_error
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 Distributions
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 elemental_tools-0.0.6.6-py3-none-any.whl.
File metadata
- Download URL: elemental_tools-0.0.6.6-py3-none-any.whl
- Upload date:
- Size: 161.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdbdea6271056c8008c8a34e67ae62c38f9513b1d085a34c643392d85081ff21
|
|
| MD5 |
292846464e28cf85fa32547b76390574
|
|
| BLAKE2b-256 |
79eb080b79a4957e19fba6407a08854500836228c310d496e19de0cb16f86562
|