improved fxwebp
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
//globals
|
//globals
|
||||||
uptime = 117233182
|
uptime = 117266253
|
||||||
|
|||||||
35
effects.pde
35
effects.pde
@@ -4358,6 +4358,8 @@ class WEBPCORRUPTION extends Shader {
|
|||||||
PImage img;
|
PImage img;
|
||||||
byte[] brokenfile;
|
byte[] brokenfile;
|
||||||
int rw, rh;
|
int rw, rh;
|
||||||
|
String[] convertToPNG;
|
||||||
|
String[] convertToWebp;
|
||||||
WEBPCORRUPTION() {
|
WEBPCORRUPTION() {
|
||||||
name = "fxWebpCorruption";
|
name = "fxWebpCorruption";
|
||||||
params.add(new Param("byte amount to change probability", INTVAL, 2, 50, new int[]{RANDOM}));
|
params.add(new Param("byte amount to change probability", INTVAL, 2, 50, new int[]{RANDOM}));
|
||||||
@@ -4366,15 +4368,8 @@ class WEBPCORRUPTION extends Shader {
|
|||||||
rw = canvas.width;
|
rw = canvas.width;
|
||||||
rh = canvas.height;
|
rh = canvas.height;
|
||||||
img = createImage(rw, rh, ARGB);
|
img = createImage(rw, rh, ARGB);
|
||||||
String encodecmd[] = {"convert \"" + dataPath("") + "/img.png\" \"" + dataPath("") + "/WEBPhex.webp\""};
|
convertToPNG = new String[]{"/usr/local/bin/convert", "-verbose", dataPath("") + "/webp_glitched.webp", dataPath("") + "/webp_glitched.png"};
|
||||||
String decodecmd[] = {"convert \"" + dataPath("") + "/result.webp\" \"" + dataPath("") + "/result.png\""};
|
convertToWebp = new String[]{"/usr/local/bin/convert", "-verbose", dataPath("") + "/webp_orig.png", dataPath("") + "/webp_orig.webp"};
|
||||||
if (OS == "mac") {
|
|
||||||
saveStrings(dataPath("") + "/webpencode.command", encodecmd);
|
|
||||||
saveStrings(dataPath("") + "/webpdecode.command", decodecmd);
|
|
||||||
} else if (OS == "windows") {
|
|
||||||
saveStrings(dataPath("") + "/webpencode.cmd", encodecmd);
|
|
||||||
saveStrings(dataPath("") + "/webpdecode.cmd", decodecmd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply() {
|
void apply() {
|
||||||
@@ -4390,11 +4385,11 @@ class WEBPCORRUPTION extends Shader {
|
|||||||
canvas.image(img, canvas.width/2, canvas.height/2);
|
canvas.image(img, canvas.width/2, canvas.height/2);
|
||||||
|
|
||||||
|
|
||||||
File oldImage = new File(dataPath("")+"/webp_orig.webp");
|
File oldImage = new File(dataPath("")+"/webp_orig.png");
|
||||||
if (oldImage.exists()) {
|
if (oldImage.exists()) {
|
||||||
oldImage.delete();
|
oldImage.delete();
|
||||||
}
|
}
|
||||||
oldImage = new File(dataPath("")+"/png_orig.png");
|
oldImage = new File(dataPath("")+"/webp_orig.webp"); //is it better to move this up again?
|
||||||
if (oldImage.exists()) {
|
if (oldImage.exists()) {
|
||||||
oldImage.delete();
|
oldImage.delete();
|
||||||
}
|
}
|
||||||
@@ -4406,21 +4401,14 @@ class WEBPCORRUPTION extends Shader {
|
|||||||
if (oldImage.exists()) {
|
if (oldImage.exists()) {
|
||||||
oldImage.delete();
|
oldImage.delete();
|
||||||
}
|
}
|
||||||
String[] convertToPNG = {"/usr/local/bin/convert", "-verbose", dataPath("") + "/webp_glitched.webp", dataPath("") + "/webp_glitched.png"};
|
canvas.save(dataPath("")+"/webp_orig.png"); //save as png
|
||||||
while (!runCommand(convertToPNG)) {
|
int failCount = 0;
|
||||||
|
while (!runCommand(convertToPNG) && failCount < 25) {
|
||||||
|
failCount ++;
|
||||||
println("Trying to convert...");
|
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)) {
|
while (!runCommand(convertToWebp)) {
|
||||||
println("Conversion failed, trying again...");
|
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.
|
brokenfile = loadBytes(dataPath("")+"/webp_orig.webp"); //and reload. just in case it wasnt a jpg.
|
||||||
byte[] savebytes = new byte[brokenfile.length];
|
byte[] savebytes = new byte[brokenfile.length];
|
||||||
double probability = float(probparam) / float(brokenfile.length);
|
double probability = float(probparam) / float(brokenfile.length);
|
||||||
@@ -4452,7 +4440,8 @@ class WEBPCORRUPTION extends Shader {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
img = loadImage(dataPath("") + "/webp_glitched.png");
|
if(failCount == 50) println("Failed 50 times, skipping webp glitch");
|
||||||
|
else img = loadImage(dataPath("") + "/webp_glitched.png");
|
||||||
|
|
||||||
//launch(dataPath("") + "/webpdecode.command");
|
//launch(dataPath("") + "/webpdecode.command");
|
||||||
//delay(1500);
|
//delay(1500);
|
||||||
|
|||||||
Reference in New Issue
Block a user