img2stl is a Python package that converts an image to a 3D STL models.
Project description
pic2stl Image Converter
Overview
pic2stl is a Python package that converts images to 3D STL models. It reads an image, translates it into a 3D mesh, and exports the mesh in STL format. This package is ideal for creating 3D printable models from logos, silhouettes, and other high-contrast images.
Features
- Convert images to 3D STL meshes
- Set extrusion height for 3D models
- Optionally add a base plane for enhanced model adhesion
- Compatible with any mainstream image format
Installation
To use this package, ensure that you have the required dependencies installed:
pip install numpy Pillow numpy-stl scipy
Usage
Function
def image_to_stl(image_path, output_path, extrusion_height, add_base=False, base_thickness=0)
Parameters
image_path: Path to the input image.output_path: Path to save the generated STL file.extrusion_height: Height of the 3D model extrusion.add_base(Optional, defaultFalse): Adds a base plane if set toTrue.base_thickness(Optional, default1): Thickness of the base plane.
Example
# Convert an image to STL
image_to_stl('path/to/input_image.png', 'output.stl', extrusion_height=3, add_base=True, base_thickness=2)
How It Works
- Load Image: The function reads the input image and converts it to grayscale if needed.
- Binary Conversion: Pixels above a specific threshold are considered "on," and those below are "off."
- Mesh Creation: A 3D mesh is generated based on the "on" pixels, extruding vertically.
- Optional Base: Adds an optional base to the bottom of the model for stability.
- Export to STL: The mesh is then exported to STL format.
License
This package is distributed under the MIT License.
Contribution
Contributions are welcome. Please submit issues or pull requests to help improve this package!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pic2stl-10.0.12.tar.gz.
File metadata
- Download URL: pic2stl-10.0.12.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cd1805f67aadd295e521a6204c24ac19cb96c7d98c38640da3336c6dc6b5ccc
|
|
| MD5 |
82287f5747d825265582803bb9557f2a
|
|
| BLAKE2b-256 |
86f1fbd9ea598a3f8fce6ea50f79d13ea5518668bdfcda0d01666658d6da4a70
|
Provenance
The following attestation bundles were made for pic2stl-10.0.12.tar.gz:
Publisher:
python-package.yml on niljub/pic2stl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pic2stl-10.0.12.tar.gz -
Subject digest:
9cd1805f67aadd295e521a6204c24ac19cb96c7d98c38640da3336c6dc6b5ccc - Sigstore transparency entry: 241072741
- Sigstore integration time:
-
Permalink:
niljub/pic2stl@0de2559b618dd732093def732432ddb8cfc94ae4 -
Branch / Tag:
refs/tags/test - Owner: https://github.com/niljub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yml@0de2559b618dd732093def732432ddb8cfc94ae4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pic2stl-10.0.12-py3-none-any.whl.
File metadata
- Download URL: pic2stl-10.0.12-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ff757c41909c7a87a389a5a67b4f41c92c6aa79f43997881c0e0e4b38fbd797
|
|
| MD5 |
ebc7df16df17ee6d87d8f6fbb3b20c01
|
|
| BLAKE2b-256 |
53c42b3b85b9794e4361261bc5fc2bc1de5839b96536807cad12218fb48b9e29
|
Provenance
The following attestation bundles were made for pic2stl-10.0.12-py3-none-any.whl:
Publisher:
python-package.yml on niljub/pic2stl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pic2stl-10.0.12-py3-none-any.whl -
Subject digest:
2ff757c41909c7a87a389a5a67b4f41c92c6aa79f43997881c0e0e4b38fbd797 - Sigstore transparency entry: 241072752
- Sigstore integration time:
-
Permalink:
niljub/pic2stl@0de2559b618dd732093def732432ddb8cfc94ae4 -
Branch / Tag:
refs/tags/test - Owner: https://github.com/niljub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yml@0de2559b618dd732093def732432ddb8cfc94ae4 -
Trigger Event:
push
-
Statement type: