«JPEG / JPG Glitcher» by rukano
on 11 Dec'13 18:14 inThis code, based on uiae's blogpost takes a JPG file and replaces some bytes on it to mess up the codec. The result, some funny glitches
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
// code found @ "http://uiae.de/?p=110" // based on: http://www.hellocatfood.com/create-jpgs-in-pure-data/ // test with jpeg data here: http://www.ffd8.org/header_remix/?showall=yup ( // make 10 glitched versions of a JPEG 10.do{ |i| // change here the path of the original image and the path to the glithced images var inpath = "/Users/rukano/Desktop/monalisa.jpg"; var outpath = "/Users/rukano/Desktop/monalisa-glitch-%.jpg".format(i); var outfile; var file = File.open(inpath, "rb"); var data = file.length.collect{ file.getInt8 }; // how many bytes to replace 100.do{ var pos = rrand(200, data.size - 10); data[pos] = 256.rand; // data[pos] = (data[pos] + 100.rand2).max(0).min(255); }; // write out the file outfile = File.new(outpath, "wb"); outfile.write(data.as(Int8Array)); outfile.close; "---> wrote %".format(outpath).postln; }; )
descendants
full graph
«Re: JPEG / JPG Glitcher» by anonymous (private)
reception
Cool
Great!! =D