I am writing a java program to make an edit to a sequence of images, but I am looking for an easy and flexible way to do this edit using the Image Editors Scripts (eg: Photoshop Scripts, Gimp Scripts, …).
Can I run Photoshop Scripts or GIMP Scripts on images in a Java Program ?
I know that these scripts are written in Javascript. At least, can I run a javascript functions in a JVM ? and is there some Photoshop APIs (jars) that I should add to make editing images with scripts works properly ?
UPDATE
It’s clear that running JavaScript codes using the Nashorn from answers, but I still need some answers.
I am looking if it is possible to run the photoshop or GIMP scripts on nashorn like a normal script and get the result in the java program ?
It does not need any dependencies or some libraries to make running the script on images work properly ?
How to put an image as parameter before running the script and get the result after running it to do other things on the new image like printing it or saving it or even running another script ?
Thank you
2
Answers
Perhaps Nashorn is what you’re looking for.
I don’t think there is any easy way to run existing photoshop or gimp scripts outside of photoshop/gimp. Since gimp is open source, with potentially a lot of work it may be possible to get it working. With photoshop all you have is documentation.
So probably the only way would be to allow your own script, for example in javascript. And as other answer already says, you can run javascripts from java using nashorn. In general, I think such question is too broad to be fully answered on stackoverflow as I don’t think it’s something that has a quick and easy solution.