Last year I was studying basic database in my college and in the last assignment I had to develop a random image generator (short long history: I had to generate some profile pics for placeholder users to make the database huge). I made some changes before posting here, in the old version it would only draw circles inside the picture and in this it can generate circles and regular polygons with 3 or more sides. Also, I added more configuration variables and released under The Unlicense (means full public domain, so you can copy, edit, compress, expand, create, etc) on github.
It's fully commented for you and available on https://github.com/marco-xd/PHP-Random-Image.
If you want to understand more, you can PM me anytime or post here. Also, I recommend reading the following links:
You can pass the arguments via GET or let the code use random values. It accepts the following arguments:
These arguments are limited on the server-side so you cannot enter a huge value of width and use all of the computer memory.
Some results are attached below.
image__width.1000_height.200_antialias.2.png (Size: 83.59 KB / Downloads: 1)
image__width.1000_height.100_antialias.2_seed.gigarank.png (Size: 59.05 KB / Downloads: 1)
image__width.500_height.100_antialias.3.png (Size: 42.66 KB / Downloads: 1)
image__width.500_height.500_antialias.2.png (Size: 96.15 KB / Downloads: 1)
It's fully commented for you and available on https://github.com/marco-xd/PHP-Random-Image.
If you want to understand more, you can PM me anytime or post here. Also, I recommend reading the following links:
- http://php.net/manual/en/function.sprintf.php (used for generating an ETAG)
- http://php.net/manual/en/reserved.variables.server.php (used for retrieving user cache information)
- https://en.wikipedia.org/wiki/HTTP_ETag (used to cache)
- http://php.net/manual/en/book.image.php (used to communicate to the browser)
- https://en.wikipedia.org/wiki/Polar_coordinate_system and http://www.mathwords.com/p/polar_rectang...rmulas.htm (used to calculate polygon vertex)
- http://php.net/manual/en/zlib.configuration.php and http://php.net/manual/en/function.ob-gzhandler.php (used to gzip compression)
You can pass the arguments via GET or let the code use random values. It accepts the following arguments:
- seed: Random seed (string)
- width: Image width
- height: Image height
- antialias: Image antialiasing (GD circles have a lot of aliasing)
These arguments are limited on the server-side so you cannot enter a huge value of width and use all of the computer memory.
Some results are attached below.



