The Lab Book Pages

An online collection of electronics information

Dr. Andrew Greensted
Last modified: 18th November 2009

Hide Menu

Valid XHTML Valid CSS
Valid RSS VIM Powered
RSS Feed Icon

This site uses Google Analytics to track visits. Privacy Statement

Page Icon


Here are some graphics related tips and tricks.

Converting PNGs to GIFs for the Web

Unfortunately not all browsers will display the alpha channels of PNGs properly (Well most of them do apart from IE). One way to get around this is to convert the images to GIFs. Not ideal, but it kinda works. This can be achieved by using the fantastic FREE graphics programme The Gimp. The steps below tell you how.

  • Open the PNG image.
  • Select all (ctrl-A).
  • Copy to clipboard (ctrl-C).
  • Create a new image, selecting a transparent background (ctrl-N).
  • Add a layer to the new image.
    Set the new layer's colour to that which the image is likely to sit on.
  • Paste the previously copied image onto the new image (ctrl-V).
  • Anchor the floating layer (ctrl-H).
  • Select background colour parts using the 'select regions by color' tool. Gimp 'Select regions by colour' Icon
  • Cut the selected parts. Should show the transparency from below (ctrl-x).
  • Save as GIF.

Converting EPSs to JPEGs

OK, so you've written your paper using latex with EPS images. Now you've got to create a presentation and the EPS files just will not import. The easiest thing to do is to convert them to JPEGs. Here's how using ghostscript. It's wrapped into a mini script.

The code below uses a resolution of 150 and a JPEG quality of 95, simply change these to suit.

# Usage: epstojpg file.eps file.jpg



# Convert eps to jpeg
$GS   -q -dNOPAUSE -dBATCH -r150 -sDEVICE=jpeg -dJPEGQ=95 \
      -dGraphicsAlphaBits=4 -dTextAlphaBits=4 \
      -sOutputFile=$OUTPUT_FILE -c "/showpage { } def " -f $BBOX $INPUT_FILE \
      -c "systemdict /showpage get exec quit"

You also need the file. I can't remember who wrote it, let me know if you want your name (honestly) credited to the file.

Converting SVGs to EPSs

Inkscape is a great tool for drawing vector based graphics. However, getting your drawings into OpenOffice can be a real pain. The easiest thing to do is convert them to an EPS, then import that. However, as Inkscape doesn't include a thumbnail into the EPS, OpenOffice only shows an empty box. Here's a few commands to make a EPS containing a preview.

> inkscape --export-area-drawing --export-eps=tmp.eps image.svg
> epstool -t6p --dpi 300 tmp.eps image.eps

These commands will create the EPS image.eps containing a TIFF preview at a resolution of 300dpi.

Book Logo