Last active
January 16, 2023 19:19
-
-
Save sparkstar/c6bff470e84912566113 to your computer and use it in GitHub Desktop.
[python] random image generator
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
""" | |
20180828 code fixed | |
$ pip freeze | |
numpy==1.15.1 | |
Pillow==5.2.0 | |
pkg-resources==0.0.0 | |
""" | |
#!/usr/bin/env python | |
import os | |
import time | |
import numpy | |
from PIL import Image | |
def create_image(width = 1920, height = 1080, num_of_images = 100): | |
width = int(width) | |
height = int(height) | |
num_of_images = int(num_of_images) | |
current = time.strftime("%Y%m%d%H%M%S") | |
os.mkdir(current) | |
for n in range(num_of_images): | |
filename = '{0}/{0}_{1:03d}.jpg'.format(current, n) | |
rgb_array = numpy.random.rand(height,width,3) * 255 | |
image = Image.fromarray(rgb_array.astype('uint8')).convert('RGB') | |
image.save(filename) | |
def main(args): | |
create_image(width = args[0], height = args[1], num_of_images = args[2]) | |
return 0 | |
if __name__ == '__main__': | |
import sys | |
status = main(sys.argv[1:]) | |
sys.exit(status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What the type of Images files are downloading

I wrote in CMD python taking_random_image.py 1280 720 4 to call it