xslTNG icon indicating copy to clipboard operation
xslTNG copied to clipboard

Invalid Image length when using scalefit

Open fsteimke opened this issue 11 months ago • 0 comments

I have an image duck.png with intrinsic size 300px * 293px and the following code fragement

<informaltable >
        <tgroup cols="1">
            <colspec colnum="1" colwidth="200px"/>
            <tbody>
                <row>
                    <entry>
                        <mediaobject>
                            <imageobject>
                                <imagedata fileref="duck.png" width="100%" scalefit="1"/>
                            </imageobject>
                        </mediaobject>                        
                    </entry>
                </row>
            </tbody>
        </tgroup>
    </informaltable>

According to the imagedata section in the DocBook Reference Guide

  • The viewport area is specified by the width and depth attributes. Viewport area dimensions expressed as a percentage are a percentage of the available area. Since width=100% and the available area is a column width of 200px i would expect viewport area=200px.
  • If scaling to fit is requested, the content area is scaled until either the content width is the same as the viewport width or the content depth is the same as the viewport depth. Since scaling to fit is requested, i would expect an image width of 200px to fit in the viewport area.

However, when i try with the recent xslTNG Stylesheets, i get the error message "Invalid length (100%), returning 0 for absolute-length" and the result:

<table>
  <colgroup><col style="width: 200px" /></colgroup>
  <tbody>
     <tr>
       <td>
         <div class="mediaobject">
           <div class="media image">
             <span class="viewport-table" style="width:300px;">
               <span class="viewport-row">
                 <span class="viewport-cell">
                   <span>
                     <span class="viewport">
                       <picture class="imageobject">
                          <img src="duck.png" style="width:0px;" />

Running with $debug=image-properties shows:

file:/C:/tmp/img/src/duck.png {
  "compression-type": "Deflate",
  "bits-per-sample": 8,
  "color-type": "Indexed Color",
  "width": 300,
  "height": 293,
  "detected-mime-type": "image\/png",
  "detected-file-type-long-name": "Portable Network Graphics",
  "palette-size": 16,
  "image-width": 300,
  "image-gamma": "0,455",
  "filter-method": "Adaptive",
  "detected-file-type-name": "PNG",
  "expected-file-name-extension": "png",
  "image-height": 293,
  "interlace-method": "No Interlace"
}
{
  "contentheight": {  },
  "intrinsicwidth": { "unit":"px", "relative":0, "magnitude":300 },
  "align": null,
  "width": { "unit":"px", "relative":0, "magnitude":300 },
  "height": {  },
  "scalefit": true,
  "scale": 1,
  "intrinsicheight": { "unit":"px", "relative":0, "magnitude":293 },
  "contentwidth": null,
  "valign": null
}

While contentheight is the empty map, contentwidth is null.

test.zip

fsteimke avatar Jan 28 '25 13:01 fsteimke