EXTREMEXPLOIT

Data Generator a lo grande

Sep 8th, 2020 (edited)
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.33 KB | None | 0 0
  1. from PIL import Image, ImageDraw, ImageFont
  2. import random, time, string, os
  3.  
  4. def GenerateImageRandomCharacter(Character, FileName, FontPath, TextSize, SIZE_X=150, SIZE_Y=150, characterColor=None, bgColor=None):
  5.     IMG_MODE = 'RGB'
  6.     IMG_SIZE = (SIZE_X, SIZE_Y)
  7.     RandomColour = lambda: random.randint(0, 255)
  8.     if not characterColor:
  9.         CHAR_COLOR = '#%02X%02X%02X' % (RandomColour(), RandomColour(), RandomColour())
  10.     else:
  11.         CHAR_COLOR = characterColor
  12.     IMG_NAME = str(FileName) + str('.jpg')
  13.     IMG_FONT, IMG_TEXT = ImageFont.truetype(FontPath, TextSize), Character
  14.     IMG = Image.new(IMG_MODE, IMG_SIZE, CHAR_COLOR)
  15.     Draw = ImageDraw.Draw(IMG)
  16.     Draw.textsize(IMG_TEXT, font=IMG_FONT)
  17.     CHARACTER_POSITION = (random.randint(0, SIZE_X - TextSize)), (random.randint(0, SIZE_Y - TextSize))
  18.     if not bgColor:
  19.         BG_COLOR = '#%02X%02X%02X' % (RandomColour(), RandomColour(), RandomColour())
  20.     else:
  21.         BG_COLOR = bgColor
  22.     Draw.text(CHARACTER_POSITION, IMG_TEXT, font=IMG_FONT, fill=BG_COLOR)
  23.     IMG.save(IMG_NAME)
  24.  
  25. DATA_SIZE = 1000
  26.  
  27. UserInput = input('Create Number Characters? [Y/N]: ')
  28. if UserInput == 'Y':
  29.     BlackWhite = input('Black & White Number Characters? [Y/N]: ')
  30.     for NumberCharacter in list(map(str, range(10))):
  31.         if not os.path.exists(f'./DATA/{NumberCharacter}'):
  32.             os.mkdir(f'./DATA/{NumberCharacter}')
  33.             for imageID in range(DATA_SIZE):
  34.                 if BlackWhite == 'Y':
  35.                     GenerateImageRandomCharacter(NumberCharacter, f'./DATA/{NumberCharacter}/{imageID}', 'C:/Windows/Fonts/consola.ttf', random.randint(10, 50),
  36.                         characterColor='#000000', bgColor='#FFFFFF')
  37.                 else:
  38.                     GenerateImageRandomCharacter(NumberCharacter, f'./DATA/{NumberCharacter}/{imageID}', 'C:/Windows/Fonts/consola.ttf', random.randint(10, 50))
  39.         print(f'Folder: ./DATA/{NumberCharacter} ✓')
  40. print('\n')
  41.  
  42. UserInput = input('Create Lower Characters? [Y/N]: ')
  43. if UserInput == 'Y':
  44.     BlackWhite = input('Black & White Lower Characters? [Y/N]: ')
  45.     for LowerCharacter in list(string.ascii_lowercase): # Lowercase Letters.
  46.         if not os.path.exists(f'./DATA/{LowerCharacter}'):
  47.             os.mkdir(f'./DATA/{LowerCharacter}')
  48.             for imageID in range(DATA_SIZE):
  49.                 if BlackWhite == 'Y':
  50.                     GenerateImageRandomCharacter(LowerCharacter, f'./DATA/{LowerCharacter}/{imageID}', 'C:/Windows/Fonts/consola.ttf', random.randint(10, 50),
  51.                         characterColor='#000000', bgColor='#FFFFFF')
  52.                 else:
  53.                     GenerateImageRandomCharacter(LowerCharacter, f'./DATA/{LowerCharacter}/{imageID}', 'C:/Windows/Fonts/consola.ttf', random.randint(10, 50))
  54.         print(f'Folder: ./DATA/{LowerCharacter} ✓')
  55. print('\n')
  56.  
  57. UserInput = input('Create Upper Characters? [Y/N]: ')
  58. if UserInput == 'Y':
  59.     BlackWhite = input('Black & White Upper Characters? [Y/N]: ')
  60.     for UpperCharacter in list(string.ascii_uppercase): # Uppercase Letters
  61.         if not os.path.exists(f'./DATA/Upper_{UpperCharacter}'):
  62.             os.mkdir(f'./DATA/{UpperCharacter}Upper')
  63.             for imageID in range(DATA_SIZE):
  64.                 if BlackWhite == 'Y':
  65.                     GenerateImageRandomCharacter(UpperCharacter, f'./DATA/{UpperCharacter}/{imageID}', 'C:/Windows/Fonts/consola.ttf', random.randint(10, 50),
  66.                         characterColor='#000000', bgColor='#FFFFFF')
  67.                 else:
  68.                     GenerateImageRandomCharacter(UpperCharacter, f'./DATA/{UpperCharacter}/{imageID}', 'C:/Windows/Fonts/consola.ttf', random.randint(10, 50))
  69.         print(f'Folder: ./DATA/{UpperCharacter} ✓')
  70. print('\n')
Add Comment
Please, Sign In to add comment