Wednesday, November 4, 2009

Resizing EPS files

Sometimes an eps file from my favourite plotting device (gnuplot, matlab, mathematica) is just to big for the arxiv and a png or jpeg file produced directly from the plotting device is just useless; in my experience the lettering produced like this pixelize most of the time.

I have tried different methods to produce nice and small figure files. So far, when an image files is just too big even for a journal submission I do the following,

  1. Arxiv, convert the nice looking eps into a png and use the png for submission. Pdflatex can handle png files.

    gs -r300 -dEPSCrop -dTextAlphaBits=4 -sDEVICE=png16m -sOutputFile=output.png -dBatch -dNOPAUSE input.eps

  2. Journal, try to rezise the nice looking eps. I take the output of the aforementioned code

    convert -quality=100 input.png output.jpg
    convert input.jpg esp2:output.eps

These are modifications on the solutions posted by Luke at Terminally-Incoherent, the Four Forces, the gs manual and the imagemagick manual. It seems png -> eps2 fails that's why png->eps3 or jpg->eps2 has to be used, it seems quite an old problem. I prefer jpg->eps2 as it produces smaller files than png->eps3 does.

If you have a better solution I'm eager to read about that.

NOTE: I found almost the same solution with a great discussion on the topic here.

UPDATE (March 23rd, 2010): I've started using GIMP to parse EPS files into smaller EPS files and PNG files, it seems the best alternative so far without the hassle of keeping gs and convert commands in my memory.

Saturday, October 17, 2009

How to embed a blog into a personal web page.

I've created a blog in blogger and now I want to embed it to my personal web page. After asking the intertubes about this question I decided to go with the iframe solution, although it is only xhtml-transitional and not supported in strict DTD. Here is my little how to.

1) (Optional) If you want, you can take out the navigation bar from blogger. Go to Layout>Edit HTML>Edit Template and add the following line of code.


#navbar-iframe {

   display: none;

}


2) Create an iframe at your personal web page to load the blog into it. The following code will do the trick,


<iframe id="myiframe" SRC="http://myblog.blogspot.com/" width="750px" height="400px" marginheight="0" frameborder="0" />



Just substitute the "myblog.blogspot.com" with the URL of your blog.

3) As you will notice, there will be a not so nice looking scrollbar on the right hand side of the iframe. In order to get rid of this scroll bar, John McKerrel has dealt with this and gives all the details on his blog here. Basically, to solve the problem you have to go to Layout>Edit HTML>Edit Template and include the following lines before the closing head tag,


<style type='text/css'>

     #inneriframe { position : absolute; top : 0px; left : 0px; visibility: hidden; }

</style>

<script type='text/javascript'>

      function test2() {

        var iframe = document.getElementById( 'inneriframe' );

        var wrapper = document.getElementById( 'wrapper' );

        var height = Math.max( document.body.offsetHeight, document.body.scrollHeight );

        iframe.src = 'http://www.mywebpage.org/iframetest-resize1.html?height='+height;

      }      

</script>


As you can see, you need to copy Jhon's file iframetest-resize1.html somewhere in your personal web page domain. This way your blog will be able to tell your page its height and your page will be able to resize the iframe accordingly.

Finally, add to your blog template the following line anywhere inside the body of the blog,


   <iframe height='10' id='inneriframe' width='10'/>


I put it just before the closing body tag.


I hope this is helpful for all those who are just looking for a simple solution without thinking on fulfilling strict DTD.