Skip to main content

A module to generate images from HTML content

Project description

hex_htmltoimg

Convert HTML to images with ease and flexibility! 🖼️✨

Overview

hex_htmltoimg is a powerful Python module that transforms HTML files into high-quality images with dynamic content replacement and customizable rendering.

🌟 Features

  • HTML to Image Conversion: Seamlessly transform HTML content into crisp, professional images
  • Dynamic Content Placeholders: Replace placeholders with personalized, real-time content
  • Flexible Image Sizing: Customize output image dimensions effortlessly
  • Unique Filename Generation: Automatically create distinct filenames for each generated image
  • Image Resizing: Adjust image sizes post-generation with built-in tools

🚀 Installation

Install the module quickly using pip:

pip install hex_htmltoimg

💡 Usage Examples

Basic Usage

from hex_htmltoimg import generate_image_from_html

# Path to your HTML template
html_file_path = 'template.html'

# Dynamic content replacements
replacements = {
    '{{title}}': 'Hello, World!',
    '{{content}}': 'Dynamically generated image magic!'
}

# Generate image with custom dimensions
image_filename = generate_image_from_html(
    html_file_path, 
    replacements, 
    width=800, 
    height=600
)

print(f"Image saved: {image_filename}")

HTML Template Example

<!DOCTYPE html>
<html>
<body>
    <h1>{{header}}</h1>
    <p>{{content}}</p>
    <footer>{{footer}}</footer>
</body>
</html>

🔧 Parameters

Parameter Description Default
file_path Path to the HTML file Required
replacements Dictionary of placeholder replacements {}
width Output image width 650px
height Output image height 1250px

⚠️ Error Handling

The module handles various scenarios:

  • Raises FileNotFoundError if HTML file is missing
  • Validates width and height as positive integers
  • Manages image generation exceptions

📄 License

MIT License - Free for personal and commercial use.

🤝 Contributing

Contributions are welcome!

  • Fork the repository
  • Submit issues
  • Create pull requests

📞 Support

For more information, check the project repository.

Generated with ❤️ by azharbhat-dev

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

hex_htmltoimg-1.2.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

hex_htmltoimg-1.2.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file hex_htmltoimg-1.2.0.tar.gz.

File metadata

  • Download URL: hex_htmltoimg-1.2.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for hex_htmltoimg-1.2.0.tar.gz
Algorithm Hash digest
SHA256 c8cc2d55d4294021054fb1caa4639cbb075029d0d5976cad210c72a2c521905d
MD5 743ec17e0e3bc8955c7ef392e0493b1b
BLAKE2b-256 5f0f307020a29429cf9152e903316208f5c2a370db56823061a0302d2e5fa38b

See more details on using hashes here.

File details

Details for the file hex_htmltoimg-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: hex_htmltoimg-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for hex_htmltoimg-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f5e457bc5ee1444c0b1e98ae2bb6006d9eaabfb98ab55dc758bdb18e2a381cb
MD5 bf9ce9bbf4abd111eb57a8f0f4202764
BLAKE2b-256 502e891e458c82d86346aacb884ad27856b161b50db88a2b52d62a8e8cfb900c

See more details on using hashes here.

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