Can I drag and drop to launch code?

edited November 2016 in How To...

Hi guys, I just discovered Processing, and I think it might be exactly what I'm looking for. But I need to check something: can I create a program (or batch file) that I drag an image file onto in order to run some code on that mage?

More details: I want to write some code to read the transparency of pixels and output a text file. As far as I can tell, Processing might be able to do that? Ideally I'd like to finish with a WIndows EXE file, and I just drag an image onto it (or onto a batch file that calls it), and bingo, a text file is created. Does that make sense?

For example, the program "PNGQuant" can creates smaller versions of PNGs: all you do is drag your big PNG onto the appropriate .bat file, and magically a smaller image file is saved. It's super useful. I want to make something similar, but for reading pixels and doing some calculations, then outputting text. Do you think that would be possible in Processing?

Thanks for any comments or suggestions.

Tagged:

Answers

  • Answer ✓

    Possible

    See reference

    Loadimage

    img.save

    Savestrings and the like

    use args[]

  • Many thanks for the prompt replies! I did search for the answer, but obviously my searching skills need help. And thanks for supporting Processing, I've been looking for something like this for years. (But not looking very hard, obviously!)

  • Yeah, I like it a lot

  • Answer ✓

    @tolworthy

    You should check the library drop. Install it using the import library available in the Procesing IDE's menu: Sketch >> Import library... >> Add library... and then search for drop. Then in the example section of that library, check the example DropLoadImage.pde. If you can make this as an executable, then you got there almost what you want.

    Kf

Sign In or Register to comment.