Finishing op the TUI version

This commit is contained in:
Mr Finchum 2024-12-28 10:23:03 +00:00 committed by CodeByMrFinchum
parent 2fd144cfd3
commit c1cd798b0d
4 changed files with 34 additions and 38 deletions

View file

@ -1,65 +1,50 @@
# OPTIMA-35
# OPTIMA-35 TUI *version*
## Overview
**OPTIMA-35** (**Organizing, Processing, Tweaking Images and Modifying scanned Analogs from 35mm Film**) is a Python-based project designed to provide a streamlined way to manage and edit metadata and images from analog photography. But can be used for any images.
Fork from **OPTIMA-35** (**Organizing, Processing, Tweaking Images and Modifying scanned Analogs from 35mm Film**) which will preserve the TUI
This project is a *port* of my earlier work, an collection of [bash script](https://gitlab.com/sf-bashscripts/analogphotography), transitioning functionality to a more modular and maintainable design.
The primary focus is on building a terminal-based user interface (TUI). Initially, the interface will utilize `simple_term_menu`, with plans to expand to `textual` for a more dynamic TUI experience in the future.
**Please check** if a new branch is available and read the **changelog** to see the progress and current features of the program. The README might sometimes lag behind.
## **Current Status**
- While the program works and core features are available, there are currently no safety checks in place. For example, the program will write / save an image without verifying if a file with the same name already exists.
- While the program works and core features are available, there are currently some safety checks missing. For example, the program will write / save an image without verifying if a file with the same name already exists.
- Additionally, while EXIF data/metadata should be implemented correctly, there is a possibility of overlooked issues. In the worst case, a program might throw an error when handling EXIF data, though this has not occurred so far.
### Available Features:
- Initial basic TUI functionality using `simple_term_menu` (planned to switch to a different interface later).
- Core features, including image resizing, metadata management, and YAML configuration.
## Key Features
- Intuitive TUI for organizing and editing metadata and image properties.
- Improved modularity with classes split into separate files for flexibility and maintainability.
- Supports essential tasks like reading, editing, and saving EXIF data, as well as resizing and processing images.
- Initial basic TUI functionality using `simple_term_menu`
- Core features:
- resizing
- renaming
- grayscale
- Change brightness
- Change contrast
- Exif management
- Add watermark
**Gif of program in action**
![my-gif](https://gitlab.com/python_projects3802849/optima-35/-/raw/main/media/v0.1.0-demo.gif?ref_type=heads)
![my-gif](https://gitlab.com/python_projects3802849/optima-35-tui/-/raw/main/media/v0.1.0-demo.gif?ref_type=heads)
## Dependencies
To run **OPTIMA-35 TUI**, the following Python libraries are required:
To run **OPTIMA-35**, the following Python libraries are required:
- **textual**: For building TUI (planned future updates).
- **pyyaml**: To handle YAML files for configuration and settings.
- **piexif**: To read, modify, and write EXIF metadata.
- **Pillow**: For image processing.
- **pillow**: For image processing.
- **simple\_term\_menu**: For building the initial TUI interface.
### Installing Dependencies
You can install the dependencies using `pip`:
```bash
pip install textual pyyaml piexif pillow simple-term-menu
pip install pyyaml piexif pillow simple-term-menu
```
Alternatively, you can use `conda` or its alternatives (`anaconda`, `mamba`, `micromamba`):
```bash
conda install -c conda-forge textual pyyaml piexif pillow simple-term-menu
conda install -c conda-forge pyyaml piexif pillow simple-term-menu
```
## Development Approach
Compared to my previous project, [FTL Save Manager](https://gitlab.com/python_projects3802849/ftl-save-manager), this project emphasizes:
- **Enhanced Modularity**: Classes and components are organized into separate files, making the codebase more maintainable and scalable.
- **Improved Design Principles**: Focus on creating reusable and flexible code for future expansion.
- **Slower Code Pushes**: Updates and code releases will be less frequent but of higher quality, ensuring stability and adherence to best practices.
# Use of LLMs
In the interest of transparency, I disclose that Generative AI (GAI) large language models (LLMs), including OpenAIs ChatGPT and Ollama models (e.g., OpenCoder and Qwen2.5-coder), have been used to assist in this project.
@ -71,8 +56,9 @@ In the interest of transparency, I disclose that Generative AI (GAI) large langu
In cases where LLMs contribute directly to code or provide substantial optimizations, such contributions will be disclosed and documented in the relevant sections of the codebase.
mradermacher gguf Q4K-M Instruct version of infly/OpenCoder-1.5B
unsloth gguf Q4K_M Instruct version of both Qwen/QWEN2 1.5B and 3B
**ollama**
- mradermacher gguf Q4K-M Instruct version of infly/OpenCoder-1.5B
- unsloth gguf Q4K_M Instruct version of both Qwen/QWEN2 1.5B and 3B
### References
1. **Huang, Siming, et al.**

View file

@ -1,3 +1,4 @@
# Example file. You can add and remove entries here.
make:
- Nikon
model:

View file

@ -8,7 +8,8 @@ from ui.tui import SimpleTUI
class Optima35:
# The layout of class Optima35 was originally made by ChatGPT, but major adjustments have been made. To remain transparent, I disclose this.
def __init__(self, settings_file, exif_options_file):
self.version = "0.2.0"
self.name = "OPTIMA-35 TUI"
self.version = "0.2.1"
self.utilities = Utilities()
self.image_processor = ImageProcessor()
self.exif_handler = ExifHandler()
@ -132,7 +133,8 @@ class Optima35:
self.settings["output_folder"] = input("Enter path of output folder: ").strip()
self.settings["file_format"] = self.take_input_and_validate(question = "Enter export file format (jpg, png, webp): ", accepted_input = ["jpg", "png", "webp"], accepted_type = str)
self.settings["modifications"] = self.tui.multi_select_menu(
"Select what you want to do", menu_options
f"\n{self.name} v.{self.version} \nSelect what you want to do (esc or q to exit)",
menu_options
)
if "Change EXIF" not in self.settings["modifications"]:
self.settings["copy_exif"] = self.tui.yes_no_menu("Do you want to copy exif info from original file?")

View file

@ -47,13 +47,20 @@ class ImageProcessor:
font = ImageFont.truetype("OpenDyslexic3-Regular.ttf", font_size)
except:
print("Error loading font for watermark, please ensure font is installed...\n")
time.sleep(0.3)
time.sleep(0.1)
return image
c, w, textwidth, textheight, = drawer.textbbox(xy = (0, 0), text = text, font = font) # Getting text size, only need the last two values
x = imagewidth - textwidth - margin
y = imageheight - textheight - margin
drawer.text((x, y), text, font = font)
# thin border
drawer.text((x-1, y), text, font=font, fill=(64, 64, 64))
drawer.text((x+1, y), text, font=font, fill=(64, 64, 64))
drawer.text((x, y-1), text, font=font, fill=(64, 64, 64))
drawer.text((x, y+1), text, font=font, fill=(64, 64, 64))
# Adding text in the desired color
drawer.text((x, y), text, font = font, fill=(255, 255, 255))
return image