Hello everybody again,<div><br></div><div>so today I started working with charts as images rendered by PHP. I wanted to ask what do you guys think about encoding images in the HTML using base64 like this:</div><div><span class="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: rgb(51, 51, 51); line-height: 17px; "><pre class="code html" style="font-size: 11px; padding-left: 1em; padding-top: 0.5em; padding-bottom: 0.5em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(153, 153, 153); border-right-color: rgb(153, 153, 153); border-bottom-color: rgb(153, 153, 153); border-left-color: rgb(153, 153, 153); background-color: rgb(239, 239, 239); color: rgb(51, 153, 0); overflow-x: auto; overflow-y: auto; ">

<imgsrc="data:image/gif;base64,R0lGODlhUAA....j5+g4JADs=" /></pre></span></div><div><br></div><div>I thought about these pros and cons.</div><div><br></div><div>First of all pros:</div><div><ul><li>no additional request to fetch the image from server.</li>

<li>image generation script can return multiple values. For example the image itself and the image map (later used for tooltips) can be returned.</li></ul><div>Cons</div></div><div><ul><li>some overhead is introduced when encoding binary data into base64 format. On my experiment 46kB image was encoded into 60kB. (~30% overhead).</li>

<li>Script execution is halted while the image generation is in progress. This introduces slower response times for pages, which show charts. (If the image is loaded in a "normal" way, in many browsers page is started being rendered before images are received from the server). This problem can be solved by writing rendered charts to disk. However almost all planned charts are going to display dynamic data (query results, profiling data, query statistics).</li>

<li>Generated images can not be linked to externally. (hardly a problem for PMA)</li></ul><div>The only real problem that I see is the longer script execution times. However all the charts will be generated only on user request, so we can assume that the user knows that the chart is coming soon and expects to wait a little bit more.</div>

</div><div><br></div><div>Both techniques are easy to implement. I have already images as base64 strings working. Changing this would be a matter of minutes.</div><div><br></div><div>What do you think?</div><div><br></div>

<div>Martynas</div>