feat: jpg to png to svg
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
*.3mf
|
||||
*.stl
|
||||
.vscode
|
||||
bin/OpenSCAD-*/
|
||||
|
||||
BIN
png_creation/PXL_20250915_172044293.jpg
Normal file
BIN
png_creation/PXL_20250915_172044293.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
25
png_creation/create_png.py
Normal file
25
png_creation/create_png.py
Normal 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!")
|
||||
17
png_creation/png_creation.scad
Normal file
17
png_creation/png_creation.scad
Normal 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
19
png_creation/prompt.md
Normal 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.
|
||||
53
png_creation/spitzzangerl.svg
Normal file
53
png_creation/spitzzangerl.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 687 KiB |
Reference in New Issue
Block a user