def get_random_background(self): image = peak_random_preloaded_image("backgrounds") width, height = self.get_size() if width is None: width = self.get_maximum_width() image_width, image_height = image.size x_crop = randint(0, max(1, image_width - width)) y_crop = randint(0, max(1, image_height - height)) return image.crop((x_crop, y_crop, x_crop + width, y_crop + height))
def transform_image(self, image): image = image.copy() image_width, image_height = image.size n = randint(0, 10) for i in range(0, n): phantomPatterns = peak_random_preloaded_image("phantomPatterns") image.paste(phantomPatterns, (randint(0, image_width), randint(0, image_height)), ImageOps.invert(phantomPatterns.convert("L"))) return image
def __init__(self, width=None, height=None, parent=None, random_rotation=10): super().__init__(width, height, parent) self.documents = [] self.random_rotation = random_rotation self.transformations = [] self.background = peak_random_preloaded_image("backgrounds")
def __init__(self, width=None, height=None, parent=None): super().__init__(width, height, parent) self.image = peak_random_preloaded_image("backgrounds")
def get_random_image(self): image = peak_random_preloaded_image("backgrounds") return image.resize(self.get_size(), Image.ANTIALIAS)