image display fix, change of saving method

This commit is contained in:
tsulej
2015-04-20 01:02:57 +02:00
parent c45a2608ca
commit 74c8c56e26
10 changed files with 298 additions and 128 deletions
+8 -3
View File
@@ -9,7 +9,9 @@
// ENTER - to decay automaticly
// drag clicked mouse to decay in or out
String filename = "test.jpg";
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
int max_display_size = 800; // viewing window size (regardless image size)
@@ -20,8 +22,11 @@ PImage img;
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
img = loadImage(filename);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
buffer = createGraphics(img.width, img.height);
buffer.image(img,0,0);
@@ -66,7 +71,7 @@ void mouseDragged() {
void keyPressed() {
if(key == 'i') in = !in;
if(keyCode == RETURN || keyCode == ENTER) auto = !auto;
if(keyCode == 32) { buffer.save("res_"+(int)random(10000,99999)+"_"+filename); print("saved... "); };
if(keyCode == 32) { buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext); print("saved... "); };
printStats();
}
+11 -6
View File
@@ -3,13 +3,15 @@
// Licence CC-BY-SA 3.0
// put image filename here:
String imagefilename = "test.jpg";
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
// choose channel
int channel = HUE;
// run, after 30 iterations result will be saved automatically
// or click mouse when ready
// or press SPACE
int max_display_size = 800; // viewing window size (regardless image size)
@@ -39,8 +41,11 @@ int len;
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
img = loadImage(imagefilename);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
@@ -97,7 +102,7 @@ void draw() {
}
buffer.endDraw();
if(tick == 30) buffer.save("res_"+(int)random(10000,99999)+"_"+imagefilename);
if(tick == 30) keyPressed();
image(buffer,0,0,width,height);
}
@@ -118,7 +123,7 @@ float getChannel(color c) {
return channel>5?255-cc:cc;
}
void mouseClicked() {
buffer.save("res_"+(int)random(10000,99999)+"_"+imagefilename);
void keyPressed() {
buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
println("image saved");
}
+8 -3
View File
@@ -13,7 +13,9 @@
// NOTE: small change to stroke_len, angles_no, stroke_alpha may have dramatic effect
// image filename
String filename = "test.jpg";
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
int stat_type = ABSDIST2; // type of diff calculation: fast: ABSDIST, DIST, slow: HUE, SATURATION, BRIGHTNESS
int stroke_len = 3; // length of the stroke, values: 1 and above
@@ -32,8 +34,11 @@ PImage img;
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
img = loadImage(filename);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
@@ -214,7 +219,7 @@ void printParameters() {
void keyPressed() {
println("");
if(keyCode == 32) {
buffer.save("res_"+(int)random(10000,99999)+"_"+filename);
buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
print("image saved");
} else if(key == 'i') {
interactive = !interactive;
+8 -4
View File
@@ -14,7 +14,9 @@
// yes, it's rather slow
String imagename = "test.jpg";
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
int max_display_size = 800; // viewing window size (regardless image size)
@@ -33,8 +35,11 @@ boolean negative;
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
img = loadImage(imagename);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
@@ -62,8 +67,7 @@ void setup() {
void draw() {}
void keyPressed() {
int r = (int)random(1000,9999);
buffer.save("res_"+r+"_"+imagename);
buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
println("image saved");
}
+83 -42
View File
@@ -21,9 +21,14 @@
// find line with fill(n) - there are hidden other options as a comments
// filename
String filename = "test.jpg"; // image to process
String lensfilename = null; // use different image to use as lens (null = use same as image to process)
//String lensfilename = "lens1.jpg";
String filename = "test"; // image to process
String fileext = ".jpg";
String foldername = "./";
String lensfilename = null; // use different image to use as lens (null = use same as image to process), full path please!
//String lensfilename = "./lens1.jpg";
int max_display_size = 800; // viewing window size (regardless image size)
// set to true to use colour lovers random pattern
// http://www.colourlovers.com/patterns
@@ -69,28 +74,14 @@ boolean interactive = false; // move mouse to set bend when active, ENTER to act
float[] facts = new float[2];
void getCLPattern() {
int n = (int)random(1,4719052);
print("Loading pattern from ColourLovers number: "+n+"...");
String pad="";
if(n<1000) pad = "0";
else {
String nn = ""+n;
pad = nn.substring(0,nn.length()-3);
}
String clname = "http://colourlovers.com.s3.amazonaws.com/images/patterns/"+pad+"/"+n+".png";
try {
limg = loadImage(clname, "png");
} catch(Exception e) {
getCLPattern();
}
println(" done");
}
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
img = loadImage(filename);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
img.loadPixels();
if(lensfilename != null) {
@@ -99,13 +90,28 @@ void setup() {
} else
limg=img;
size(img.width,img.height);
noStroke();
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
buffer.noStroke();
buffer.endDraw();
// calculate window size
float ratio = (float)img.width/(float)img.height;
int neww, newh;
if(ratio < 1.0) {
neww = (int)(max_display_size * ratio);
newh = max_display_size;
} else {
neww = max_display_size;
newh = (int)(max_display_size / ratio);
}
size(neww,newh);
if(use_clpattern) getCLPattern();
facts[0] = bendx * width;
facts[1] = bendy * height;
facts[0] = bendx * img.width;
facts[1] = bendy * img.height;
drawMe();
}
@@ -147,31 +153,43 @@ int getShift(color c, int idx) {
}
void drawMe() {
background(0);
buffer.beginDraw();
buffer.background(0);
for(int x=0;x<width;x++) {
int lx = ((int)(x*pattern_factor))%limg.width;
for(int y=0;y<height;y++) {
int ly = ((int)(y*pattern_factor))%limg.height;
for(int x=0;x<img.width;x++) {
int lx;
if(use_clpattern) lx = ((int)(x*pattern_factor))%limg.width;
else lx = (int)map(x,0,img.width-1,0,limg.width-1);
for(int y=0;y<img.height;y++) {
int ly;
if(use_clpattern) ly = ((int)(y*pattern_factor))%limg.height;
else ly = (int)map(y,0,img.height-1,0,limg.height-1);
color c = limg.pixels[lx+ly*limg.width];
int posx = (x+getShift(c, 0)+2*width)%width;
int posy = (y+getShift(c, 1)+2*height)%height;
int posx = (x+getShift(c, 0)+2*img.width)%img.width;
int posy = (y+getShift(c, 1)+2*img.height)%img.height;
color n = img.pixels[posx+posy*width];
color n = img.pixels[posx+posy*img.width];
fill(n);
buffer.fill(n);
// fill(red(c),green(c),blue(n)); // work only on blue channel
// fill(red(n), abs(green(c)-green(n)), blue(n)); // green channel is blended using difference method
rect(x,y,1,1);
buffer.rect(x,y,1,1);
}
}
buffer.endDraw();
image(buffer,0,0,width,height);
}
void draw() {
if(interactive) {
facts[0] = mouseX;
facts[1] = mouseY;
facts[0] = (int)map(mouseX,0,width,0,img.width);
facts[1] = (int)map(mouseY,0,height,0,img.height);
drawMe();
}
@@ -184,8 +202,8 @@ void mouseClicked() {
channels[1] = (int)random(12);
types[0] = (int)random(4);
types[1] = (int)random(4);
facts[0] = mouseX;
facts[1] = mouseY;
facts[0] = (int)map(mouseX,0,width,0,img.width);
facts[1] = (int)map(mouseY,0,height,0,img.height);
drawMe();
}
@@ -197,7 +215,7 @@ void keyPressed() {
}
if(keyCode == 32) {
saveFrame("res_"+(int)random(10000,99999)+"_"+filename);
buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
println("image saved");
}
@@ -206,4 +224,27 @@ void keyPressed() {
println("pattern changed");
drawMe();
}
}
void getCLPattern() {
int n = (int)random(1,4719052);
print("Loading pattern from ColourLovers number: "+n+"...");
String pad="";
if(n<1000) pad = "0";
else {
String nn = ""+n;
pad = nn.substring(0,nn.length()-3);
}
String clname = "http://colourlovers.com.s3.amazonaws.com/images/patterns/"+pad+"/"+n+".png";
try {
limg = loadImage(clname, "png");
} catch(Exception e) {
getCLPattern();
}
if(limg.width <=0) getCLPattern();
println(" done");
}
+8 -3
View File
@@ -32,7 +32,9 @@ import java.util.Arrays;
import java.util.Map;
// set up filename
String filename = "test.jpg";
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
int max_display_size = 800; // viewing window size (regardless image size)
@@ -77,8 +79,11 @@ final static int SORT = 4; // sort segments by color value
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
img = loadImage(filename);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
@@ -109,7 +114,7 @@ void draw() {}
void keyPressed() {
if(keyCode == 32) {
String fn = "res_"+(int)random(10000,99999)+"_"+filename;
String fn = foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext;
buffer.save(fn);
PrintWriter w = createWriter(fn+".txt");
printOptions(w);
+66 -30
View File
@@ -23,7 +23,11 @@
// SPACE to save
// filename here:
String filename = "test.jpg";
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
int max_display_size = 800; // viewing window size (regardless image size)
// actions here (comma separated in curly braces):
int[] order = { UL, L, DL };
@@ -70,22 +74,47 @@ int tx,ty;
PImage img;
void setup() { //<>//
img = loadImage(filename);
size(img.width,img.height);
image(img,0,0);
noStroke();
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
size = width<height?width:height;
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
buffer.image(img,0,0);
buffer.noStroke();
buffer.endDraw();
// calculate window size
float ratio = (float)img.width/(float)img.height;
int neww, newh;
if(ratio < 1.0) {
neww = (int)(max_display_size * ratio);
newh = max_display_size;
} else {
neww = max_display_size;
newh = (int)(max_display_size / ratio);
}
size(neww,newh);
//<>//
size = img.width<img.height?img.width:img.height;
tx=ty=0;
if(width>size) tx = width-size;
if(height>size) ty = height-size;
if(img.width>size) tx = img.width-size;
if(img.height>size) ty = img.height-size;
image(buffer,0,0,width,height);
}
void draw() {}
void mouseClicked() {
buffer.beginDraw();
if(automatic) {
int n = (int)random(1,16);
order = new int[n];
@@ -93,12 +122,18 @@ void mouseClicked() {
}
for(int i=0;i<order.length;i++) doMirror(order[i]);
buffer.endDraw();
image(buffer,0,0,width,height);
}
void keyPressed() {
if(keyCode == ENTER || keyCode == RETURN) image(img,0,0);
if(keyCode == 32) saveFrame("res_"+(int)random(10000,99999)+"_"+filename);
if(keyCode == ENTER || keyCode == RETURN) {
buffer.beginDraw();
buffer.image(img,0,0);
buffer.endDraw();
image(buffer,0,0,width,height);
}
if(keyCode == 32) buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
}
void doMirror(int type) {
@@ -128,6 +163,7 @@ void doMirror(int type) {
case RUR: doDiagRRect(true); break;
case RDR: doDiagRRect(false); break;
}
}
void doDiagUL(int type, boolean shift) {
@@ -155,36 +191,36 @@ void doDiagUR(int type, boolean shift) {
}
void doHorizontal(boolean type) {
for(int y=0;y<height/2;y++)
for(int x=0;x<width;x++)
if(type) drawPoint(x,y,x,height-y-1,false);
else drawPoint(x,height-y-1,x,y,false);
for(int y=0;y<img.height/2;y++)
for(int x=0;x<img.width;x++)
if(type) drawPoint(x,y,x,img.height-y-1,false);
else drawPoint(x,img.height-y-1,x,y,false);
}
void doVertical(boolean type) {
for(int x=0;x<width/2;x++)
for(int y=0;y<height;y++)
if(type) drawPoint(x,y,width-x-1,y,false);
else drawPoint(width-x-1,y,x,y,false);
for(int x=0;x<img.width/2;x++)
for(int y=0;y<img.height;y++)
if(type) drawPoint(x,y,img.width-x-1,y,false);
else drawPoint(img.width-x-1,y,x,y,false);
}
void doDiagLRect(boolean m) {
for(int y=0;y<height;y++) {
int d = m?(int)map(y,0,height,0,width):(int)map(y,0,height-1,width-1,0);
for(int y=0;y<img.height;y++) {
int d = m?(int)map(y,0,img.height,0,img.width):(int)map(y,0,img.height,img.width,0);
for(int x=0;x<d;x++) {
fill(get(x,y));
rect(width-x-1,height-y-1,1,1);
buffer.fill(buffer.get(x,y));
buffer.rect(img.width-x-1,img.height-y-1,1,1);
}
}
}
void doDiagRRect(boolean m) {
for(int y=0;y<height;y++) {
int d = m?(int)map(y,0,height,0,width):(int)map(y,0,height-1,width-1,0);
for(int y=0;y<img.height;y++) {
int d = m?(int)map(y,0,img.height,0,img.width):(int)map(y,0,img.height,img.width,0);
for(int x=0;x<d;x++) {
fill(get(width-x-1,height-y-1));
rect(x,y,1,1);
buffer.fill(buffer.get(img.width-x-1,img.height-y-1));
buffer.rect(x,y,1,1);
}
}
}
@@ -195,6 +231,6 @@ void drawPoint(int oldx, int oldy, int newx, int newy, boolean shift) {
int sy=0;
if(shift) { sx = tx; sy = ty; } // fucking rectangles...
fill(get(oldx+sx,oldy+sy));
rect(newx+sx,newy+sy,1,1);
buffer.fill(buffer.get(oldx+sx,oldy+sy));
buffer.rect(newx+sx,newy+sy,1,1);
}
+12 -8
View File
@@ -26,8 +26,11 @@ import generateme.analogtv.*;
// CONFIGURATION BEGIN
String imagename = "test.jpg"; // should have 4:3 ratio
//String secondimage = "people.jpg"; // if you want to mix with second image, put its name here
String filename = "test"; // should have 4:3 ratio
String fileext = ".jpg";
String foldername = "./";
//String secondimage = "people.jpg"; // if you want to mix with second image, put its name here, full path here
String secondimage = null;
// General settings
@@ -70,11 +73,13 @@ TV tv;
Reception rec1; // image
Reception rec2; // noise
String sessionid;
void setup() {
sessionid = hex((int)random(0xffff),4);
size(W,3*W/4);
background(0);
noStroke();
seed = "_" + (int)random(10000,99999);
tv = new TV(this, width, height);
tv.powerup = POWERUP;
@@ -106,7 +111,7 @@ void reset() {
rec1.hfloss2 = HFLOSS2;
rec1.do_hfloss2 = DO_HFLOSS2;
tv.setup_sync(rec1.signal,COLOR_SYNC, DISABLE_SYNC);
tv.set_image(rec1.signal,loadImage(imagename));
tv.set_image(rec1.signal,loadImage(foldername+filename+fileext));
if(TELETEXT) tv.setup_teletext(rec1.signal);
rec2 = new Reception(this);
@@ -144,7 +149,7 @@ void randomize() {
rec1.hfloss2 = random(-2,5);
rec1.do_hfloss2 = random(1)<0.2?true:false;
tv.setup_sync(rec1.signal,random(1)<0.8, random(1)<0.2);
if(random(1)<0.9) tv.set_image(rec1.signal,loadImage(imagename));
if(random(1)<0.9) tv.set_image(rec1.signal,loadImage(foldername+filename+fileext));
if(random(1)<0.5) tv.setup_teletext(rec1.signal);
rec2 = new Reception(this);
@@ -154,7 +159,7 @@ void randomize() {
tv.set_image(rec2.signal,loadImage(secondimage));
if(random(1)<0.5) tv.setup_teletext(rec2.signal);
} else if(random(1)<0.3)
tv.set_image(rec2.signal,loadImage(imagename));
tv.set_image(rec2.signal,loadImage(foldername+filename+fileext));
tv.clear_receptions();
boolean onlynoise = random(1)<0.2;
@@ -178,13 +183,12 @@ void mousePressed() {
randomize();
}
String seed = "_12345";
void keyPressed() {
noLoop();
switch(keyCode) {
case ENTER: reset(); break;
case RETURN: reset(); break;
case 32: saveFrame("frame_"+frameCount+seed+".png");
case 32: saveFrame(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
default: break;
}
loop();
+47 -16
View File
@@ -10,7 +10,11 @@
// sometimes it copies the image, I don't know why, ignore and click more
// put file name here
String filename = "test.jpg";
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
int max_display_size = 800; // viewing window size (regardless image size)
// logic starts here
int[] fx;
@@ -32,25 +36,48 @@ float[][] ft = new float[2][32];
int depth; // number of octaves
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
img = loadImage(filename);
size(img.width,img.height);
noStroke();
fill(255);
background(0);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
buffer.noStroke();
buffer.fill(255);
buffer.background(0);
buffer.endDraw();
// calculate window size
float ratio = (float)img.width/(float)img.height;
int neww, newh;
if(ratio < 1.0) {
neww = (int)(max_display_size * ratio);
newh = max_display_size;
} else {
neww = max_display_size;
newh = (int)(max_display_size / ratio);
}
size(neww,newh);
for(int i=0;i<32;i++) {
ft[0][i] = pow(2.0,i);
ft[1][i] = 0.5*1.0/ft[0][i];
}
int s = width>height?height:width;
int s = img.width>img.height?img.height:img.width;
depth = (int)(log(s)/log(2));
mouseClicked();
}
void mouseClicked() {
buffer.beginDraw();
int fxnum = (int)random(depth);
int fynum = (int)random(depth);
@@ -82,33 +109,37 @@ void mouseClicked() {
doy = dox?random(1)<0.8:true;
float v=0;
for(int y=0;y<height;y++)
for(int x=0;x<width;x++) {
float iy = map(y,0,height,0,1);
for(int y=0;y<img.height;y++)
for(int x=0;x<img.width;x++) {
float iy = map(y,0,img.height,0,1);
v=0;
if(doy) for(int i=0;i<fy.length;i++)
if(!skipfy[i]) v+=sy[i]*getValue(fy[i],iy,i,phy[i]);
float ry = 2*iy+v;
float y2 = (3*height+ry * height/2)%height;
float y2 = (3*img.height+ry * img.height/2)%img.height;
float ix = map(x,0,width,0,1);
float ix = map(x,0,img.width,0,1);
v=0;
if(dox) for(int i=0;i<fx.length;i++)
if(!skipfx[i]) v+=sx[i]*getValue(fx[i],ix,i,phx[i]);
float rx = 2*ix+v;
float x2 = (3*width+rx * width/2)%width;
float x2 = (3*img.width+rx * img.width/2)%img.width;
fill(img.get((int)x2,(int)y2));
rect(x,y,1,1);
buffer.fill(img.get((int)x2,(int)y2));
buffer.rect(x,y,1,1);
}
buffer.endDraw();
image(buffer,0,0,width,height);
}
void keyPressed() {
save("res_"+(int)random(10000,99999)+"_"+filename);
buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
println("saved");
}
void draw() {}
+47 -13
View File
@@ -9,8 +9,14 @@
// * press SPACE to toggle between RGBRGB... (HSBHSB...) or RRR...GGG...BBB... (HHH...SSS...BBB...) raws
// * click to save
String filename = "test.jpg"; // file name of your raw
boolean do_hsb = true; // do operate on HSB channels
// filename
String filename = "test";
String fileext = ".jpg";
String foldername = "./";
int max_display_size = 800; // viewing window size (regardless image size)
boolean do_hsb = false; // do operate on HSB channels
// logic below
@@ -27,11 +33,35 @@ int n,n2,s;
boolean option1 = true;
float sc = 160;
PImage img;
// working buffer
PGraphics buffer;
String sessionid;
void setup() {
PImage img = loadImage(filename);
size(img.width, img.height);
noStroke();
background(0);
sessionid = hex((int)random(0xffff),4);
img = loadImage(foldername+filename+fileext);
buffer = createGraphics(img.width, img.height);
buffer.beginDraw();
buffer.background(0);
buffer.noStroke();
buffer.endDraw();
// calculate window size
float ratio = (float)img.width/(float)img.height;
int neww, newh;
if(ratio < 1.0) {
neww = (int)(max_display_size * ratio);
newh = max_display_size;
} else {
neww = max_display_size;
newh = (int)(max_display_size / ratio);
}
size(neww,newh);
s = img.width*img.height;
raw = new float[s*3];
@@ -43,8 +73,8 @@ void setup() {
int iter=0;
int iter2 = 0;
for(int y=0;y<height;y++) {
for(int x=0;x<width;x++) {
for(int y=0;y<img.height;y++) {
for(int x=0;x<img.width;x++) {
color c = img.get(x,y);
float r,g,b;
if(do_hsb) {
@@ -115,8 +145,8 @@ void option2() {
float r = clamp(out1[i]);
float g = clamp(out2[i]);
float b = clamp(out3[i]);
fill(r,g,b);
rect(i%width,i/width,1,1);
buffer.fill(r,g,b);
buffer.rect(i%img.width,i/img.width,1,1);
}
}
@@ -136,8 +166,8 @@ void option1() {
case 2: b = c; break;
default: {
r = c;
fill(r,g,b);
rect(floor(i/3.0)%width,floor(i/3.0)/width,1,1);
buffer.fill(r,g,b);
buffer.rect(floor(i/3.0)%img.width,floor(i/3.0)/img.width,1,1);
state = 0;
}
}
@@ -146,11 +176,15 @@ void option1() {
}
void draw() {
buffer.beginDraw();
scalingfactorin = map(mouseX,0,width,0,sc);
scalingfactorout = map(mouseY,0,height,0,sc);
if(option1) option1();
else option2();
buffer.endDraw();
image(buffer,0,0,width,height);
}
void printOption() {
@@ -184,7 +218,7 @@ void keyPressed() {
}
void mouseClicked() {
saveFrame("res_####_" + filename);
buffer.save(foldername + filename + "/res_" + sessionid + hex((int)random(0xffff),4)+"_"+filename+fileext);
println("image saved");
}