Alexander Peshkov
Scaling images using scale-to-fit
Scales down images using scale-to-fit value
of content-width
and content-height traits.
2003-07-07
Scaling images using scale-to-fit
Both content-width
and content-height
properties can have
a special value scale-to-fit
which allows you to automatically scale down
images which are wider or taller then necessary.
XSL FO Recommendation, Chapter 7.14.2 "content-height"
XSL FO Recommendation, Chapter 7.14.3 "content-width"
In the table below every row has height="300px"
and every image cell has width="300px"
.
Example of fo:external-graphic
element used to insert images cited below:
<fo:external-graphic content-width="scale-to-fit"
content-height="100%"
width="100%"
scaling="uniform"/>
src="url(Images/bud400x300.jpg)"
Thus we want all wider images to scale down while small images must stay intact.
In the table below only images in first and third rows must be scaled.
Table cells in the right column contain intrinsic information about images placed in the left column.
Note that scaling works both for raster and SVG images.
Bud of an alder-tree [JPEG].
This image intrinsic width is 400 pixels and it's height is 300 pixels.
Butterfly [JPEG].
This image intrinsic width is 160 pixels and it's height is 120 pixels.
Phrase analysis [SVG].
This image intrinsic width is 400 pixels and it's height is 250 pixels.
Temperatures graphic [SVG].
This image intrinsic width is 150 pixels and it's height is 150 pixels.