<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">I have been (and am) reading what I can find on performance generally, but I have a specific case and wonder if people might have suggestions.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am writing an application to run on a Raspberry Pi 3, which renders PDF's. These PDF's 99% of the time contain multiple pages each of which has exactly one image. I create these, so I have some control over the type of image (I say
"some" as I use Photoshop's Multi-page presentation automation and not completely sure what it does under the covers).
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I realize I can pull images out separately, but I hesitate to do that because 1% (+/-) of the time there may be other things - annotations, or the source of the PDF may be elsewhere and I have no control. But the vast majority have zero
text or other artifacts other than the image.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">At present to render a page at about 1200x900 takes almost 2 seconds on the Pi. That's somewhere between impressive given it is a Pi, and too slow.
<span style="font-family:Wingdings">J</span> <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Almost all the time is in the render call, specifically:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">new QImage(popplerPage->renderToImage(desiredScale, desiredScale)<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">I've instrumented the QT program and very little is taken in putting up the image on the screen or other manipulation there.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My question is whether there are any sweet spots in the code you may suggest? Anything I can do to the input image (color depth, format, etc.) that might speed the render, anything in settings in poppler? I've tried Arthur and Splash
and while the former is slightly faster it is not quite as good. I am not using any rendering hints at present. As I want to cache the image itself, Arthur's ability to render into a painter does not seem to help much (or maybe I'm missing how to best use
it). <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I've already adjusted the resolution of the scanned image to be as low as I can and still get crisp images at the final maximum size<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The input image is indexed color (which is actually grey) as it comes from my scanner. I could convert to a real grey scale, or to color. I tried bitmap but it introduces some artifacts, though I may be able to manage a good pattern or
setting. Maybe. Will it make much difference? Or poppler going to do the same work regardless?
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am using the distro library on Ubuntu Mate for Pi, with CPP wrapper.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any advice welcomed. I am doing experiments, but there are so many variables, am hoping that people more knowledgeable of the code might know more fertile ground than random combinations.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">On a mostly unrelated note -- any recommendations of a simple example of using QT bindings with poppler to create and save annotations? That's next on my agenda.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks, <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Linwood<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>