I am using jhead
to check if an image has an Orientation flag set, and if it is, then rotate it and set the exif information to indicate it does not need to be rotated when viewed. On the commandline it looks like:
jhead -autorot 'IMG_3680.JPG'
I am trying to use ProcessBuilder
to call this from my java app on the images I am looking at, but it uses jpegtran
to do the actual image rotation. Both these apps work correctly from the commandline and are located in /opt/local/bin
on my mac.
I keep getting:
sh: jpegtran: command not found
Error : Problem executing specified command
in file '/images/IMG_3681.JPG'
My code is:
public static void main(String[] args) throws Exception {
File[] files = (new File("/images")).listFiles();
for (File file : files){
ProcessBuilder pb = new ProcessBuilder("jhead", "-autorot", file.getAbsolutePath());
pb.redirectOutput(Redirect.INHERIT);
pb.redirectError(Redirect.INHERIT);
Process p = pb.start();
}
}
Do I need to provide a hint to ProcessBuilder
in order for jhead
to be able to call jpegtran
?