We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello. I'm some what new to processing: Question?
I recently came across a java class for vector image tracing on GitHub that I would like to use but I am not sure how to make it work inside processing.
Any suggestions how I can use the class or .jar file inside processing? Thanks.
https://github.com/jankovicsandras/imagetracerjava
Code snippet of the class...
package jankovicsandras.imagetracer;
import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.TreeMap;
import javax.imageio.ImageIO;
public class ImageTracer{
public static String versionnumber = "1.1.2";
public ImageTracer(){}
public static void main (String[] args){
try{
if(args.length<1){
System.out.println("ERROR: there's no input filename. Basic usage: \r\n\r\njava -jar ImageTracer.jar <filename>"+
"\r\n\r\nor\r\n\r\njava -jar ImageTracer.jar help");
} else if(arraycontains(args,"help")>-1){
System.out.println("Example usage:\r\n\r\njava -jar ImageTracer.jar <filename> outfilename test.svg "+
"ltres 1 qtres 1 pathomit 8 colorsampling 1 numberofcolors 16 mincolorratio 0.02 colorquantcycles 3 "+
"scale 1 simplifytolerance 0 roundcoords 1 lcpr 0 qcpr 0 desc 1 viewbox 0 blurradius 0 blurdelta 20 \r\n"+
"\r\nOnly <filename> is mandatory, if some of the other optional parameters are missing, they will be set to these defaults. "+
"\r\nWarning: if outfilename is not specified, then <filename>.svg will be overwritten."+
"\r\nSee https://github.com/jankovicsandras/imagetracerjava for details. \r\nThis is version "+versionnumber);
} else {
// Parameter parsing
String outfilename = args[0]+".svg";
HashMap<String,Float> options = new HashMap<String,Float>();
String[] parameternames = {"ltres","qtres","pathomit","colorsampling","numberofcolors","mincolorratio","colorquantcycles","scale","simplifytolerance","roundcoords","lcpr","qcpr","desc","viewbox","blurradius","blurdelta","outfilename"};
int j = -1; float f = -1;
for (String parametername : parameternames) {
j = arraycontains(args,parametername);
if(j>-1){
if(parametername=="outfilename"){
if( j < (args.length-1)){ outfilename = args[j+1]; }
}else{
f = parsenext(args,j); if(f>-1){ options.put(parametername, new Float(f)); }
}
}
}// End of parameternames loop
// Loading image, tracing, rendering SVG, saving SVG file
saveString(outfilename,imageToSVG(args[0],options,null));
}// End of parameter parsing and processing
}catch(Exception e){ e.printStackTrace(); }
}// End of main()
Answers
https://Forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Thank you for the tips and article. I will give it a try.