Metadata-Version: 2.1
Name: html_image_embedder
Version: 1.0.0
Summary: Converts images to base64 and embeds them in HTML files.
Project-URL: Homepage, https://github.com/matthew-hajec/html_image_embedder
Project-URL: Issues, https://github.com/matthew-hajec/html_image_embedder/issues
Author-email: Matthew Hajec <matthew.hajec02@gmail.com>
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Requires-Dist: selectolax>=0.3
Description-Content-Type: text/markdown

# html_image_embedder

A Python package that embeds images into HTML documents using data URIs.

## Installation

You can install html_image_embedder using pip:

```pip install html_image_embedder```

## Usage

To use html_image_embedder, you need to import the embed_images function from the package:

```python
from html_image_embedder import embed_images
```

The embed_images function takes two arguments: html and images. The html argument is a string containing the HTML code. The images argument is a dictionary mapping image URLs to image bytes. For example, you can use the requests library to get the image bytes from a URL:

```python
import requests

url = "https://example.com/image.png"
response = requests.get(url)
image_bytes = response.content
```

The embed_images function returns a modified HTML string with the image data embedded in the src attributes of the img tags. For example:

```python
html = "<html><body><img src='https://example.com/image.png'></body></html>"
images = {"https://example.com/image.png": image_bytes}
new_html = embed_images(html, images)
print(new_html)
# <html><body><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."></body></html>
```

## License

This project is licensed under the MIT License - see the LICENSE file for details.