streamlined webp corruption to a absolute maximum bro i'm a beast w/ this

This commit is contained in:
2022-07-31 16:11:11 +02:00
parent 8832351b4a
commit 5d3d4ce77e
14 changed files with 83 additions and 22 deletions

View File

@@ -4387,16 +4387,42 @@ class WEBPCORRUPTION extends Shader {
int iterations = (int)params.get(1).value;
img = canvas.get();
canvas.beginDraw();
boolean finished = false;
while(!finished) {
println("yo");
canvas.image(img, canvas.width/2, canvas.height/2);
canvas.save(dataPath("")+"/img.png"); //save as png
delay(300);
launch(dataPath("") + "/webpencode.command");
delay(1500);
brokenfile = loadBytes(dataPath("")+"/WEBPhex.webp"); //and reload. just in case it wasnt a jpg.
byte[] savebytes2 = new byte[brokenfile.length];
canvas.image(img, canvas.width/2, canvas.height/2);
File oldImage = new File(dataPath("")+"/webp_orig.webp");
if (oldImage.exists()) {
oldImage.delete();
}
oldImage = new File(dataPath("")+"/png_orig.png");
if (oldImage.exists()) {
oldImage.delete();
}
oldImage = new File(dataPath("")+"/webp_glitched.webp");
if (oldImage.exists()) {
oldImage.delete();
}
oldImage = new File(dataPath("")+"/webp_glitched.png");
if (oldImage.exists()) {
oldImage.delete();
}
String[] convertToPNG = {"/usr/local/bin/convert", "-verbose", dataPath("") + "/webp_glitched.webp", dataPath("") + "/webp_glitched.png"};
while (!runCommand(convertToPNG)) {
println("Trying to convert...");
canvas.save(dataPath("")+"/webp_orig.png"); //save as png
String[] convertToWebp = {"/usr/local/bin/convert", "-verbose", dataPath("") + "/webp_orig.png", dataPath("") + "/webp_orig.webp"};
while (!runCommand(convertToWebp)) {
println("Conversion failed, trying again...");
}
//delay(300);
//launch(dataPath("") + "/webpencode.command");
//String[] commandToRun = {"/usr/local/bin/convert", "-verbose", dataPath("") + "/0.png", dataPath("") + "/webp_orig.webp"};
//delay(1500);
brokenfile = loadBytes(dataPath("")+"/webp_orig.webp"); //and reload. just in case it wasnt a jpg.
byte[] savebytes = new byte[brokenfile.length];
double probability = float(probparam) / float(brokenfile.length);
int glitchCount = 0;
for (int i = 0; i < brokenfile.length; i++) {
@@ -4410,19 +4436,30 @@ class WEBPCORRUPTION extends Shader {
}
byte hexByte[] = fromHexString(hexStr);
for (int j = 0; j < hexByte.length; j++) {
savebytes2[i] += hexByte[j];
savebytes[i] += hexByte[j];
}
}
println("Glitched " + glitchCount + " bytes");
saveBytes(dataPath("") + "/result.webp", savebytes2);
delay(300);
launch(dataPath("") + "/webpdecode.command");
delay(1500);
//try or load fallback image and redo in while loop
PImage compare = img.get();
img = loadImage(dataPath("") + "/result.png");
if (img != compare) finished = true;
saveBytes(dataPath("") + "/webp_glitched.webp", savebytes);
File newImage = new File(dataPath("")+"/webp_glitched.webp");
while (!newImage.exists()) {
println("Waiting until bytes have been written to disk...");
}
/*
String[] convertToPNG = {"/usr/local/bin/convert", "-verbose", dataPath("") + "/webp_glitched.webp", dataPath("") + "/webp_glitched.png"};
while (!runCommand(convertToPNG)) {
println("Trying to convert...");
}
*/
}
img = loadImage(dataPath("") + "/webp_glitched.png");
//launch(dataPath("") + "/webpdecode.command");
//delay(1500);
//try or load fallback image and redo in while loop
//PImage compare = img.get();
//img = loadImage(dataPath("") + "/result.png");
canvas.image(img, canvas.width/2, canvas.height/2);
canvas.endDraw();
}