Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Image length when using scalefit #581

Open
fsteimke opened this issue Jan 28, 2025 · 0 comments
Open

Invalid Image length when using scalefit #581

fsteimke opened this issue Jan 28, 2025 · 0 comments

Comments

@fsteimke
Copy link
Contributor

fsteimke commented Jan 28, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant