ImageReader
NAME | image |
WHAT | The ImageReader component is used
to serve binary image data in a sitemap pipeline.
|
TYPE | Reader, Sitemap Component |
BLOCK | Scratchpad |
CLASS | org.apache.cocoon.reading.ImageReader |
SINCE | Cocoon 2.1 |
CACHEABLE | yes |
Description
The ImageReader component is used to serve binary image data
in a sitemap pipeline.
Usage
Sitemap pipeline examples
The ImageReader is used in a pipline as shown in the
pipeline snippet below:
| | |
|
<map:match pattern="*.png">
<map:read type="image"
src="resources/styles/{1}.css"
mime-type="image/jpeg">
<!-- optional setup parameters -->
</map:read>
</map:match>
| |
| | |
It is important to specify the mime-type attribute,
as it is passed to the browser as the Content-Type
in the HTTP response.
Sitemap component configuration example
A ImageReader is declared in the sitemap readers
section, as shown in the sitemap readers snippet below:
| | |
|
<map:readers default="resource">
...
<map:reader name="image"
src="org.apache.cocoon.reading.ImageReader"
logger="sitemap.reader.image"
pool-max="32" pool-min="1" pool-grow="4"/>
<!-- optional reader configuration -->
...
</map:readers>
...
| |
| | |
Configuration
The ImageReader has no configuration options.
Sitemap Parameters
The ImageReader accepts following sitemap
setup parameters
Parametername | Type | Comment |
expire-time | Time in milliseconds |
This parameter is optional. When specified it determines how long
in miliseconds the resources can be cached by any proxy or browser
between Cocoon2 and the requesting visitor.
|
width | Image width in pixels |
This parameter is optional. When specified it determines the width
of the binary image.
If no height parameter is specified the ascpect ratio
of the image is kept.
|
height | Image height in pixels |
This parameter is optional. When specified it determines the width
of the binary image.
If no width parameter is specified the ascpect ratio
of the image is kept.
|
The following pipeline snippet
uses the ImageReader for serving images
having an expiration time of 1 day (ie. 24 * 60 * 60 * 1000 ms = 86400000 ms),
and scaling images to width 300 pixels.
| | |
|
<map:match pattern="*.jpg">
<map:reader type="image"
<map:parameter name="expire-time" value="86400000"/>
<map:parameter name="width" value="300"/>
</map:reader>
...
| |
| | |
Effect on Object Model and Sitemap Parameters
The ImageReader does not change object model and sitemap parameters.
It only access parameter values for reading.
Bugs/Caveats
The ImageReader is able to transform
JPEG images only.
Nevertheless it can serve any image data in a non transforming mode.
The ImageReader does support HTTP ranges, thus
it sets Accept-Ranges to bytes .
The java Bug Id 4502892 (which is found in *all* JVM implementations from
1.2.x and 1.3.x on all OS!), ImageReader must buffer
the JPEG generation to avoid that connection resetting by the peer
(user pressing the stop button, for example) crashes the entire JVM.
History
12-25-02: Initial document creation by Bernhard Huber
Copyright
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
See also
|