Release 2.0.1
Release Note
Dependency Updates
- Replaced
docsaidkit
utilities withcapybara
:- For image resizing and file-handling functionalities.
- Introduced at the start to emphasize its importance in enhancing functionality and performance.
Key Changes and Code Refactoring
Module Renaming and Restructuring
-
Renamed and Refactored Modules:
imgaug.py
was renamed tocustom_aug.py
to better reflect its role in handling custom augmentation functionalities.- Utilities from
base.py
andutils.py
were restructured into more specialized modules for improved code clarity and maintainability:font_utils.py
: Dedicated to font management, including loading, validating fonts, and introducing new functions for Unicode character validation and filtering.text_image_renderer.py
: Handles text-to-image rendering with extensive customization options, including multi-line text support and text stroke features.
- Machine Readable Zone (MRZ) related functions from
mrz.py
andtext2image.py
were consolidated intomrz_generator.py
for streamlined MRZ generation.
-
Introduced New Modules:
font_utils.py
:- Implements font-related operations like loading, filtering, and validating characters against Unicode ranges.
- Added multiple new functions to enhance font validation and improve robustness in character checks.
text_image_renderer.py
:- Enables rendering of text into images with configurable direction, alignment, stroke, and spacing.
- Introduced multi-line text rendering and enhanced text stroke options.
mrz_generator.py
:- Focused exclusively on generating MRZ images with validation for text formatting and spacing.
Functional Enhancements
-
WordCanvas
andRandomWordCanvas
:- Split
WordCanvas
into two dedicated classes:WordCanvas
focuses on static, predictable text rendering.RandomWordCanvas
specializes in dynamic, randomized text and style generation.
- Expanded randomization options for font, color, direction, and spacing.
- Refined logic for image dimension adjustments and text alignment.
- Split
-
MRZGenerator
:- Improved flexibility for generating MRZ text, supporting customizable lines, spacing, and randomization.
- Enhanced character placement accuracy within MRZ images.
-
text2image
:- Added features to control text stroke width and fill color.
- Introduced support for multi-line text rendering.
- Improved text alignment and spacing calculations for better visual rendering.
- Returns metadata such as font path, actual font size, and text direction for enhanced traceability.
Testing Enhancements
-
Comprehensive Test Coverage:
- Introduced new test files:
test_custom_aug.py
:- Validates Shear augmentation under various probabilities and parameter combinations.
test_font_utils.py
:- Ensures font-loading mechanisms and character filtering work as expected.
- Tests new font validation functions thoroughly.
test_mrz_generator.py
:- Tests MRZ generation for types TD1, TD2, and TD3 with text validation.
test_text_image_renderer.py
:- Checks rendering accuracy, including alignment, direction, and text clamping.
- Verifies new multi-line text and text stroke rendering.
test_word_canvas.py
:- Validates
WordCanvas
andRandomWordCanvas
functionalities, covering randomization and image alignment.
- Validates
- Introduced new test files:
-
Advanced Testing Strategies:
- Utilized
pytest.mark.parametrize
for efficient multi-case testing. - Simulated edge cases, including invalid font paths and incorrect text directions.
- Integrated testing for combined functionalities (e.g., Shear and ExampleAug).
- Enhanced error handling to strengthen validation for unsupported characters and corrupted fonts.
- Utilized
Deprecated and Removed Files
- Removed the following obsolete or redundant files:
- Test files:
test_generator.py
,test_imgaug.py
,test_utils.py
. - Modules:
mrz.py
,base.py
,utils.py
,text2image.py
.
- Test files:
Full Changelog: [GitHub Compare Link](1.0.4...2.0.1)