How can i add a "Open with" function?

Hi @Aryszin,

you mean by install that want to make an executable from your sketch ie. MySketch.exe on a specific location on disk ?

If so you can do for example the following to get the command line parameter on calling the sketch executable.

PImage myImage;
String myDefaultImageName = "noimage.jpg"; // should be a valid and existing image in data folder
String myImageName;

void settings() {
  if (args == null) {
    myImageName = myDefaultImageName;
  } else {
    myImageName = args[0];
  }
  myImage=loadImage(myImageName);
  if (myImage == null) {
    myImageName = myDefaultImageName;
    myImage=loadImage(myImageName);    
  }
  size(myImage.width, myImage.height);
}

void setup() {
  surface.setTitle(myImageName);
}

void draw() {
  image(myImage, 0, 0);
}

Assuming you already have build the executable from your sketch and it processes the command line argument similar as shown above, you can start your sketch executable by
...\MySketch.exe <full_path_to_image>.

Please note that you need to set the working directory to your MySketch.exe path otherwise it wouldn’t start the MySketch.exe properly. For that it could be necessary to wrap everything in a batch file to make a cd before calling the executable

ie run.bat content:

cd /D <path_to_MySketch.exe>
MySketch.exe %1

Hope that helps …

Cheers
— mnse

Examples
run.bat
example1

run.bat <path_to_processing_logo>

PS: Error handling could be refined to your needs (ie. exit if not a valid image instead of showing noimage)

PPS: if you don’t want to create an executable but want to call the sketch by processing-java.exe, you can call the above example by …

<path_to_processing>\processing-java.exe --sketch="<path_to_your_sketch_folder>" --run "<path_to_the_image_file>"
2 Likes