public interface GMExecutor
String execute(@Nonnull String command, String... arguments) throws IOException, GMException, GMServiceException
This method can be used in different ways explained in the following sections using an example of drawing text NO IMAGE on a background defined by in.png.
One way is to prepare entire command line with proper space separation of GraphicsMagick arguments and pass it as one single string to command parameter. You don't need to use arguments parameter at all. Using this way, you need to make sure special characters are escaped and arguments with space are quoted. e.g.,
execute("convert in.png -draw \"text 50 100 \"\"NO IMAGE\"\"\" out.png");
A better way is to pass the command and arguments separately. The same example can now be written as below.
Notice that you don't need to add the quotes and escape the quotes anymore.
execute("convert", "in.png", "-draw", "text 50 100 \"NO IMAGE\"", "out.png");
command
- the command to be executedarguments
- arguments of the command.NullPointerException
- when command is nullIOException
- when GM encounter IO error executing the commandGMException
- when GraphicsMagick returns non-IO error executing the commandGMServiceException
- when there is error communicating with the underlying GraphicsMagick processexecute(List)
String execute(@Nonnull List<String> command) throws IOException, GMException, GMServiceException
command
- the command and arguments to be executedNullPointerException
- when command is nullIllegalArgumentException
- when command is an empty list.IOException
- when GM encounter IO error executing the commandGMException
- when GraphicsMagick returns non-IO error executing the commandGMServiceException
- when there is error communicating with the underlying GraphicsMagick processexecute(String, String...)
Copyright © 2013. All Rights Reserved.