Skip to main content

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, default False): Adds a base plane if set to True.
  • base_thickness (Optional, default 1): 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

  1. Load Image: The function reads the input image and converts it to grayscale if needed.
  2. Binary Conversion: Pixels above a specific threshold are considered "on," and those below are "off."
  3. Mesh Creation: A 3D mesh is generated based on the "on" pixels, extruding vertically.
  4. Optional Base: Adds an optional base to the bottom of the model for stability.
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pic2stl-10.0.12.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pic2stl-10.0.12-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

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

Hashes for pic2stl-10.0.12.tar.gz
Algorithm Hash digest
SHA256 9cd1805f67aadd295e521a6204c24ac19cb96c7d98c38640da3336c6dc6b5ccc
MD5 82287f5747d825265582803bb9557f2a
BLAKE2b-256 86f1fbd9ea598a3f8fce6ea50f79d13ea5518668bdfcda0d01666658d6da4a70

See more details on using hashes here.

Provenance

The following attestation bundles were made for pic2stl-10.0.12.tar.gz:

Publisher: python-package.yml on niljub/pic2stl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pic2stl-10.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 2ff757c41909c7a87a389a5a67b4f41c92c6aa79f43997881c0e0e4b38fbd797
MD5 ebc7df16df17ee6d87d8f6fbb3b20c01
BLAKE2b-256 53c42b3b85b9794e4361261bc5fc2bc1de5839b96536807cad12218fb48b9e29

See more details on using hashes here.

Provenance

The following attestation bundles were made for pic2stl-10.0.12-py3-none-any.whl:

Publisher: python-package.yml on niljub/pic2stl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page