I'm looking for a script that generates random images using the PIL Image module by assigning random RGB values to each pixel on a blank canvas. Does anyone have one of those lying around? (I want to write my own just for practice, but if it's already been done by a pro I'd also like to study the pro's version.)
EdJones
0
Newbie Poster
Recommended Answers
Jump to PostHow do you think you could do it? If you understand the capabilities of the module, then try some experimentation and don't steal from the experts until you have some understanding of what you are doing.
Jump to PostThis is perhaps a more efficient way to generate the same kind of random image
>>> from PIL import Image >>> import os >>> size = (600, 600) >>> im = Image.new('RGB', size) >>> def ran(): ... return os.urandom(600*600) ... >>> pixels = zip(ran(), ran(), ran()) >>> …
All 6 Replies
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
EdJones
0
Newbie Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
sneekula
969
Nearly a Posting Maven
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.