More hints on postscript are below.
The arXiv has good help on figure sizes and on the easiest way to do bitmapping.
For photos with colours use jpg format with uses a lossy compression method giving small files but acceptable image quality.
For images with sharp edges or fine detail use png or gif as both have lossless compression options, and will work with colour, grayscale or black and white images.
Both jpg JPEG and gif files can be wrapped into postscript files and the compression can be kept. ImageMagick and jpeg2ps can do this for you.
On Windows to get a copy of the screen press alt+Print Screen key. Pressing cntrl+alt+Print Screen gives the active Window.
My preferred bitmap file viewer on Windows is Irfanview which also lets you do some basic manipulations. It does not let you save as postscript however. Many other programmes are around that will output as postscript but to date all I have found many need to be compiled. Irfanview does allow you to crop a picture (draw a box with the mouse then select Edit-> Crop), to resize a picture (Image -> resize resample) and save in png, jpeg, gif etc. The information option gives you all sort of details on the file, such as the dpi (dots per inch density of bitmap images) used.
For instance, one can look at the Image - resize/resample menu option and select 72dpi and a desired size (probably with Preserve Aspect Ratio selected if one wants to produce an image for a web page. Likewise dragging the cursor with the left mouse key held draws a white box and then the edit - crop selection selects a part of the image. Note the crop box size in pixels is shown at the top helping you to select an exact square if required.
To produce postscript from a bitmap I use the jpeg2ps command line converter. Use the -h option to ensure there are no percentage symbols to confuse things so type
jpeg2ps -h input.jpg > output.eps
To convert all the files in one directory, say from all eps files to png (png is good for images with sharp edges, jpeg is good for photos) you move to the directory with the a copy of the files (to be on the safe side) and the you type
mogrify -format png *.epsHere is an example where I resize the tiff to get the esp bounding box to work out
mogrify -format eps -resize 50% aegeain34.tif
Another example of the usefulness of ImageMagik is in producing tiff files (or other bitmap formats) in a standard resolution for a publisher. Starting with the vector files in eps format (produced from other packages like OpenOffice Draw, pajek, etc.) I converted them simply to 600dpi density as follows:
convert fig2.eps -display 600x600 fig2.tiff
convert -density 600 input.eps -flatten output.tiffNote that with pdf files the density option must come before teh input file as there is no density specified in the input file. A useful example of a ImageMagik Windows batch file is given below. Note that I did not get this to work so used GIMP instead.
Finally here is how I converted a pdf file to a bitmap file
convert -density 1200 -trim original.pdf -resize 3600 -quality 100 bitmapversion.jpgNote that the resize usually requires a percentage scaling or a width and height in pixels.
Here is how we can convert a file to be 2cm wide, same aspect ratio and at 96dpi (PC web format)
convert inputfile.png -resample 96x96 -resize 192 outputfile.png
Pixels in PNG files (and others) have the option to be transparent to a specified degree. For instance when saving figures from Microsoft office (e.g. right click on a diagram or group of drawing objects and the option is there) png files are produced which are transparent. When displaying in a browser, this can be a problem. IE treats this incorrectly, Firefox showing a black background (even when I changed the background colour in the html body command). The solution is to change the transparanecy of pixels and/or change those transparent pixels to a background colour.
I do this with ImageMagik convert command. two versions I tied were as follows:-
convert fig.png -alpha opaque fig1.png convert fig.png -alpha off fig2.png convert fig.png -background white -alpha background fig3.pngThe first two produced a grey like background in the browser. The last switched all the transparent (previous balck appearing) pixels to white.
A useful ImageMagik Windows batch file is as follows
@echo off echo Converts transparent pixels to white pixels in png files. echo Output files as *whitebakgkgnd.png in output directory. mkdir output for %%f in (*.png) do ( convert "%%f" -background white -alpha background "output\%%~nfwhitebkgnd.png" )or in a similar way
@echo off echo Converts pdf to jpg. echo Output files as *d1200.jpg in output directory. mkdir output for %%f in (*.pdf) do ( convert -density 1200 -trim "%%f" -resize 3600 -quality 100 "output\%%~nfd1200.jpg" )
For eps manipulation you need ghostscript (I found mine in C:\Program Files (x86)\gs\gs8.60\bin\gswin32.exe) and you need to add an environment variable GS_PROG with this value (to do this right click on the computer icon, system properties, advanced tab and then the Environment Variables button). I then opened the eps file in GIMP specifying the dpi as the resolution. GIMP now converts this to a pixel based image and you can save or edit it from there.
Web browsers display images by pixels so the DPI of an image is nothing more than an instruction that used when a page is printed. Screen resolutions are usually 72 (Mac) or 96dpi (PC) so preparing at 72 dpi is the defacto web standard. Irfanview and Imagemagik can do this as resample and resize options.
<head> ... <link rel="icon" type="image/png" href="http://example.com/myicon.png"> ... </head>
For problems with png (and other file types) coming out with a black background in a browser, you may have a problem with graphics file transparency so see answer above.
C:\Program Files\gs\gs8.53\libor try cygwin which emulates Unix and has these commands. Postscript Figures The best way I have found to produce figures is to use the drawing product, draw, in openoffice or libreoffice, both of whioch are open source and multiplatform. Many other drawing packages will have similar capabilities. Draw the figure then export them in a vector format such as eps so they will rescale nicely. The fonts will not rescale but sometimes hand editing can do the trick or go back to the original drawing.
There are some tricks worth knowing for draw and eps export.
<node oor:name="Filter"> <node oor:name="Graphic"> <node oor:name="Export"> <node oor:name="EPS"> <prop oor:name="ColorFormat" oor:type="xs:int"> <value>1</value> </prop> <prop oor:name="Version" oor:type="xs:int"> <value>2</value> </prop> <prop oor:name="TextMode" oor:type="xs:int"> <value>2</value> </prop> </node> </node> </node> </node>For libreoffice try changing main.xcd in the same way adding or changing the textmode section. Again look for in C:\Users\USERNAME directory using dir /s main.xcu command.
The values for TextMode are
The web site www.ps2pdf.com/convert/convert.htm is good for occasional ps to pdf conversion.
For more frequent use use ps2pdf which you should find with your Ghostscript implementation. General use is
ps2pdf [options] input.[e]ps output.pdfIn particular you should note that it is common for pdf export to assume you want a figure or sketch put on a whole page, while eps export can limit the size of the graphic file to be the actual extent of the picture. For instance in the draw component of LibreOffice/OpenOffice you select the part of the graphic you want to save (often this is the whole drawing), choose export, then select the tick box marked selection and if you select the eps option you get a boundingbox defined in the eps file which is set to be only as big as the selected parts of your drawing. If you do this in with pdf format selected for export it all seems to work but the pdf file produced is a full sized page. On the other hand export from the visone network package does produce both eps and pdf files which are only as big as the drawing. So how do we fix this. Well after much searching I found the following option is needed
ps2pdf -dEPSCrop squarewalk.eps squarewalk.pdfBasically pdf files have things like cropbox or artbox which play the role of the eps boundingbox, you just need the software which sets these pdf boxes. Note that ghostview can set the bounding box of an eps file by hand or automatically, or you even edit the eps file by hand - the boundingbox section is pretty obvious at the start of the file.
psnup -nup 2 filename.ps filenameeconomy.ps
For conversion from postscript to pdf see postscript notes above. However a useful batch file to convert many pdf files in one directory is as follows
@echo Converts %1 (pdf file) to %2 (eps file) for %%F IN (*.pdf) DO "C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\pdf2ps" -eps %%F %%~nF.eps
For occasional use try the following
PDF Toolkit is best for anything more involved. A beautiful example of a programme that does just one job but does it thoroughly and well. It works on all platforms and there is lots of documentation on PDF toolkit and many examples using PDF toolkit. PDF Toolkit can split off pages from a pdf, rotate pages, combine pages from different files, decrypt or encrypt (useful if passing your new book on) etc. etc.
Joining files: This can be done in several ways
pdftk file1.pdf file2.pdf cat output bothfiles.pdf pdftk A=file1.pdf B=file2.pdf cat A B output bothfiles.pdf pdftk *.pdf cat output allfiles.pdfNote that the "file handlers" A and B must be upper case.
Selecting parts of files: Again several variations. This example selects page 1, pages 3 and 4, and then everything from 16 to the end and puts them (in that order) in the new file.
pdftk file.pdf cat 1 3-4 16-end output lastpart.pdf pdftk A=file.pdf cat A1 A3-4 A16-end output lastpart.pdf
Rotating Pages: A common job for me is to rotate every second page by 180 degrees after scanning part of a book. Currently I have no simple way to do this other than typing in a list of every page on the command line (a script could generate this). As I do this infrequently, the quickest way is to type in the long winded command line or copy it from here. For instance
pdftk umezawabookch2.pdf cat 1D 2 3D 4 5D 6 7D 8 9D 10 11D 12 13D 14 15D 16 17D 18 19D 20 21D 22 23D output UMTch2.pdftakes the first 23 pages of umezawabookch2.pdf and rotates the odd pages by 180 degrees.
pdftk doc.pdf output doc-protected.pdf owner_pw SimplePassword allow Printing