Converting Html to GIF - size ignored

322 views Asked by At

On my Ubuntu box I have installed htlm2ps in order to convert a simple html file to a GIF. My html file looks like this:

<!DOCTYPE html> 
    <html lang='en'> 
    <head>
        <meta charset="utf-8">
    </head>
    <body style="width: 120px; height: 90px" >
     <div>
         <div>Gas Prices</div>
         <div>Todays local Prices</div>
         <div>Low Price&nbsp; &nbsp; &nbsp; &nbsp; 1.29</div>
         <div>High Price&nbsp; &nbsp; &nbsp; &nbsp; 1.44</div>
     </div> 
    </body>
 </html>

and I run convert like this:

convert -size 120x90 gas.html gas.gif

However, the generated image is always of size 612x712. Same thing when converting to PNG or JPG.

Any ideas what I'm doing wrong?

1

There are 1 answers

1
emcconville On

The -size option in Imagemagick is ignored as the page size is determined by html2ps converting the HTML into PostScript. I believe you'll need to set the size of the page with CSS within the document. See @paper option under html2ps's documentation.

/* 
  Check your version of html2ps, as @paper my have been replace with @page selector
 */
@paper {
    width: 120px;
    height: 90px;
    /* Note: Units may need to be converted to `em' or `pt' */
}