Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
"""
|
|
|
|
| 2 |
Iluminados Vectorizer - VTracer + Hugging Face Space
|
| 3 |
Adicionar ao mesmo Space do upscaler ou criar Space novo
|
| 4 |
"""
|
|
@@ -55,6 +56,15 @@ def vectorize_image(
|
|
| 55 |
path_precision=int(path_precision),
|
| 56 |
)
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Salva SVG
|
| 59 |
svg_path = f"/tmp/result_{os.getpid()}.svg"
|
| 60 |
with open(svg_path, 'w', encoding='utf-8') as f:
|
|
|
|
| 1 |
"""
|
| 2 |
+
"""
|
| 3 |
Iluminados Vectorizer - VTracer + Hugging Face Space
|
| 4 |
Adicionar ao mesmo Space do upscaler ou criar Space novo
|
| 5 |
"""
|
|
|
|
| 56 |
path_precision=int(path_precision),
|
| 57 |
)
|
| 58 |
|
| 59 |
+
# Corrige viewBox para garantir que o SVG mostre a imagem toda
|
| 60 |
+
import re
|
| 61 |
+
if 'viewBox' not in svg_str:
|
| 62 |
+
svg_str = svg_str.replace('<svg ', f'<svg viewBox="0 0 {w} {h}" ', 1)
|
| 63 |
+
|
| 64 |
+
# Garante que width e height sejam 100% para escalar corretamente
|
| 65 |
+
svg_str = re.sub(r'<svg([^>]*?)width="[^"]*"', r'<svg\1width="100%"', svg_str)
|
| 66 |
+
svg_str = re.sub(r'<svg([^>]*?)height="[^"]*"', r'<svg\1height="100%"', svg_str)
|
| 67 |
+
|
| 68 |
# Salva SVG
|
| 69 |
svg_path = f"/tmp/result_{os.getpid()}.svg"
|
| 70 |
with open(svg_path, 'w', encoding='utf-8') as f:
|