streamlined webp corruption to a absolute maximum bro i'm a beast w/ this
BIN
data/JPGHex.jpg
|
Before Width: | Height: | Size: 682 KiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 82 KiB |
BIN
data/img.png
|
Before Width: | Height: | Size: 3.5 MiB After Width: | Height: | Size: 3.1 MiB |
BIN
data/result.png
|
Before Width: | Height: | Size: 2.3 MiB |
BIN
data/result.webp
|
Before Width: | Height: | Size: 82 KiB |
@@ -1,2 +1,2 @@
|
||||
//globals
|
||||
uptime = 117147364
|
||||
uptime = 117205446
|
||||
|
||||
BIN
data/webp_glitched.png
Normal file
|
After Width: | Height: | Size: 2.4 MiB |
BIN
data/webp_glitched.webp
Normal file
|
After Width: | Height: | Size: 123 KiB |
BIN
data/webp_orig.png
Normal file
|
After Width: | Height: | Size: 4.4 MiB |
BIN
data/webp_orig.webp
Normal file
|
After Width: | Height: | Size: 123 KiB |
@@ -1 +0,0 @@
|
||||
convert "/Users/giers/Documents/Processing 3/manglr2/data/result.webp" "/Users/giers/Documents/Processing 3/manglr2/data/result.png"
|
||||
@@ -1 +0,0 @@
|
||||
convert "/Users/giers/Documents/Processing 3/manglr2/data/img.png" "/Users/giers/Documents/Processing 3/manglr2/data/WEBPhex.webp"
|
||||
75
effects.pde
@@ -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();
|
||||
}
|
||||
|
||||
26
manglr2.pde
@@ -161,3 +161,29 @@ String getOS() {
|
||||
return "other";
|
||||
}
|
||||
}
|
||||
boolean runCommand(String[] command) {
|
||||
//String returnedValues;
|
||||
try {
|
||||
Process p = new ProcessBuilder(command).start();
|
||||
int ii = p.waitFor();
|
||||
if (ii == 0) { //success signal
|
||||
//BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
//while ( (returnedValues = stdInput.readLine ()) != null) {
|
||||
//println(returnedValues);
|
||||
//}
|
||||
return(true);
|
||||
} else {
|
||||
//BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
|
||||
//println("Error:");
|
||||
//while ( (returnedValues = stdErr.readLine ()) != null) {
|
||||
//println(returnedValues);
|
||||
//}
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
//println("Error running command");
|
||||
//println(e);
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||