Created
September 6, 2021 00:10
-
-
Save Tschucker/27b6595c7799ad4e97b91559b44e2a8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from PIL import Image\n", | |
| "import random\n", | |
| "import randomize_image\n", | |
| "import os" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "num_iterations = 1" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "test_image = randomize_image.full_random_image()\n", | |
| "test_size = test_image[0].size" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "images = os.listdir(\"images\")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "for i in images:\n", | |
| " for n in range(num_iterations):\n", | |
| " rand_color = (random.randint(200,255),random.randint(200,255),random.randint(200,255))\n", | |
| " full_image = Image.new(mode=\"RGB\", size=test_size, color=rand_color)\n", | |
| " asset_image = randomize_image.random_color_image(i)\n", | |
| " full_image.paste(asset_image[0], (0,0), mask=asset_image[1])\n", | |
| " hash = random.getrandbits(64)\n", | |
| " if not os.path.exists(\"collections/single/\"+i.strip(\".png\")):\n", | |
| " os.makedirs(\"collections/single/\"+i.strip(\".png\"))\n", | |
| " full_image.save(\"collections/single/\"+i.strip(\".png\")+\"/\"+i.strip(\".png\")+\"_%016x.png\" % hash)" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.7.6" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment