Re: [Gimp-user] Gimp Java Batch not working

2014-03-07 Thread Ofnuts

On 03/07/2014 10:54 AM, Andreas Truszkowski wrote:

... the Java code :) :

File imageFile = new File(this.targetDir.getPath() + 
File.separator + UUID.randomUUID().toString() + ".png");
File testFile = new File(this.targetDir.getPath() + 
File.separator + "test.png");

Tools.compressJpegFile(imageFile, inImage, 1.0f);
String argString = String.format("(let* ((image (car 
(gimp-file-load RUN-NONINTERACTIVE \"%s\" \"%s\")))"

+ "(drawable (car (gimp-image-get-active-layer image"
+ "(plug-in-sobel RUN-NONINTERACTIVE image drawable 1 
1 1)"
+ "(gimp-file-save RUN-NONINTERACTIVE image drawable 
\"%s\" \"%s\")"
+ "(gimp-image-delete image))", imageFile.getPath(), 
imageFile.getPath(), testFile.getPath(), testFile.getPath());
String script = String.format("\"C:\\Program Files\\GIMP 
2\\bin\\gimp-2.8.exe\" -i -b '%s' -b '(gimp-quit 0)'", argString);

ProcessBuilder builder = new ProcessBuilder(script);
builder.directory(this.targetDir);
builder.redirectErrorStream(true);
if (!this.isCancelled()) {
Process process = builder.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
System.out.println("Program terminated!");
process.waitFor();
}

Kind regards,
Andreas

Am 07.03.2014 10:52, schrieb Andreas Truszkowski:

Hi there,

I am new to Gimp and first I want to thank the Gimp community for 
such a great application.


But here is my problem. I try to process images from within a Java 
application. When I run the assembled batch command the gimp console 
writes that the execution was successfull.



But actually nothing happens. Here is my Java code:


The resulting command line is:

"C:\Program Files\GIMP 2\bin\gimp-2.8.exe" -i -b '(let* ((image (car 
(gimp-file-load RUN-NONINTERACTIVE 
"z:\test\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png" 
"z:\test\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png")))(drawable (car 
(gimp-image-get-active-layer image(plug-in-sobel 
RUN-NONINTERACTIVE image drawable 1 1 1)(gimp-file-save 
RUN-NONINTERACTIVE image drawable "z:\test\test.png" 
"z:\test\test.png")(gimp-image-delete image))' -b '(gimp-quit 0)'


Executing this directly from command line does not fix the problem. 
Anyone a clue what I make wrong? Thank you in advance...




You should really use the |*ProcessBuilder 
*(List 
> command) 
contructor, that will give you more control on the parameters and let 
you avoid a lot of quoting and escaping. And instead of calling  Gimp, 
make it call a small script/program that dumps its parameters to stdout. 
As far as I can tell you are using the Unix shell syntax (leading single 
quote) while the file names indicate you are on Windows...


You will also save you a lot of grief by making all your scheme code a 
small script. Once that works you can try to pack the whole script back 
in a parameter.


If you call gimp with -c you will get messages printed to the console 
(ie, stdout) instead of being displayed by the graphical UI





|
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


Re: [Gimp-user] Gimp Java Batch not working

2014-03-07 Thread Kevin Cozens

On 14-03-07 04:52 AM, Andreas Truszkowski wrote:

But here is my problem. I try to process images from within a Java
application. When I run the assembled batch command the gimp console writes
that the execution was successfull.


But actually nothing happens. Here is my Java code:

[snip]

Executing this directly from command line does not fix the problem. Anyone a
clue what I make wrong?


The Scheme code looks correct, AFAICT. If in doubt, paste the code in to the 
Script-Fu console and see if it works as expected or if it spits out error 
messages.


If you run that code from a Windows command line you have to be aware of 
whether the \ characters are being seen as \ or if they are being used to 
escape the following character.


--
Cheers!

Kevin.

http://www.ve3syb.ca/   |"Nerds make the shiny things that distract
Owner of Elecraft K2 #2172  | the mouth-breathers, and that's why we're
| powerful!"
#include  | --Chris Hardwick
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


Re: [Gimp-user] Gimp Java Batch not working

2014-03-07 Thread Kevin Payne
Try replacing the single quote marks ' with double quotes " and also escaping 
the escaping the existing double quotes inside the single quotes:

"C:\Program Files\GIMP 2\bin\gimp-2.8.exe" -i -b "(let* ((image (car 
 (gimp-file-load RUN-NONINTERACTIVE 
 \"z:\test\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png\" ...

I'm not sure if you will also have to escape the backslashes in file name paths 
as well:  \"z:\\test\\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png\"

Kevin

> Date: Fri, 7 Mar 2014 10:52:27 +0100
> From: at_li...@gmx.de
> To: gimp-user-list@gnome.org
> Subject: [Gimp-user] Gimp Java Batch not working
> 
> Hi there,
> 
> I am new to Gimp and first I want to thank the Gimp community for such a 
> great application.
> 
> But here is my problem. I try to process images from within a Java 
> application. When I run the assembled batch command the gimp console 
> writes that the execution was successfull.
> 
> 
> But actually nothing happens. Here is my Java code:
> 
> 
> The resulting command line is:
> 
> "C:\Program Files\GIMP 2\bin\gimp-2.8.exe" -i -b '(let* ((image (car 
> (gimp-file-load RUN-NONINTERACTIVE 
> "z:\test\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png" 
> "z:\test\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png")))(drawable (car 
> (gimp-image-get-active-layer image(plug-in-sobel RUN-NONINTERACTIVE 
> image drawable 1 1 1)(gimp-file-save RUN-NONINTERACTIVE image drawable 
> "z:\test\test.png" "z:\test\test.png")(gimp-image-delete image))' -b 
> '(gimp-quit 0)'
> 
> Executing this directly from command line does not fix the problem. 
> Anyone a clue what I make wrong? Thank you in advance...
> 
> Kind regards,
> Andreas

  
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


Re: [Gimp-user] Gimp Java Batch not working

2014-03-07 Thread Andreas Truszkowski

... the Java code :) :

File imageFile = new File(this.targetDir.getPath() + 
File.separator + UUID.randomUUID().toString() + ".png");
File testFile = new File(this.targetDir.getPath() + 
File.separator + "test.png");

Tools.compressJpegFile(imageFile, inImage, 1.0f);
String argString = String.format("(let* ((image (car 
(gimp-file-load RUN-NONINTERACTIVE \"%s\" \"%s\")))"

+ "(drawable (car (gimp-image-get-active-layer image"
+ "(plug-in-sobel RUN-NONINTERACTIVE image drawable 1 1 1)"
+ "(gimp-file-save RUN-NONINTERACTIVE image drawable 
\"%s\" \"%s\")"
+ "(gimp-image-delete image))", imageFile.getPath(), 
imageFile.getPath(), testFile.getPath(), testFile.getPath());
String script = String.format("\"C:\\Program Files\\GIMP 
2\\bin\\gimp-2.8.exe\" -i -b '%s' -b '(gimp-quit 0)'", argString);

ProcessBuilder builder = new ProcessBuilder(script);
builder.directory(this.targetDir);
builder.redirectErrorStream(true);
if (!this.isCancelled()) {
Process process = builder.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
System.out.println("Program terminated!");
process.waitFor();
}

Kind regards,
Andreas

Am 07.03.2014 10:52, schrieb Andreas Truszkowski:

Hi there,

I am new to Gimp and first I want to thank the Gimp community for such 
a great application.


But here is my problem. I try to process images from within a Java 
application. When I run the assembled batch command the gimp console 
writes that the execution was successfull.



But actually nothing happens. Here is my Java code:


The resulting command line is:

"C:\Program Files\GIMP 2\bin\gimp-2.8.exe" -i -b '(let* ((image (car 
(gimp-file-load RUN-NONINTERACTIVE 
"z:\test\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png" 
"z:\test\26cf5abe-eaa1-4ddd-af04-3d9e59804ed2.png")))(drawable (car 
(gimp-image-get-active-layer image(plug-in-sobel 
RUN-NONINTERACTIVE image drawable 1 1 1)(gimp-file-save 
RUN-NONINTERACTIVE image drawable "z:\test\test.png" 
"z:\test\test.png")(gimp-image-delete image))' -b '(gimp-quit 0)'


Executing this directly from command line does not fix the problem. 
Anyone a clue what I make wrong? Thank you in advance...


Kind regards,
Andreas
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list