Java ProcessBuilder and backslashes

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
rjh.sgc
Posts: 1
Joined: 2014-09-29T06:17:54-07:00
Authentication code: 6789

Java ProcessBuilder and backslashes

Post by rjh.sgc »

Im trying to run the resize command with conditional shrinking through java. the following command works in the terminal window:

/usr/bin/convert my.jpg -resize 1280x720\> output.jpg

But the following does not resize the photo:

Code: Select all

String[] command = {"/usr/bin/convert", "my.jpg", "-resize", "1280x720\\>", "output.jpg"};
ProcessBuilder pb = new ProcessBuilder(command);
pb.redirectErrorStream(true);
Process process = pb.start();
If I change the 4th parameter to just "1280x720" (i.e. - always resize the image), it works fine. Seems like this is a problem with blackslashes, but I'm not sure if it's in ProcessBuilder or imagemagick.

Using:
Version: ImageMagick 6.8.9-5 Q16 x86_64 2014-07-25
Java SE Runtime Environment (build 1.7.0_51-b13)
Mac OSX

Any thoughts? Thanks.
Post Reply