Skip to content

Commit

Permalink
adding random string generator for output file name so each save will…
Browse files Browse the repository at this point in the history
… not overwrite itself
  • Loading branch information
Pices-26 committed Nov 24, 2020
1 parent 8a827f4 commit 7176292
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ChaosMosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import numpy as np
import matplotlib.pyplot as plt
from math import ceil
from random import randint
from random import randint, choice
from PIL import Image
import cv2
from enum import Enum
import string


class TilePatchSelectMethodType(Enum):
Random = 1,
Expand Down Expand Up @@ -68,8 +70,15 @@ def perform(self):
# Save image to file
self._outputImage = self._outputImage[0:self._outputImageTargetSize[0], 0:self._outputImageTargetSize[1]]
if self._saveOutputImageToFile:
name = self.getRandomString()
img = Image.fromarray(np.uint8(self._outputImage * 255))
img.save(self._outputImagePath + 'out.jpg')
img.save(self._outputImagePath + name +'.jpg')

def getRandomString(self):
# generates random string for output name
letters = string.ascii_lowercase
name = ''.join(choice(letters) for i in range(10))
return name

def loadSampleImage(self):
# Read sample image from file
Expand Down
Binary file modified __pycache__/ChaosMosaic.cpython-37.pyc
Binary file not shown.

0 comments on commit 7176292

Please sign in to comment.