Image scaling driving me crazy. Can this be scripted?
Philo Calhoun <[email protected]> Tue, 30 Mar 2021 12:16:51 -0700
| Newsgroups | gmane.text.docbook.apps |
|---|---|
| Message-ID | <[email protected]> |
I tried the various suggestions given and still have to do extensive editing of OxygenXML docbook to ePub conversions if image scaling is used.
To demonstrate the issue, here is a simple docbook XML file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://docbook.org/xml/5.1/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://docbook.org/xml/5.1/sch/docbook.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.1">
<info>
<title>Figure Scaling</title>
<author>
<personname>John Doe</personname>
</author>
<author>
<orgname>ABC Publishing</orgname>
</author>
</info>
<sect1>
<title>The problem</title>
<para>Image scaled 25%:</para>
<para><inlinemediaobject>
<imageobject>
<imagedata
fileref="../../../../../Applications/Oxygen%20XML%20Editor/samples/personal-images/michelle.taylor.jpg" width="25%"
/>
</imageobject>
</inlinemediaobject></para>
<para>Image scaled 50%:</para>
<para><inlinemediaobject>
<imageobject>
<imagedata
fileref="../../../../../Applications/Oxygen%20XML%20Editor/samples/personal-images/michelle.taylor.jpg" width="50%"
/>
</imageobject>
</inlinemediaobject></para>
<para>Image scaled 75%:</para>
<para><inlinemediaobject>
<imageobject>
<imagedata
fileref="../../../../../Applications/Oxygen%20XML%20Editor/samples/personal-images/michelle.taylor.jpg" width="75%"
/>
</imageobject>
</inlinemediaobject></para>
</sect1>
</article>
__________________
When this is exported, it looks fine on Apple Books but generates errors on Epubchecker, since width designation is not allowed in the ePub except as a image.style
The OxygenXML generated ebook looks like this:
<?xml version="1.0" encoding="utf-8"?><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops"
xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:ssml="http://www.w3.org/2001/10/synthesis"
xmlns:svg="http://www.w3.org/2000/svg"><head><title>Figure Scaling</title>
<link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.2"/></head>
<body><header/>
<section class="article" title="Figure Scaling" id="d0e3"><div class="titlepage"><div><div>
<h1 class="title">Figure Scaling</h1></div><div><div class="author">
<h3 class="author">John Doe</h3></div></div><div><div class="author">
<h3 class="author"><span class="orgname">ABC Publishing</span></h3></div></div></div><hr/></div>
<section class="sect1" title="The problem" epub:type="subchapter" id="d0e13"><div class="titlepage"><div><div>
<h2 class="title" style="clear: both">The problem</h2></div></div></div>
<p>Image scaled 25%:</p>
<p><span class="inlinemediaobject"><img src="images/michelle.taylor_987157347.jpg" width="25%"/></span></p>
<p>Image scaled 50%:</p>
<p><span class="inlinemediaobject"><img src="images/michelle.taylor_987157347.jpg" width="50%"/></span></p>
<p>Image scaled 75%:</p><p><span class="inlinemediaobject"><img src="images/michelle.taylor_987157347.jpg" width="75%"/></span></p>
</section>
</section>
<footer/>
</body>
</html>
______________________
This generates errors for each width designation:
E [EPUBCHeck 4.2.4] Error while parsing file: value of attribute “width” is invalid; must be an integer
________________________
To fix this I need to add image styles to the CSS:
img.A{width: 25%;}
img.B{width: 50%;}
img.B{width: 75%;}
I can correct the code, but it requires manually changing each image entry, which is a real issue if one has 100 or so images. The corrected ePub code looks like this:
<?xml version="1.0" encoding="utf-8"?><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:ssml="http://www.w3.org/2001/10/synthesis"
xmlns:svg="http://www.w3.org/2000/svg">
<head>
<title>Figure Scaling</title>
<link rel="stylesheet" type="text/css" href="docbook-epub.css"/><meta name="generator" content="DocBook XSL Stylesheets V1.79.2"/></head><body><header/>
<section class="article" title="Figure Scaling" id="d0e3"><div class="titlepage"><div><div>
<h1 class="title">Figure Scaling</h1></div><div><div class="author">
<h3 class="author">John Doe</h3></div></div><div><div class="author">
<h3 class="author"><span class="orgname">ABC Publishing</span></h3></div></div></div><hr/></div>
<section class="sect1" title="The problem" epub:type="subchapter" id="d0e13"><div class="titlepage"><div><div>
<h2 class="title" style="clear: both">The problem</h2></div></div></div>
<p>Image scaled 25%:</p>
<p><span class="inlinemediaobject"><img class="A" src="images/michelle.taylor_987157347.jpg"/></span></p>
<p>Image scaled 50%:</p>
<p><span class="inlinemediaobject"><img class="B" src="images/michelle.taylor_987157347.jpg"/></span></p>
<p>Image scaled 75%:</p>
<p><span class="inlinemediaobject"><img class="C" src="images/michelle.taylor_987157347.jpg"/></span></p>
</section>
</section>
<footer/>
</body>
</html>
Is there a way of scripting this?
smime.p7s
(application/pkcs7-signature, 1.3 KB) - not displayed