RE: Scale Image to fit in width or leave unscaled

Greg Cale <[email protected]>
Newsgroups gmane.text.docbook.misc
Message-ID <1D61590A862BD34BB92C362FC7AE29A396BC1DC5@cptcsgiexch01.CSGICORP.COM>
This is one I have been battling (as a self-taught to novice Docbook user), for some time. I was trying to find a common solution for block and inline images. What worked in Docbook 4 did not necessarily work after upgrading to Docbook 5. Two mins after documenting my solution for my team, your mail came in.

I tried all sorts of combinations of attributes and xsl styling. I ended up removing nearly all the image sizing content in our customisation layer and settled on this.

For an image that is too wide, add scalefit="1" and contentwidth="100%" attributes to the <imagegedata> tag: e.g

<mediaobject>
    <imageobject>
        <imagedata fileref="images/excel_ccode.png"/>
    </imageobject>
</mediaobject>

becomes

<mediaobject>
    <imageobject>
        <imagedata scalefit="1" width="100%" fileref="images/excel_ccode.png"/>
    </imageobject>
</mediaobject>


2 For an image that is too high to fit onto a page, add scalefit="1" and contentwidth="100%" attributes to the <imagegedata> tag

For inline media objects, I just resize them in an image editor – don’t know if this is practical in your case though.

There may be other considerations depending on your build tool chain.

I am sure that experts will have a much more sophisticated customisation layer solution, but this is simple, works for me and I can easily roll out to the rest of my team. I do look forward to seeing solutions from more expert users.

I’d love to get some feedback.

Cheers
Greg


From: Paul Baumer [mailto:[email protected]]
Sent: 17 October 2016 03:29 PM
To: [email protected]
Subject: [docbook] Scale Image to fit in width or leave unscaled

Hello,

I would like to achieve the following image resizing as a general rule in my docbook5. I generate the docbook myself using python. And finally I generate pdf from the docbook.

if image width will not fit the page
   it shall be resized to fit in width
else
   image size shall be left unchanged

I am aware of the scalefit, scale, width and content width. But I am having difficulty in using a combination of those to achieve the desired logic above.

Paul
________________________________
All emails in this message string and any attachments are the confidential information of CSG Systems International, Inc. (CSG), or its affiliates and subsidiaries, and may contain privileged and/or confidential material. If you are not an intended recipient, please delete it immediately and notify the sender; unintended recipients are not authorized to read or otherwise use the information contained herein.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.