Author and developer: A.A. Suvorov
The Babylonian Image Library is a Python library that generates unique images based on a given seed or address. The library uses SHA-256 hashing to create deterministic yet visually unique images. It also provides functionality to generate random addresses, which can be used to create random images.
- Deterministic Image Generation: Generate images based on a seed or address using SHA-256 hashing.
- Random Address Generation: Create random addresses in the format
RoomX:WallY:ShelfZ:VolumeA:BookB:PageC
. - Image Saving: Save generated images to a file in PNG format.
- Customizable Image Size: Set custom width and height for the generated images.
To use the Babylon Image Library, ensure you have the following dependencies installed:
- Python 3.x
Pillow
(PIL fork) for image manipulation.
pip install babylonian-image-library
from babylonian_image_library import BabylonianImageLibrary
# Create an instance of the library
library = BabylonianImageLibrary(width=800, height=600)
# Generate a random address
random_address = library.generate_random_address()
print(f"Random address: {random_address}")
# Save the generated image to a file
library.save_image(random_address, "random_image.png")
print("The image has been saved to 'random_image.png'")
You can also generate an image using a custom seed:
# Generate an image using a custom seed
from babylonian_image_library import BabylonianImageLibrary
# Create an instance of the library
library = BabylonianImageLibrary()
custom_seed = "MyCustomSeed123"
library.save_image(custom_seed, "custom_image.png")
print("The image has been saved to 'custom_image.png'")
The image generation process works as follows:
- The input seed (or address) is hashed using SHA-256.
- The hash is used to generate RGB pixel values for the image.
- If the hash is exhausted, it is rehashed to continue generating pixel values.
- The resulting image is saved to a file.
The random address is generated in the following format:
RoomX:WallY:ShelfZ:VolumeA:BookB:PageC
Where:
X
is a random integer between 1 and 100.Y
is a random integer between 1 and 6.Z
is a random integer between 1 and 10.A
is a random integer between 1 and 10.B
is a random integer between 1 and 100.C
is a random integer between 1 and 1000.
- width: The width of the generated image (default: 1920).
- height: The height of the generated image (default: 1080).
generate_image(seed)
: Generates an image based on the provided seed.get_image(address)
: Returns an image generated from the given address.save_image(address, filename="output.png")
: Saves the generated image to a file.generate_random_address()
: Generates a random address in the specified format.
Running the script will generate a random address and save the corresponding image to a file:
Random address: Room42:Wall3:Shelf7:Volume5:Book23:Page456
The image has been saved to 'random_image.png'
pip install setuptools twine wheel
pip install build
pip install --upgrade pip
python -m build
twine upload dist/*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------
Licensed under the terms of the BSD 3-Clause License
(see LICENSE for details).
Copyright © 2018-2025, A.A. Suvorov
All rights reserved.
--------------------------------------------------------