icoft 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- icoft-0.4.0/.github/workflows/publish.yml +30 -0
- icoft-0.4.0/.gitignore +62 -0
- icoft-0.4.0/.python-version +1 -0
- icoft-0.4.0/CHANGELOG.md +150 -0
- icoft-0.4.0/LICENSE +21 -0
- icoft-0.4.0/PKG-INFO +285 -0
- icoft-0.4.0/README.md +266 -0
- icoft-0.4.0/main.py +6 -0
- icoft-0.4.0/pyproject.toml +62 -0
- icoft-0.4.0/src/icoft/__init__.py +0 -0
- icoft-0.4.0/src/icoft/cli.py +480 -0
- icoft-0.4.0/src/icoft/core/__init__.py +0 -0
- icoft-0.4.0/src/icoft/core/generator.py +426 -0
- icoft-0.4.0/src/icoft/core/processor.py +327 -0
- icoft-0.4.0/src/icoft/core/u2net.py +177 -0
- icoft-0.4.0/src/icoft/platforms/__init__.py +0 -0
- icoft-0.4.0/src/icoft/utils/__init__.py +0 -0
- icoft-0.4.0/tests/__init__.py +0 -0
- icoft-0.4.0/tests/test_cli.py +121 -0
- icoft-0.4.0/tests/test_generator.py +122 -0
- icoft-0.4.0/tests/test_processor.py +125 -0
- icoft-0.4.0/uv.lock +996 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment:
|
|
12
|
+
name: pypi
|
|
13
|
+
url: https://pypi.org/p/icoft
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.x"
|
|
22
|
+
|
|
23
|
+
- name: Install build tools
|
|
24
|
+
run: pip install --upgrade build
|
|
25
|
+
|
|
26
|
+
- name: Build package
|
|
27
|
+
run: python -m build
|
|
28
|
+
|
|
29
|
+
- name: Publish to PyPI
|
|
30
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
icoft-0.4.0/.gitignore
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# macOS
|
|
2
|
+
.DS_Store
|
|
3
|
+
._*
|
|
4
|
+
.AppleDouble
|
|
5
|
+
.LSOverride
|
|
6
|
+
|
|
7
|
+
# Python-generated files
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[oc]
|
|
10
|
+
build/
|
|
11
|
+
dist/
|
|
12
|
+
wheels/
|
|
13
|
+
*.egg-info
|
|
14
|
+
|
|
15
|
+
# IDE and editor files
|
|
16
|
+
.venv
|
|
17
|
+
.ruff_cache
|
|
18
|
+
.lingma/
|
|
19
|
+
.trae/
|
|
20
|
+
.vscode/
|
|
21
|
+
pyrightconfig.json
|
|
22
|
+
|
|
23
|
+
# Test scripts and temporary files
|
|
24
|
+
scripts/
|
|
25
|
+
test_*.png
|
|
26
|
+
test_*.jpg
|
|
27
|
+
|
|
28
|
+
# Example files
|
|
29
|
+
examples/
|
|
30
|
+
*.py[cod]
|
|
31
|
+
*$py.class
|
|
32
|
+
*.so
|
|
33
|
+
.Python
|
|
34
|
+
develop-eggs/
|
|
35
|
+
downloads/
|
|
36
|
+
eggs/
|
|
37
|
+
.eggs/
|
|
38
|
+
lib/
|
|
39
|
+
lib64/
|
|
40
|
+
parts/
|
|
41
|
+
sdist/
|
|
42
|
+
var/
|
|
43
|
+
*.egg-info/
|
|
44
|
+
.installed.cfg
|
|
45
|
+
*.egg
|
|
46
|
+
MANIFEST
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
.coverage
|
|
49
|
+
htmlcov/
|
|
50
|
+
.tox/
|
|
51
|
+
.nox/
|
|
52
|
+
.hypothesis/
|
|
53
|
+
*.cover
|
|
54
|
+
*.pyc
|
|
55
|
+
*.pyo
|
|
56
|
+
*.pyd
|
|
57
|
+
*~
|
|
58
|
+
.venv/
|
|
59
|
+
venv/
|
|
60
|
+
ENV/
|
|
61
|
+
env/
|
|
62
|
+
.env/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.10
|
icoft-0.4.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.4.0] - 2026-04-14
|
|
9
|
+
|
|
10
|
+
### Removed
|
|
11
|
+
- RMBG-1.4 model support (removed due to quality issues)
|
|
12
|
+
- CLI options: `--ai-model`, `--ai-threshold`, `--ai-denoise`, `--hole-fill`, `--hole-fill-threshold`
|
|
13
|
+
- All RMBG-related test scripts in `scripts/` directory
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Simplified AI background removal to use only U²-Net model
|
|
17
|
+
- Improved CLI help text organization (alphabetical order for options)
|
|
18
|
+
- Removed step numbers from processing output
|
|
19
|
+
- Updated command description to mention `-o` option for intermediate output
|
|
20
|
+
|
|
21
|
+
## [0.3.3] - 2026-04-14
|
|
22
|
+
|
|
23
|
+
### Removed
|
|
24
|
+
- Unused dependencies: `opencv-python`, `scipy`, `scikit-image`
|
|
25
|
+
- These were legacy dependencies from previous watermark removal algorithm
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- Streamlined dependency tree for faster installation and smaller package size
|
|
29
|
+
|
|
30
|
+
## [0.3.2] - 2026-04-14
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
- Fix linter warnings for unused cairosvg imports
|
|
34
|
+
- Use `importlib.util.find_spec()` for module availability checks
|
|
35
|
+
- Add None check for cairosvg.svg2png return value
|
|
36
|
+
- Fix import ordering in generator.py
|
|
37
|
+
|
|
38
|
+
## [0.3.1] - 2026-04-13
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- Use source filename for output files instead of hardcoded names (e.g., `cogist17.svg` instead of `04_vectorized.svg`)
|
|
42
|
+
- Replace `open()` with `Path.open()` (PTH123)
|
|
43
|
+
- Add `strict=True` to `zip()` calls (B905)
|
|
44
|
+
- Fix type checking issues (crop_margin None type, vtracer imports)
|
|
45
|
+
|
|
46
|
+
### Removed
|
|
47
|
+
- Unused `import struct` in generator.py
|
|
48
|
+
|
|
49
|
+
## [0.3.0] - 2026-04-12
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
- Full Windows 10/11 ICO support (8 sizes: 16-256px with PNG compression)
|
|
53
|
+
- Complete macOS Retina ICNS support (10 PNG sizes + ICNS container)
|
|
54
|
+
- Official Linux hicolor specification compliance (8 sizes + SVG)
|
|
55
|
+
- Single file output mode (`-o png` / `-o svg`)
|
|
56
|
+
- Platform names in `--platforms` help text
|
|
57
|
+
- Clear error messages for missing arguments
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
- Linux icon sizes to official hicolor spec (removed Android sizes, added 256px)
|
|
61
|
+
- Output directory structure documentation with complete file listing
|
|
62
|
+
- `--output` help text to clarify directory vs single file modes
|
|
63
|
+
- CLI examples to use short parameter `-o`
|
|
64
|
+
|
|
65
|
+
### Removed
|
|
66
|
+
- Complex watermark removal algorithm (`HybridWatermarkRemover`)
|
|
67
|
+
- `-T/--noise-threshold` parameter (smart cutout)
|
|
68
|
+
- `denoise()` method and OpenCV dependency for watermark removal
|
|
69
|
+
- Unrealistic v0.3 roadmap items (batch processing, config files)
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
- Windows ICO generation (Pillow bug - manual implementation)
|
|
73
|
+
- macOS ICNS generation (manual implementation with OSType codes)
|
|
74
|
+
- Missing 256px size in Linux icon set
|
|
75
|
+
- Unclear platform parameter names
|
|
76
|
+
- Added `--output=svg` option to save processing result as single SVG
|
|
77
|
+
- Updated CLI help and documentation with new output parameter design
|
|
78
|
+
|
|
79
|
+
### Removed
|
|
80
|
+
- `-i, --icon` parameter (replaced by `--output=icon`)
|
|
81
|
+
- `-c, --crop` parameter (use `-m/--crop-margin` with explicit value)
|
|
82
|
+
- `-u, --cutout` parameter (functionality merged into noise removal workflow)
|
|
83
|
+
- `-I, --output-intermediate` parameter (redundant with `--output=png`)
|
|
84
|
+
- `--preset` parameter (users can combine parameters directly)
|
|
85
|
+
|
|
86
|
+
### Fixed
|
|
87
|
+
- Default behavior now correctly generates icons when no parameters specified
|
|
88
|
+
- Parameter logic simplified: configuration parameters auto-enable corresponding steps
|
|
89
|
+
|
|
90
|
+
## [0.2.0] - 2026-04-12
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
- Unix-style CLI parameter design with composable short options (`-c`, `-u`, `-t`, `-s`, `-i`)
|
|
94
|
+
- Step control parameters:
|
|
95
|
+
- `-c, --crop`: Crop borders
|
|
96
|
+
- `-u, --cutout`: Smart cutout to extract subject
|
|
97
|
+
- `-t, --transparent`: Make background transparent
|
|
98
|
+
- `-s, --svg`: Vectorize PNG to SVG
|
|
99
|
+
- `-i, --icon`: Generate platform icons (default)
|
|
100
|
+
- Configuration parameters with auto-enable:
|
|
101
|
+
- `-m, --crop-margin`: Custom crop margin (default: 5%)
|
|
102
|
+
- `-T, --cutout-threshold`: Smart cutout sensitivity (0-255, default: 30)
|
|
103
|
+
- `-B, --bg-threshold`: Background removal tolerance (0-255, default: 10)
|
|
104
|
+
- `-S, --svg-speckle`: Filter SVG noise (default: 10)
|
|
105
|
+
- `-P, --svg-precision`: SVG color precision (default: 6)
|
|
106
|
+
- Preset configurations: `--preset=minimal|standard|full|icon`
|
|
107
|
+
- Intermediate output option: `-I, --output-intermediate`
|
|
108
|
+
- Vectorization support with vtracer library
|
|
109
|
+
- SVG background rendering with CairoSVG
|
|
110
|
+
|
|
111
|
+
### Changed
|
|
112
|
+
- **Breaking**: CLI parameter order changed to Unix convention (options first)
|
|
113
|
+
- Removed `--mode` parameter (replaced by step parameter combinations)
|
|
114
|
+
- Default output behavior: last step determines output type
|
|
115
|
+
- Improved edge artifact removal in smart cutout (erosion for both dark and light backgrounds)
|
|
116
|
+
- Removed Gaussian blur from watermark removal to improve vectorization quality
|
|
117
|
+
|
|
118
|
+
### Removed
|
|
119
|
+
- `--smooth-edges` option (redundant with vectorization)
|
|
120
|
+
- `smooth_edges()` method from processor
|
|
121
|
+
- Redundant anti-aliasing code
|
|
122
|
+
|
|
123
|
+
### Fixed
|
|
124
|
+
- Edge artifacts in smart cutout for light backgrounds
|
|
125
|
+
- Black dots in vectorized output (adjusted filter_speckle to 10)
|
|
126
|
+
- SVG background rectangle insertion order
|
|
127
|
+
|
|
128
|
+
## [0.1.0] - 2026-04-11
|
|
129
|
+
|
|
130
|
+
### Added
|
|
131
|
+
- Initial release
|
|
132
|
+
- Core image processing:
|
|
133
|
+
- Automatic border cropping
|
|
134
|
+
- Background to transparent conversion
|
|
135
|
+
- Smart cutout (HybridWatermarkRemover algorithm)
|
|
136
|
+
- Multi-platform icon generation:
|
|
137
|
+
- Windows: `.ico` file (16-256 px)
|
|
138
|
+
- macOS: `.icns` + `icon_512x512.png`
|
|
139
|
+
- Linux: PNG icon set (hicolor theme) + SVG
|
|
140
|
+
- Web: favicon, PWA icons, manifest.json
|
|
141
|
+
- CLI interface with Click and Rich
|
|
142
|
+
- Configuration options: `--margin`, `--platforms`, `--no-crop`, `--no-transparent`
|
|
143
|
+
- Comprehensive test suite (23 tests)
|
|
144
|
+
- Documentation: README.md, project status, design philosophy
|
|
145
|
+
|
|
146
|
+
[Unreleased]: https://github.com/hexin/icoft/compare/v0.2.2-dev...HEAD
|
|
147
|
+
[0.2.2-dev]: https://github.com/hexin/icoft/compare/v0.2.1-dev...v0.2.2-dev
|
|
148
|
+
[0.2.1-dev]: https://github.com/hexin/icoft/compare/v0.2.0...v0.2.1-dev
|
|
149
|
+
[0.2.0]: https://github.com/hexin/icoft/compare/v0.1.0...v0.2.0
|
|
150
|
+
[0.1.0]: https://github.com/hexin/icoft/releases/tag/v0.1.0
|
icoft-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Icoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
icoft-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: icoft
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: From AI Logo to Full-Platform App Icons - CLI Tool
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: click>=8.1.0
|
|
8
|
+
Requires-Dist: numpy>=1.24.0
|
|
9
|
+
Requires-Dist: onnxruntime>=1.19.0
|
|
10
|
+
Requires-Dist: pillow>=10.0.0
|
|
11
|
+
Requires-Dist: rich>=13.0.0
|
|
12
|
+
Requires-Dist: vtracer>=0.6.0
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
16
|
+
Provides-Extra: vector
|
|
17
|
+
Requires-Dist: cairosvg>=2.7.0; extra == 'vector'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Icoft - Icon Forge
|
|
21
|
+
|
|
22
|
+
**From Single Image to Full-Platform App Icons**
|
|
23
|
+
|
|
24
|
+
[](https://www.python.org/downloads/)
|
|
25
|
+
[](https://opensource.org/licenses/MIT)
|
|
26
|
+
[](https://pypi.org/project/icoft/)
|
|
27
|
+
|
|
28
|
+
Icoft is a command-line tool that converts a single image (PNG, JPG, JPEG, WEBP) into icons for all platforms (Windows, macOS, Linux, Web), or performs image processing tasks like cropping, background removal, and vectorization.
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- **Icon Generation**: Complete icon sets for Windows, macOS, Linux, and Web
|
|
33
|
+
- **Image Cropping**: Manual border removal with customizable margins
|
|
34
|
+
- **Background Removal**: Convert solid-color backgrounds to transparent
|
|
35
|
+
- **Vectorization**: High-quality PNG to SVG conversion (vector tracing or embedded PNG)
|
|
36
|
+
- **Flexible Output**: Generate full icon sets or single processed images
|
|
37
|
+
- **CLI Friendly**: Unix-style composable parameters with Rich terminal output
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Clone the repository
|
|
43
|
+
git clone <repository-url>
|
|
44
|
+
cd icoft
|
|
45
|
+
|
|
46
|
+
# Install with uv (recommended)
|
|
47
|
+
uv sync
|
|
48
|
+
|
|
49
|
+
# Or install with pip
|
|
50
|
+
pip install -e .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Generate full icon set (default)
|
|
57
|
+
icoft source_file.png dest_dir/
|
|
58
|
+
|
|
59
|
+
# Crop and generate icons
|
|
60
|
+
icoft -m 10% source_file.png dest_dir/
|
|
61
|
+
|
|
62
|
+
# Background removal + crop + icons
|
|
63
|
+
icoft -m 10% -t source_file.png dest_dir/
|
|
64
|
+
|
|
65
|
+
# Output single processed PNG
|
|
66
|
+
icoft -m 10% source_file.png output.png -o png
|
|
67
|
+
|
|
68
|
+
# Output single SVG (auto-vectorizes with vector tracing)
|
|
69
|
+
icoft source_file.png output.svg -o svg
|
|
70
|
+
|
|
71
|
+
# Output single SVG with embedded PNG (preserves gradients perfectly)
|
|
72
|
+
icoft source_file.png output.svg -s embed -o svg
|
|
73
|
+
|
|
74
|
+
# Crop + background removal + SVG
|
|
75
|
+
icoft -m 10% -t source_file.png output.svg -o svg
|
|
76
|
+
|
|
77
|
+
# Generate icons for specific platforms only
|
|
78
|
+
icoft source_file.png icons/ -p windows,web
|
|
79
|
+
icoft source_file.png icons/ -p macos,linux
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Usage Examples
|
|
83
|
+
|
|
84
|
+
### Example 1: Generate Full Icon Set
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Generate icons for all platforms
|
|
88
|
+
icoft source_file.png dest_dir/
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Output structure:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
dest_dir/
|
|
95
|
+
├── windows/
|
|
96
|
+
│ └── app.ico # Windows ICO (8 sizes: 16-256px)
|
|
97
|
+
├── macos/
|
|
98
|
+
│ ├── app.icns # macOS ICNS container
|
|
99
|
+
│ ├── icon_16x16.png # 16×16 @1x
|
|
100
|
+
│ ├── icon_16x16@2x.png # 16×16 @2x (32×32)
|
|
101
|
+
│ ├── icon_32x32.png # 32×32 @1x
|
|
102
|
+
│ ├── icon_32x32@2x.png # 32×32 @2x (64×64)
|
|
103
|
+
│ ├── icon_128x128.png # 128×128 @1x
|
|
104
|
+
│ ├── icon_128x128@2x.png # 128×128 @2x (256×256)
|
|
105
|
+
│ ├── icon_256x256.png # 256×256 @1x
|
|
106
|
+
│ ├── icon_256x256@2x.png # 256×256 @2x (512×512)
|
|
107
|
+
│ ├── icon_512x512.png # 512×512 @1x
|
|
108
|
+
│ └── icon_512x512@2x.png # 512×512 @2x (1024×1024)
|
|
109
|
+
├── linux/
|
|
110
|
+
│ └── hicolor/
|
|
111
|
+
│ ├── 16x16/apps/app.png
|
|
112
|
+
│ ├── 22x22/apps/app.png
|
|
113
|
+
│ ├── 24x24/apps/app.png
|
|
114
|
+
│ ├── 32x32/apps/app.png
|
|
115
|
+
│ ├── 48x48/apps/app.png
|
|
116
|
+
│ ├── 64x64/apps/app.png
|
|
117
|
+
│ ├── 128x128/apps/app.png
|
|
118
|
+
│ ├── 256x256/apps/app.png
|
|
119
|
+
│ └── scalable/apps/app.svg
|
|
120
|
+
└── web/
|
|
121
|
+
├── favicon.ico # Browser favicon
|
|
122
|
+
├── apple-touch-icon.png # iOS home screen icon
|
|
123
|
+
├── icon-192x192.png # PWA icon
|
|
124
|
+
├── icon-512x512.png # PWA icon
|
|
125
|
+
└── manifest.json # PWA manifest
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Example 2: Crop and Remove Background
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# For images with solid-color borders and backgrounds
|
|
132
|
+
icoft -m 10% -t source_file.png dest_dir/
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
This performs:
|
|
136
|
+
|
|
137
|
+
1. Crop borders with 10% margin
|
|
138
|
+
2. Make background transparent
|
|
139
|
+
3. Generate full icon set
|
|
140
|
+
|
|
141
|
+
### Example 3: Output Single Processed Image
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Crop and save as PNG
|
|
145
|
+
icoft -m 10% source_file.png cropped.png -o png
|
|
146
|
+
|
|
147
|
+
# Background removal and save as PNG
|
|
148
|
+
icoft -t source_file.png transparent.png -o png
|
|
149
|
+
|
|
150
|
+
# Crop + background removal + vectorization to SVG
|
|
151
|
+
icoft -m 10% -t source_file.png output.svg -o svg
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Example 4: CI/CD Pipeline
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
# .github/workflows/release.yml
|
|
158
|
+
- name: Generate icons
|
|
159
|
+
run: |
|
|
160
|
+
pip install icoft
|
|
161
|
+
icoft logo.png resources/icons/
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Command-Line Options
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
Usage: icoft [OPTIONS] SOURCE_FILE DEST_DIR
|
|
168
|
+
icoft [OPTIONS] SOURCE_FILE OUTPUT_FILE -o FORMAT
|
|
169
|
+
|
|
170
|
+
Icoft - From Single Image to Full-Platform App Icons.
|
|
171
|
+
|
|
172
|
+
Output Modes:
|
|
173
|
+
DEST_DIR Generate full icon set for selected platforms
|
|
174
|
+
OUTPUT_FILE -o png Save processed image as single PNG
|
|
175
|
+
OUTPUT_FILE -o svg Save processed image as single SVG (auto-vectorizes)
|
|
176
|
+
|
|
177
|
+
Options:
|
|
178
|
+
-m, --crop-margin Margin for cropping (e.g., 5%, 10px)
|
|
179
|
+
-t, --transparent Make background transparent
|
|
180
|
+
-B, --bg-threshold=10 Background threshold (0-255)
|
|
181
|
+
-s, --svg=normal Enable SVG output: normal (vector tracing) or embed (PNG in SVG)
|
|
182
|
+
-S, --svg-speckle=10 Filter SVG noise (1-100, only for 'normal' mode)
|
|
183
|
+
-P, --svg-precision=6 SVG color precision (1-16, only for 'normal' mode)
|
|
184
|
+
-o, --output=icon Output format: icon, png, svg
|
|
185
|
+
-p, --platforms=all Platforms: windows, macos, linux, web
|
|
186
|
+
-V, --version Show version
|
|
187
|
+
-h, --help Show help message
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Development
|
|
191
|
+
|
|
192
|
+
### Setup Development Environment
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Install with dev dependencies
|
|
196
|
+
uv sync --extra dev
|
|
197
|
+
|
|
198
|
+
# Run tests
|
|
199
|
+
uv run pytest tests/ -v
|
|
200
|
+
|
|
201
|
+
# Run linter
|
|
202
|
+
uv run ruff check .
|
|
203
|
+
|
|
204
|
+
# Run formatter
|
|
205
|
+
uv run ruff format .
|
|
206
|
+
|
|
207
|
+
# Run type checker
|
|
208
|
+
uv run pyright .
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Project Structure
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
icoft/
|
|
215
|
+
├── src/icoft/
|
|
216
|
+
│ ├── cli.py # CLI entry point
|
|
217
|
+
│ ├── core/
|
|
218
|
+
│ │ ├── processor.py # Image preprocessing
|
|
219
|
+
│ │ └── generator.py # Icon generation
|
|
220
|
+
│ └── platforms/ # Platform-specific modules
|
|
221
|
+
├── tests/
|
|
222
|
+
│ ├── test_cli.py
|
|
223
|
+
│ ├── test_processor.py
|
|
224
|
+
│ └── test_generator.py
|
|
225
|
+
├── docs/
|
|
226
|
+
└── examples/
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Roadmap
|
|
230
|
+
|
|
231
|
+
### v0.3.2 (Current)
|
|
232
|
+
|
|
233
|
+
- ✅ Unix-style CLI parameter design
|
|
234
|
+
- ✅ Step-by-step processing control
|
|
235
|
+
- ✅ Dual-mode SVG generation: `normal` (vector tracing for lossless scaling) and `embed` (PNG embedding for gradient preservation)
|
|
236
|
+
- ✅ Smart cutout improvements
|
|
237
|
+
- ✅ Edge artifact removal
|
|
238
|
+
- ✅ Configuration parameters with auto-enable
|
|
239
|
+
- ✅ Single file output mode (-o png/svg)
|
|
240
|
+
- ✅ Improved CLI help and error messages
|
|
241
|
+
- ✅ AI-based background removal (U²-Net)
|
|
242
|
+
|
|
243
|
+
### v0.5.0 (Planned)
|
|
244
|
+
|
|
245
|
+
- [ ] Improve edge detection for better cropping
|
|
246
|
+
- [ ] Support more input formats (WEBP, AVIF)
|
|
247
|
+
- [ ] Optimize SVG output quality
|
|
248
|
+
- [ ] Add progress indicators for long operations
|
|
249
|
+
- [ ] Support custom icon sizes
|
|
250
|
+
- [ ] Add platform-specific output options
|
|
251
|
+
- [ ] Improve error messages
|
|
252
|
+
|
|
253
|
+
### v1.0.0 (Future)
|
|
254
|
+
|
|
255
|
+
- [ ] iOS icon optimization
|
|
256
|
+
- [ ] Android adaptive icons
|
|
257
|
+
- [ ] Full UWP/WinUI 3 support (14 sizes + 3 themes + tiles)
|
|
258
|
+
- [ ] CI/CD integration templates
|
|
259
|
+
- [ ] GUI application (optional)
|
|
260
|
+
|
|
261
|
+
## Contributing
|
|
262
|
+
|
|
263
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
264
|
+
|
|
265
|
+
1. Fork the repository
|
|
266
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
267
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
268
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
269
|
+
5. Open a Pull Request
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
274
|
+
|
|
275
|
+
## Acknowledgments
|
|
276
|
+
|
|
277
|
+
- Built with [Click](https://click.palletsprojects.com/) for CLI
|
|
278
|
+
- Image processing powered by [Pillow](https://pillow.readthedocs.io/) and [OpenCV](https://opencv.org/)
|
|
279
|
+
- Terminal output美化 with [Rich](https://rich.readthedocs.io/)
|
|
280
|
+
|
|
281
|
+
***
|
|
282
|
+
|
|
283
|
+
**Icoft** = **Icon** + **Forge** 🛠️
|
|
284
|
+
|
|
285
|
+
Made with ❤️ for developers everywhere
|