feat: jpg to png to svg

This commit is contained in:
kellervater
2025-09-15 22:49:48 +02:00
parent 021cf7b78d
commit 099b754156
6 changed files with 115 additions and 0 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
*.3mf *.3mf
*.stl *.stl
.vscode .vscode
bin/OpenSCAD-*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -0,0 +1,25 @@
import google.generativeai as genai
import os
# Configure with your API key
genai.configure(api_key="YOUR_API_KEY")
# The prompt from our refined prompt file
prompt_text = """
Analyze the attached image and generate a PNG file...
[...your full prompt text here...]
"""
# Load the image and prompt
model = genai.GenerativeModel('gemini-1.5-pro')
source_image = genai.upload_file(path="PXL_20250915_172025980.jpg")
# Make the API call
response = model.generate_content([prompt_text, source_image])
# Save the generated image data from the response
# (The exact syntax for saving the file may vary based on API response structure)
with open("output_silhouette.png", "wb") as f:
f.write(response.parts[0].blob.data)
print("Silhouette PNG created successfully!")

View File

@@ -0,0 +1,17 @@
/* [SVG Parameters] */
// Amount to "thicken" the SVG shape in mm. This helps to fill small gaps.
thicken_amount = 0.1; // [0:0.1:5]
// Height of the extrusion in mm
extrusion_height = 20; // [1:1:100]
/* [Global Settings] */
$fn = 100;
// --- Implementation ---
linear_extrude(height = extrusion_height) {
offset(delta = thicken_amount) {
import("spitzzangerl.svg", center = true);
}
}

19
png_creation/prompt.md Normal file
View File

@@ -0,0 +1,19 @@
# --- Gemini Agent Prompt: Create Tool Silhouette ---
**ROLE:**
You are an expert image processing agent. Your sole function is to create a clean, solid black silhouette from a user-provided image of a tool.
**TASK:**
Analyze the attached image and generate a PNG file that meets the precise output requirements below. This PNG will be used as a source for a vector tracing program (Potrace), so precision is critical.
**INPUT:**
- An image file of a single tool lying on a high-contrast background.
**OUTPUT REQUIREMENTS:**
1. **Format:** PNG with a transparent background.
2. **Content:** A silhouette representing the **single, continuous, outermost contour only**. All internal holes, lines, and details must be completely filled in.
3. **Color:** The silhouette must be 100% solid black (`#000000`). No anti-aliasing or grey pixels.
4. **Cropping:** The final image must be tightly cropped around the silhouette with minimal transparent padding.
**ACTION:**
Process the attached photo and provide only the resulting PNG file as your output.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 687 KiB