Generating a live Jpeg from random numbers

Hi,

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 (https://www.hellocatfood.com/create-jpgs-in-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!

Thanks!

Grant

there are 2 things involved:

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

https://processing.org/reference/set_.html
https://processing.org/reference/save_.html

test

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.

corrupt%20jpeg

you could try to read a existing jpg file,
( and also show it
https://processing.org/reference/loadImage_.html
)

but use:
https://processing.org/reference/loadBytes_.html

change bytes at positions what are outside the file definition area
and use:
https://processing.org/reference/saveBytes_.html
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:

https://forum.processing.org/two/discussion/comment/77288/#Comment_77288

2 Likes