{
   "description" : "This 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",
   "ancestor_list" : [],
   "name" : "JPEG / JPG Glitcher",
   "author" : "rukano",
   "code" : "// code found @ \"http://uiae.de/?p=110\"\r\n// based on: http://www.hellocatfood.com/create-jpgs-in-pure-data/\r\n// test with jpeg data here: http://www.ffd8.org/header_remix/?showall=yup\r\n\r\n(\r\n// make 10 glitched versions of a JPEG\r\n10.do{ |i|\r\n\t// change here the path of the original image and the path to the glithced images\r\n\tvar inpath = \"/Users/rukano/Desktop/monalisa.jpg\";\r\n\tvar outpath = \"/Users/rukano/Desktop/monalisa-glitch-%.jpg\".format(i);\r\n\tvar outfile;\r\n\tvar file = File.open(inpath, \"rb\");\r\n\tvar data = file.length.collect{ file.getInt8 };\r\n\r\n\t// how many bytes to replace\r\n\t100.do{\r\n\t\tvar pos = rrand(200, data.size - 10);\r\n\t\tdata[pos] = 256.rand;\r\n\t\t// data[pos] = (data[pos] + 100.rand2).max(0).min(255);\r\n\t};\r\n\r\n\t// write out the file\r\n\toutfile = File.new(outpath, \"wb\");\r\n\toutfile.write(data.as(Int8Array));\r\n\toutfile.close;\r\n\t\"---> wrote %\".format(outpath).postln;\r\n};\r\n)",
   "id" : "1-4Vs",
   "is_private" : null,
   "labels" : [
      "glitch",
      "jpg",
      "jpeg",
      "picture",
      "image processing"
   ]
}
