-
-
Save UnforeseenOcean/c2cb5cad5a5b8f7793929e395fdebdf2 to your computer and use it in GitHub Desktop.
Open the last saved jpeg image Save it as a new jpeg image with slightly more compression Repeat 600 times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.image.codec.jpeg.*; | |
PImage img; | |
int numberOfFrames = 600; | |
void setup() | |
{ | |
size(1024,768); | |
} | |
void draw() | |
{ | |
for(int i =1; i < numberOfFrames ; i++) | |
{ | |
PImage reference = loadImage("sky"+(i-1)+".jpg"); | |
image(reference,0,0); | |
BufferedImage img=new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | |
loadPixels(); | |
img.setRGB(0, 0, width, height, g.pixels, 0, width); | |
try{ | |
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); | |
JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(img); | |
float q = map(i,0,numberOfFrames,1,0); | |
p.setQuality(q,true); | |
encoder.setJPEGEncodeParam(p); | |
encoder.encode(img); | |
File file = new File(savePath("data/sky"+i+".jpg")); | |
FileOutputStream fo = new FileOutputStream(file); | |
out.writeTo(fo); | |
} | |
catch(FileNotFoundException e){ | |
System.out.println(e); | |
} | |
catch(IOException ioe){ | |
System.out.println(ioe); | |
} | |
} | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment