cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Dolg <>
Subject [C3] Imaging Module
Date Wed, 14 Jan 2009 21:09:03 GMT

I planned to come up with an Imaging Module for quite some time now.
There were several situations in some of the projects I worked on where 
such a module would have been handy IMO.
I also thought this might serve as another example of how the Pipeline 
API could be used.

I did not invest much time (only a couple of hours this afternoon) and 
I'm actually not very versatile in using the Imaging API and/or Java2D.
So please don't blame me when the implementation of the transformations 
is not ideal or not really fast.
(Actually if someone know how to implement some or all of those 
manipulations better, I'd love to hear about that).
The transformers still miss alot of configuration possiblities (most of 
it is simply hardwired) and are not really suited to be used in the 
Sitemap, yet.
But I intend to continue working on this...

So far I created the following transformers:
* CropImageTransformer
    Crops the image to an area of the configured size. The area is 
centered on the image

* MaxSizeImageTransformer
    Reduces the size of the image so that it fits inside the given 
dimensions. The aspect ratio of the image is maintained. If the image 
already fits inside the given bound it will remain unchanged.

    Rotates the whole image by a given amount. Any value is possible.

    Scales the image by a given factor, maininting the aspect ratio.

    Write a configurable text centered on the image. Color and 
transparancy of the text is configurable.

Additionally there is an ImageGenerator and an ImageSerializer.
Both ImageGenerator and ImageSerializer use the Imaging API of Java. So 
by default the image formats JPG, PNG, GIF and BMP are supported (IIRC).
Additional formats may be supported by registering them with the Imaging 

All the components mentioned above a fully compatible to each other - 
and not compatible to any other Cocoon 3 components currently available 
- and the transformers can be combined in every way.
The basic rules of the PipelineAPI still apply of course (Generator -> 
Transformer* -> Serializer)

I have provided a unit test that uses several pipelines using all 

Attached you can find the patch for the code and a sample image (in case 
you have none handy).
The generator uses the URL mechanism already implemented in other 
generators in Cocoon 3, so images can also be loaded directly from a web 
site or some other location.


View raw message