Generating a live Jpeg from random numbers


I am new to the community and new to Processing and have a project in mind that I would like to tackle in order to learn.

I would like to generate a “live” jpeg image from random number inputs. I am aware that the Jpeg will need a vanilla header and that the result will look like a totally “corrupt” image - but this is exactly what I am after!

I have found Antonio Roberts version online using Pure Data ( and was wondering whether this could be recreated in Processing? And to top it off, would it be possible to preview the jpeg generating live as data is entered?

Any help, pointers and recommendations of where I can start to research this would be very much appreciated!



there are 2 things involved:

  • set a “point” to random color
  • save that picture to a jpg file


show your code pls.

Thanks for the reply!

Surely this will render a (random) pixelated image as opposed to a “corrupt” jpeg image using random JPEG encoded (JFIF) bytes?

Also, the idea is to write random (binary) data into a file (with a jpeg header) to render out the jpeg generation process live - not to save it out as a rendered image to view.


you could try to read a existing jpg file,
( and also show it

but use:

change bytes at positions what are outside the file definition area
and use:
to save it back.

that could be a start??

Thanks for this! Will have a look and see what I can achieve.

~ 2004 Benjamin Gaulon wrote a PHP JPEG corrupter, and it was adapted into a Processing sketch by Jeni5 in 2016. I helped adapt an interactive version. It is posted in the old forum; you may find it useful: