python - Create set of random JPGs -


here's scenario, want create set of random, small jpg's - anywhere between 50 bytes , 8k in size - actual visual content of jpeg irrelevant long they're valid. need generate thousand or so, , have unique - if they're different single pixel. can write jpeg header/footer , random bytes in there? i'm not able use existing photos or sets of photos web.

the second issue set of images has different each run of program.

i'd prefer in python, wrapping scripts in python.

i've looked python code generate jpg's scratch, , didn't find anything, pointers libraries good.

if images can random noise, generate array using numpy.random , save them using pil's image.save.

this example might expanded, including ways avoid (very unlikely) repetition of patterns:

import numpy, image  n in xrange(10):     = numpy.random.rand(30,30,3) * 255     im_out = image.fromarray(a.astype('uint8')).convert('rgba')     im_out.save('out%000d.jpg' % n) 

these conditions must met in order jpeg images:

  1. the array needs shaped (m, n, 3) - 3 colors, r g , b;
  2. each element (each color of each pixel) has byte integer (uint, or unsigned integer 8 bits), ranging 0 255.

additionaly, other way besides pure randomness might used in order generate images in case don't want pure noise.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -