Skip to end of metadata
Go to start of metadata

Requirements: Fits, OpenJPEG 2.0, Jpylyzer, and ImageMagick, and Taverna installed on local machine.

You should be able to run Taverna and execute the following commands on your local machine:

Fits
/fits/install/path/fits-0.6.1/fits.sh -i /current/working/directory/image.tif
OpenJPEG 2.0 opj_compress -i /current/working/directory/image.tif -o /current/working/directory/image.tif.jp2

opj_decompress -i /current/working/directory/image.tif.jp2 -o /current/working/directory/image.tif.jp2.tif
Jpylyzer jpylyzer /current/working/directory/image.tif.jp2
ImageMagick imgcmp -f /current/working/directory/image.tif -F /current/working/directory/image.tif.jp2.tif -m equal

Using Taverna, follow the steps in the table below to create the TIF to JP2 file format migration workflow with quality assurance.

The following format highlighting rules apply:

  • Workflow services are bold and black.
  • Workflow input ports of services and workflow are bold and red.
  • Workflow output ports of services and workflow are bold and green.
Step Description
Workflow Diagram
Download Workflow
1
First, we create a workflow which takes a textfile with absolute image file paths as input. The workflow reads all absolute paths contained in the text file into a list.
Attention: White spaces in paths and file names might cause troubles, so please avoid them!
  1. Create a workflow input port 'inputUrl' with a default value pointing to a text file (e.g. file:///current/working/directory/tiffileslist.txt) with absolute paths to some TIF image files:
    Absolute image paths text file
  2. Drag and drop a 'readFile' local service (Available services/Local services/io) to the workflow panel and connect the 'inputUrl' input port to the 'fileurl' input port of the readFile local service.
  3. Create a constant value (Insert/Text constant) named 'regex' with line break (\n) as value.
    Note for windows users: Windows uses \r\n for line breaks.
  4. Create a Beanshell named 'Text2List' (Available Services/Service templates/Beanshell) with the input ports 'string' and 'regex' and the output port 'split' which reads the text file and returns a list of file paths:
    Beanshell Code

    Note: BeanShell is a Java-like scripting language which runs in the Java Runtime Environment (JRE) and uses Java syntax.

  5. Connect the value of the 'regex' text constant to the 'regex' input port of the 'Text2List' Beanshell and the 'filecontents' output port output port of the 'readFile' service with the 'string' input port of the 'Text2List' Beanshell.
  6. Finally, create the output port 'out' and connect the 'split' output port with it.
FFFF-Workflows-1.t2flow
2
Before starting the actual migration, it is checked if the TIF input images are valid file format instances using Fits.
  1. Create a tool service (Available Services/Service templates/Tool) named 'fitsValidation' with the string replacement input port name 'tiffimagepath' and the following code and adapt the path to your Fits installation.
    Replacement variables are enclosed by two % characters, the variable's name must coincide with an input port name, here 'tiffimagepath' corresponds to the replacement variable %%tiffimagepath%%: 
    Bash script
    Note: Java 1.6 is required to run Fits.
    Note for windows users: Equivalent windows batch code required.
  2. Connect the 'STDOUT' output port of the 'fitsValidation' tool service with the 'out' workflow output port.
  3. Run the workflow.

FFFF-Workflows-2.t2flow
3
In this workflow we add an XPath service (Available Services/Service templates/XPath Service) to extract the validity information from the XML-based Fits validation report.
  1. Create an XPath service (Available Services/Service templates/XPath Service) named 'XPathJhove2' (Fits is using JHove2 under the hood)
  2. In the 'XPathJhove2' paste a sample Fits output XML (or load an XML file), select the fits/filestatus/valid node, and generate an XPath expression so that you get the expression /default:fits/default:filestatus/default:valid//text() and 'true' in the 'Result as text' field (in case of a valid file).
  3. Connect the 'split' output port of the 'Text2List' Beanshell with the 'tiffimage' input port of the 'fitsValidation' tool service.
    Note: Connecting a list output port with a single value input port means that Taverna will automatically process all the list values in the receiving service in a loop.
  4. Add a Flatten list service (Available Services/Local Services/list) named 'FlattenJhove2List' and connect the 'nodeList' output port of the 'XPathJhove2' service to the 'inputlist' input port of the 'FlattenJhove2List' service.
  5. Connect the 'outputlist' output port of the 'FlattenJhove2List' service with the 'out' workflow output port.
  6. Run the workflow.

FFFF-Workflows-3.t2flow
4
In this workflow we add a service which creates a temporary directory where the migrated image files and some temporary tool outputs are stored.
If the images are valid TIF images, they are migrated to the JPEG2000 (JP2) image file format using OpenJPEG 2.0.
  1. Add a tool service named 'createtmpdir' with no input port and the following code:
    Bash script

    Note for windows users: Equivalent windows batch code required.

  2. Create a tool service named 'opj_compress' with the input ports 'isvalidtif', 'tifinfilepath', and 'tmpdir' and the following code:
    Bash script

    Note for windows users: Equivalent windows batch code required.

  3. The 'opj_compress' tool service has 3 input ports of different arity. 'isvalidtif and 'tifinfilepath' are list values which contain the same number of elements and 'tmpdir' is a single value. It is therefore required to define the list handling for this component by selecting opj_compress and defining the list handling in the Details/List handling tab: crossproduct(tmpdir, dotproduct(tifinfilepath, isvalidtif)). More on Taverna's list handling can be found here.
  4. Connect the 'STDOUT' output port of the 'createtmpdir' tool service with the 'tmpdir' input port of the 'opj_compress' tool service, and connect the 'outputlist' output port of the 'FlattenJhove2List' service with the 'tifinfilepath' input port of the 'opj_compress' service.
  5. Connect the 'STDOUT' output port of the 'opj_compress' tool service with the 'out' workflow output port.
  6. Run the workflow.




FFFF-Workflows-4.t2flow
5
In this workflow we add the validation of the migrated JP2 file.
  1. Create a tool service named 'jpylyzerValidation' with the input port 'inFileAbsPath' and the following code:
    Bash script

    Note for windows users: Equivalent windows batch code required.

  2. Connect the 'STDOUT' output port of the 'jpylyzerValidation' tool service with the 'out' output port.
  3. Run the workflow.
FFFF-Workflows-5.t2flow
6
In this workflow we add an XPath service (XPathJpylyzer) to extract the validity information from the XML-based Jpylyzer validation report.
  1. Create an XPath service (Available Services/Service templates/XPath Service) named 'XPathJpylyzer'
  2. Connect the 'STDOUT' output port of the 'jpylyzerValidation' tool service with the 'xml_text' input port of the 'XPathJpylyzer' service.
  3. Add a Flatten list service (Available Services/Local Services/list) named 'FlattenJpylyzerList' and connect the 'nodeList' output port of the 'XPathJpylyzer' service to the 'inputlist' input port of the 'FlattenJpylyzerList' service.
  4. Connect the 'outputlist' output port of the 'FlattenJpylyzerList' service with the 'out' workflow output port.
  5. Run the workflow.

FFFF-Workflows-6.t2flow
7
In this workflow, the migrated JP2 image is converted back to TIF in order to be able to check (will be done in the next workflow step 8) if the original file can be restored.
  1. Create a tool service named 'opj_decompress' with the input ports 'isvalidjp2', 'jp2infilepath', and 'tmpdir' and the following code:
    Bash script

    Attention: The boolean value 'True' checked for the input port isvalidjp2 must be verified case-sensitive, it is lower case in the fits output and starts with an upper case character in the Jpylyzer output!

  2. The opj_decompress tool service has 3 input ports of different arity. 'isvalidjp2' and 'jp2infilepath' are list values which contain the same number of elements and 'tmpdir' is a single value. It is therefore required to define the list handling for this component by selecting opj_compress and defining the list handling in the Details/List handling tab: crossproduct(tmpdir, dotproduct(jp2infilepath, isvalidjp2)). More on Taverna's list handling can be found here.
  3. Connect the 'STDOUT' output port of the 'opj_decompress' tool service with the 'out' workflow output port.
  4. Run the workflow.

FFFF-Workflows-7.t2flow
8
Finally, we verify if the migrated JP2 images are valid surrogates of the original TIF images by comparing whether original and restored images are identical.
  1. Create a tool service named 'imgcmp' with the input ports 'origtifinfilepath' and 'targettifinfilepath' and the following code:
    Bash script
  2. Connect the 'STDOUT' output port of the 'imgcmp' tool service with the 'out' workflow output port.
  3. Change the list handling of the 'imgcmp' tool service from 'cross product' to 'dot product' because we want to compare each original image with the corresponding migrated image and not each original image with every migrated image.
  4. Run the workflow.

FFFF-Workflows-8.t2flow
Labels:
scape scape Delete
migration migration Delete
jpeg2000 jpeg2000 Delete
taverna taverna Delete
workflow workflow Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.