assetforge-cli 0.1.0__py3-none-any.whl
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.
- assetforge/__init__.py +1 -0
- assetforge/cli.py +22 -0
- assetforge/core.py +22 -0
- assetforge_cli-0.1.0.dist-info/METADATA +35 -0
- assetforge_cli-0.1.0.dist-info/RECORD +9 -0
- assetforge_cli-0.1.0.dist-info/WHEEL +5 -0
- assetforge_cli-0.1.0.dist-info/entry_points.txt +2 -0
- assetforge_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
- assetforge_cli-0.1.0.dist-info/top_level.txt +1 -0
assetforge/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
assetforge/cli.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from .core import optimize_image
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@click.command()
|
|
6
|
+
@click.argument('input_path', type=click.Path(exists=True))
|
|
7
|
+
@click.option('--format', '-f', 'target_format', type=click.Choice(['webp', 'png', 'jpeg']), default='webp',
|
|
8
|
+
help='Target output format.')
|
|
9
|
+
@click.option('--quality', '-q', type=int, default=85, help='Compression quality (10-100).')
|
|
10
|
+
def main(input_path, target_format, quality):
|
|
11
|
+
"""AssetForge: Optimize and convert images directly from the terminal."""
|
|
12
|
+
click.echo(f"🔨 Forging asset: {input_path}...")
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
output_path = optimize_image(input_path, target_format, quality)
|
|
16
|
+
click.secho(f"✅ Successfully optimized! Saved to: {output_path}", fg="green")
|
|
17
|
+
except Exception as e:
|
|
18
|
+
click.secho(f"❌ Error: {str(e)}", fg="red")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if __name__ == '__main__':
|
|
22
|
+
main()
|
assetforge/core.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from PIL import Image
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def optimize_image(input_path, target_format, quality):
|
|
6
|
+
if not os.path.exists(input_path):
|
|
7
|
+
raise FileNotFoundError(f"Cannot find image at: {input_path}")
|
|
8
|
+
|
|
9
|
+
filename, _ = os.path.splitext(os.path.basename(input_path))
|
|
10
|
+
output_dir = os.path.dirname(input_path) or "."
|
|
11
|
+
output_path = os.path.join(output_dir, f"{filename}_optimized.{target_format}")
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
with Image.open(input_path) as img:
|
|
15
|
+
# Convert RGBA to RGB if saving as JPEG (JPEG doesn't support transparency)
|
|
16
|
+
if target_format == 'jpeg' and img.mode in ('RGBA', 'P'):
|
|
17
|
+
img = img.convert('RGB')
|
|
18
|
+
|
|
19
|
+
img.save(output_path, format=target_format, quality=quality, optimize=True)
|
|
20
|
+
return output_path
|
|
21
|
+
except Exception as e:
|
|
22
|
+
raise RuntimeError(f"Failed to process image: {str(e)}")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: assetforge-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A command-line tool for automated asset optimization and format conversion.
|
|
5
|
+
Author-email: Logesh Kanagaraj <logeshkanagarajofficial@gmail.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: click>=8.1.0
|
|
13
|
+
Requires-Dist: Pillow>=10.0.0
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# 🔨 AssetForge
|
|
17
|
+
|
|
18
|
+
A lightweight, lightning-fast command-line interface (CLI) tool designed for automated image optimization and format conversion.
|
|
19
|
+
|
|
20
|
+
Whether you are preparing high-resolution promotional assets or optimizing web graphics for a fast-loading deployment, AssetForge allows you to compress and convert images directly from your terminal without opening heavy editing software.
|
|
21
|
+
|
|
22
|
+
## ✨ Features
|
|
23
|
+
* **Format Conversion:** Seamlessly convert between `WEBP`, `PNG`, and `JPEG`.
|
|
24
|
+
* **Smart Compression:** Dial in the exact quality level you need to save disk space and improve load times.
|
|
25
|
+
* **Auto-Routing:** Automatically detects the source directory and saves optimized assets right next to the originals.
|
|
26
|
+
* **Transparency Handling:** Safely flattens RGBA transparency layers when converting formats like PNG to JPEG.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🚀 Installation
|
|
31
|
+
|
|
32
|
+
AssetForge is available globally via PyPI. You can install it on any machine using pip:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install assetforge-logesh
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
assetforge/__init__.py,sha256=Pru0BlFBASFCFo7McHdohtKkUtgMPDwbGfyUZlE2_Vw,21
|
|
2
|
+
assetforge/cli.py,sha256=aqhN2Vk0vsuLAh0AJf2bxe3IY7-DuDVS-W8mWUPqgU8,862
|
|
3
|
+
assetforge/core.py,sha256=jgqTZqW4-A0lQCzmuUn8CsuQQTKgWh6uRfSprVcCsD4,887
|
|
4
|
+
assetforge_cli-0.1.0.dist-info/licenses/LICENSE,sha256=tWCfraqbsvEQHlb24xOfwKF3c_OuLTfcxVTXmCIcUSQ,1092
|
|
5
|
+
assetforge_cli-0.1.0.dist-info/METADATA,sha256=NPX0sSyeS2zPk9Dhx2KD-mp4rQWL6DbyTWbkLr6l-Qg,1538
|
|
6
|
+
assetforge_cli-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
7
|
+
assetforge_cli-0.1.0.dist-info/entry_points.txt,sha256=yaIIUSpXsV7-WkbPd9tF9ACYF2cmeXNJpHVic8sV8Xo,51
|
|
8
|
+
assetforge_cli-0.1.0.dist-info/top_level.txt,sha256=i5-zwyqXp5jUdpz2kGJOsicXOE91gvrZ26KXvGX-NSg,11
|
|
9
|
+
assetforge_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Logesh Kanagaraj
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
assetforge
|