Java ProcessBuilder and backslashes
Posted: 2014-09-29T06:32:54-07:00
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:
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.
/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();
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.