Documentation
Vertical or horizontal images
How can I apply differents effects wether the image is horizontal or vertical ?
You may wish to apply a different serie of effects whether the image is vertical or horizontal.
In order to do that you simply have to express your conditionnal treatement by inserting a choose node composed of a horizontal node and a vertical node, each one containing the effects top apply in each case.
Ex:
<image name="thumb25.jpg">
<convert format="jpg"/>
<choose>
<horizontal><resize height="25"/></horizontal>
<vertical><resize width="25"/></vertical>
</choose>
<crop width="25" height="25"/>
</image>
This transformation first converts the image whatever its orientation is. Then it applies the effects inside the horizontal node if the image is horizontal, and inside the vertical node if the image is vertical.
After that the image is cropped whatever the orientation of the image is.
If you wish to apply an effect only if an image is vertical/horizontal, you simply have to add a vertical/horizontal node.
<image name="thumb25.jpg">
<vertical><resize height="25"/></vertical>
<grayscale/>
</image>
In this example, only vertical images will be resized before the grayscale.
If you want to apply an effect only if the image is twice higher than wide, you can use a ratio attribute on the <vertical> node. By default the ratio is 1 and the formula to evaluate if an image is vertical is this one :
(height/width) <= ratio
If you put a ratio of 2, that means the height is at least twice bigger than the width. The same can be done for horizontal images, the formula is :
(height/width)>= ratio