imglib2 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.
imglib2/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ from .draw import draw_rectangle, draw_text
2
+ from .generate import generate_image
3
+
4
+ __all__ = ["draw_rectangle", "draw_text", "generate_image"]
imglib2/draw.py ADDED
@@ -0,0 +1,22 @@
1
+ from PIL import Image, ImageDraw, ImageFont
2
+
3
+ def draw_rectangle(width: int, height: int, color: str = "blue", rect: tuple[int,int,int,int]|None = None) -> Image.Image:
4
+ img = Image.new("RGB", (width, height), "white")
5
+ draw = ImageDraw.Draw(img)
6
+ box = rect or (50, 50, width - 50, height - 50)
7
+ draw.rectangle(box, fill=color, outline="black", width=3)
8
+ return img
9
+
10
+ def draw_text(width: int, height: int, text: str, font_size: int = 40) -> Image.Image:
11
+ img = Image.new("RGB", (width, height), "white")
12
+ draw = ImageDraw.Draw(img)
13
+ # fallback если шрифт не найден
14
+ try:
15
+ font = ImageFont.truetype("DejaVuSans.ttf", font_size)
16
+ except OSError:
17
+ font = ImageFont.load_default()
18
+ tw, th = draw.textsize(text, font=font) if hasattr(draw, "textsize") else draw.textbbox((0,0), text, font=font)[2:]
19
+ x = (width - tw) // 2
20
+ y = (height - th) // 2
21
+ draw.text((x, y), text, fill="black", font=font)
22
+ return img
imglib2/generate.py ADDED
@@ -0,0 +1,14 @@
1
+ from typing import Optional
2
+
3
+ def generate_image(prompt: str, width: int = 512, height: int = 512, seed: Optional[int] = None) -> bytes:
4
+ """
5
+ Заглушка: в реальной реализации здесь будет вызов Stable Diffusion через diffusers.
6
+ Возвращает PNG-байты.
7
+ """
8
+ # Пример: вернуть простое изображение вместо реальной генерации
9
+ from .draw import draw_text
10
+ img = draw_text(width, height, prompt)
11
+ from io import BytesIO
12
+ buf = BytesIO()
13
+ img.save(buf, format="PNG")
14
+ return buf.getvalue()
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: imglib2
3
+ Version: 0.1.0
4
+ Summary: Библиотека для создания изображений
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: diffusers>=0.25.0
8
+ Requires-Dist: pillow>=10.0.0
9
+ Requires-Dist: torch>=2.1.0
10
+ Requires-Dist: transformers>=4.35.0
@@ -0,0 +1,7 @@
1
+ imglib2/__init__.py,sha256=N6rb_xTtV9PygenSy9wI4JgYudpRzowjQMVjJ5qPWGk,142
2
+ imglib2/draw.py,sha256=COcGopQpCzbnl8odi-l9WyxLWJc7Yj-6yp--4dswC7E,979
3
+ imglib2/generate.py,sha256=wfVRZ1Ve8859T8-hU_RXAAb6ck2w_ribJfOMgY3sFsY,630
4
+ imglib2-0.1.0.dist-info/METADATA,sha256=ECZyrsCHSokZ1ngdSe3KwukYZRL8aibAhcdG3Q44S50,300
5
+ imglib2-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ imglib2-0.1.0.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ imglib2-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
File without changes