The l2h help pages   © Leon van Dommelen 
The latest version of this document is online at eng.famu.fsu.edu or at dommelen.net.

Images and Their Formats

On this web page, the term "images" means scientic plots, photographs, pictures (except those made inside LaTeX itself), sketches, etcetera. Simply put, l2h needs images to be in eps format. This web page explains how to obtain eps images.

One exception should be noted. If you do not care whether you can make web pages from your document, then you can use noneps formats (gif, jpg, png, ...). Follow the "pdflatex" or "xelatex" example documents to do so (examples 3 through 6). (However, eps would still be superior in quality over gif or jpg for line plots and such.)

Contents
Introduction
Creating eps images from the outset
Converting images to eps format
Converting eps images to pdf format
Fixing corrupt eps files

Introduction

Obtaining eps images is no big deal. If you have an image in another mainstream format, it is normally very easy to convert it to eps. See a later section on how. And lots of software allows you to save your images in eps format in the first place. The next sections discuss how to go about it.

It should also be noted that if you want to create web pages in nonWestern European languages, or in Greek for that matter, you will need properly cropped pdf images. But the simplest way to get these is probably to create eps images and convert those to pdf. The latter is discussed separately in a later section.

(You would also use such pdf images if you already have eps images, but you want to use pdftex. You might want to use pdftex because it is the default setting of LaTeX editors like TeXstudio. But I prefer to change their settings to follow the "DVI-PS-PDF" route. Then I can simply have all my images in eps format only.)

Creating eps images from the outset

The most straightforward way to get images in eps format is to create them that way.

If you make your scientific plots using the free gnuplot program, it will produce the plots in eps format. There is a separate web page on how to do that.

Various commercial plotting software will also save to eps format. Unfortunately, my experiences with that have been miserable. I found the eps images usually to be corrupt. There is a final section with some hints to fix these up. (Short of changing software.)

If you create pictures with Adobe Photoshop or its free clone, the gimp, they will save it in eps format.

So do the line drawing program xfig and the pixel "painting" program xpaint. Unfortunately, Microsoft Paint does not the last time I looked.

If you create pictures right inside LaTeX itself, you do not have to worry about format! LaTeX has a very useful "picture" environment for this. The example documents include examples of such \begin{picture} ... \end{picture} environments. For a more complete discussion see http://en.wikibooks.org/wiki/LaTeX/Picture.

Converting images to eps format

If you take a picture of your lab crew with a digital camera, it will be in jpg format, not eps. You may also find pictures in gif, png, Windows bmp, or pdf format.

Any of these formats can be converted to eps using l2h. In the l2h folder, open the "convert" folder. In it find the "any_eps" folder. Open it. Put copies of your images in this folder. Then double-click the appropriate convert_... icon. Bingo, eps versions of the images will be made. Take them out and put them in with your document.

Note that the eps file will probably be a lot bigger file than the original, say jpg. That used to be a concern when disk space was measured in megabytes and people used plain phone lines to connect to the internet. But nowadays, who cares? If you do care, I stumbled on a weird way to reduce the size greatly. Put the big eps you get in the eps_pdf folder and convert it to pdf. Put the pdf back into the any_eps folder and convert it back to eps. Bingo, much smaller! I used this trick to reduce the disk sizes of bozo.eps and nobozo.eps by a factor 15, thus keeping the l2h download size down. (I also first used the any_smaller conversion to reduce the original jpgs I had down by a factor 2, producing a further reduction in size by a factor 3 or so.)

What if your image is in some unusual format instead of the common ones listed above? In that case, you will need to find some program that can read that format and can save it as either an eps or one of the common formats above.

Adobe Photoshop and its free clone, the gimp, can read a very large amount of formats and save them as eps. Just use "Save As" from the "File" menu item.

Any reasonable image viewer should at least be able to save as jpg or gif. These can then be converted as above.

What if you have such a weird format that none of the above works? Or if the image is too corrupt? Well, I assume you have something that will display the image. Otherwise, why keep it around in the first place? If you can display the image, (and the program does not use some special copy-protection scheme), there are "screen grabbers" that will put a copy of the entire screen, or just the selected window, in a gif, jpg, or png image. In linux, try just pressing the "Print Screen" key. In Windows, you first have to install a screen grabber, the last time I looked. But after that, the procedure is probably the same. Try to display the image at the largest possible size for best quality.

A few final words about quality in general. There are two kinds of images: pixel-based and line-based. Jpg, gif, and bmp images are pixel-based. If you take such a picture and magnify it enough, you will see little squares, the pixels. A line-based (usually called vector) image can be magnified as much as you want without ugly pixelation showing up. So, if you have a line-based image, and then you save it as a jpg, gif, or bmp, there will be a loss of quality. That is the major reason that you prefer to save scientific line-plots as eps, rather than some other format. The eps (and pdf) formats can handle both pixel-based and line-based images without loss of quality.

Always remember: never save an image as black and white. Even if the original is black and white, a pixel half inside a line and half outside it is properly represented by a shade of grey. Not as either black or white.

(You might think you could compensate for that by using an extremely high pixel-per-inch ratio. But in real life, that does not work. When resizing for display, most software does not properly average the original image over the area of the new pixel. It simply evaluates it at the center of the new pixel, maybe after a cubic spline interpolation which is often worse. The result is missing lines, wrong line thickness, wrong color, and other artifacts. Then most software hates dealing with "bits" and converts them to "bytes". In normal English that means it makes a gray scale image from the black and white one. Needless to say, that grey scale image is enormous and the program slows down to molasses or crashes.)

See also http://en.wikibooks.org/wiki/LaTeX/Importing_Graphics.

Converting eps images to pdf format

Suppose you need significant Greek, Cyrillic, or Asian characters in your document. Practically speaking that means that you want to use "UTF-8" characters and XeLaTeX. If you want to make web pages of your document, your images must be properly cropped pdf ones. How do you get them?

That is simple. Just make eps images, as explained in the other sections. Next in the l2h folder, open the "convert" folder. In it find the "eps_pdf" folder. Open it. Put copies of your eps images in this folder. Then double-click the appropriate convert_eps icon. Bingo, pdf versions of the images will be made. Take them out and put them in with your document.

Fixing corrupt eps files

Warning: A lot of commercial programs produce eps files that are corrupt. (Free software like the gimp or gnuplot does not suffer that problem. Neither does Adobe Photoshop.)

If you have a corrupt eps picture, the free "ps2eps" program can often fix them. Rename NAME.eps to NAME.ps. Then from a terminal, (which should be an icon in your document folder; if not copy it in from the l2h folder), issue the command, in Windows:

   perl "%L2HTOP%\bin\ps2eps" --loose --force --warning --ignoreBB NAME.ps
or in unix (after installing ps2eps):
   ps2eps --loose --force --warning --ignoreBB NAME.ps
This will hopefully create a proper NAME.eps file.

Another possibility to try is to read the corrupt eps into Photoshop or the gimp. Use "Save As" to save it after (and if) it loads.

 Index   Intro to LaTeX