Image PipelineImage Pipeline
Home > Books > Tutorials and Training Guides > Image Processing > Image Pipeline

Rate this page:
Really useful
Satisfactory
Not helpful
Confusing
Incorrect
Unsure
Extra comments:


Image Pipeline Tutorial

This tutorial describes how to use the Image resource model within a pipeline to create refined images.

The goal of this tutorial is to create an image from an Scalar Vector Graphic (SVG) resource and then refine it by scaling, coloring the background and reducing its palette size. In the following four steps we show the individual DPML instructions from a whole pipeline program.

Step 1

The first step is to create an Image resource. This can be done in a number of ways, we will start with an SVG resource using the imageSVG2Image service.

Code Result
<instr>
  <type>imageSVG2Image</type>
  <operand>image.svg</operand>
  <target>var:image</target>
</instr>

This instruction creates an Image resource from the SVG information in the resource image.svg and stores it in the variable var:image. We will use this variable as input to the next step thereby creating the pipeline.

Step 2

The second step scales the Image resource using the imageScale service. The image resource is obtained from the variable var:image.

Code Result
<instr>
  <type>imageScale</type>
  <operand>var:image</operand>
  <operator>
    <imageScale>
      <width>64</width>
      <height>64</height>
    </imageScale>
  </operator>
  <target>var:image</target>
</instr>

Step 3

The third step applies the color "white" to the background of the Image resource using the imageBackground service.

Code Result
<instr>
  <type>imageBackground</type>
  <operand>var:image</operand>
  <operator>
    <imageBackground>
      <red>255</red>
      <green>255</green>
      <blue>255</blue>
    </imageBackground>
  </operator>
  <target>var:image</target>
</instr>

Step 4

The fourth and final step reduces the palette size of the Image resource using the imageQuantize service and then assigns the Image resource to the response sent back to the requesting client. By sending the image resource back to the client we finish the pipeline processing and complete our task.

Code Result
<instr>
  <type>imageQuantize</type>
  <operand>var:image</operand>
  <operator>
    <imageQuantize>
      <palette>256</palette>
    </imageQuantize>
  </operator>
  <target>this:response</target>
</instr>

Summary

This tutorial illustrates how to build a pipeline in DPML by passing an image resource through a sequence of processing steps. The pipeline appraoch can be used with other resource types such as XML.

© 2003-2007, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.