org.im4java.core
Class ImageCommand

java.lang.Object
  extended by org.im4java.process.ProcessStarter
      extended by org.im4java.core.ImageCommand
All Implemented Interfaces:
ErrorConsumer
Direct Known Subclasses:
CompositeCmd, ConvertCmd, DcrawCmd, DisplayCmd, ExiftoolCmd, GraphicsMagickCmd, IdentifyCmd, ImageMagickCmd, JpegtranCmd, MogrifyCmd, MontageCmd, UFRawCmd

public class ImageCommand
extends ProcessStarter
implements ErrorConsumer

This class implements the processing of image operations. It replaces placeholders within the argument-stack and passes all arguments to the generic run-method of ProcessStarter.

Version:
$Revision: 1.13 $
Author:
$Author: bablokb, Bruno Mascret (warnings) $

Field Summary
private  java.util.LinkedList<java.lang.String> iCommands
          The command (plus initial arguments) to execute.
private  java.util.ArrayList<java.lang.String> iErrorText
          List of stderr-output.
private  java.util.LinkedList<java.lang.String> iTmpFiles
          List of temporary files (input).
private  java.lang.String iTmpOutputFile
          Temporary output file.
 
Fields inherited from class org.im4java.process.ProcessStarter
BUFFER_SIZE
 
Constructor Summary
ImageCommand()
          Constructor.
ImageCommand(java.lang.String... pCommands)
          Constructor setting the commands.
 
Method Summary
 void consumeError(java.io.InputStream pInputStream)
          This method just saves the stderr-output into an internal field.
private  java.lang.String convert2TmpFile(java.awt.image.BufferedImage pBufferedImage)
          Write a BufferedImage to a temporary file.
private  java.lang.String getTmpFile()
          Create a temporary file.
private  void removeTmpFiles()
          Remove all temporary files.
private  void resolveDynamicOperations(Operation pOp, java.util.LinkedList<java.lang.String> pArgs, java.lang.Object... pImages)
          Resolve DynamicOperations.
private  void resolveImages(java.util.LinkedList<java.lang.String> pArgs, java.lang.Object... pImages)
          Resolve images passed as arguments.
 void run(Operation pOperation, java.lang.Object... images)
          Execute the command (replace given placeholders).
 void setCommand(java.lang.String... pCommands)
          Set the command.
 
Methods inherited from class org.im4java.process.ProcessStarter
addProcessListener, getIInputProvider, getIProcessListener, isAsyncMode, run, setAsyncMode, setErrorConsumer, setInputProvider, setOutputConsumer, startProcess, waitForProcess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iCommands

private java.util.LinkedList<java.lang.String> iCommands
The command (plus initial arguments) to execute.


iErrorText

private java.util.ArrayList<java.lang.String> iErrorText
List of stderr-output.


iTmpFiles

private java.util.LinkedList<java.lang.String> iTmpFiles
List of temporary files (input).


iTmpOutputFile

private java.lang.String iTmpOutputFile
Temporary output file.

Constructor Detail

ImageCommand

public ImageCommand()
Constructor.


ImageCommand

public ImageCommand(java.lang.String... pCommands)
Constructor setting the commands.

Method Detail

setCommand

public void setCommand(java.lang.String... pCommands)
Set the command.


run

public void run(Operation pOperation,
                java.lang.Object... images)
         throws java.io.IOException,
                java.lang.InterruptedException,
                IM4JavaException
Execute the command (replace given placeholders).

Throws:
IM4JavaException
java.io.IOException
java.lang.InterruptedException

resolveImages

private void resolveImages(java.util.LinkedList<java.lang.String> pArgs,
                           java.lang.Object... pImages)
                    throws java.io.IOException
Resolve images passed as arguments.

Throws:
java.io.IOException

resolveDynamicOperations

private void resolveDynamicOperations(Operation pOp,
                                      java.util.LinkedList<java.lang.String> pArgs,
                                      java.lang.Object... pImages)
                               throws IM4JavaException
Resolve DynamicOperations.

Throws:
IM4JavaException

consumeError

public void consumeError(java.io.InputStream pInputStream)
                  throws java.io.IOException
This method just saves the stderr-output into an internal field.

Specified by:
consumeError in interface ErrorConsumer
Throws:
java.io.IOException
See Also:
ErrorConsumer.consumeError(java.io.InputStream)

getTmpFile

private java.lang.String getTmpFile()
                             throws java.io.IOException
Create a temporary file.

Throws:
java.io.IOException

convert2TmpFile

private java.lang.String convert2TmpFile(java.awt.image.BufferedImage pBufferedImage)
                                  throws java.io.IOException
Write a BufferedImage to a temporary file.

Throws:
java.io.IOException

removeTmpFiles

private void removeTmpFiles()
Remove all temporary files.