Convert PostScript to EPSI with ps2epsi and verify the result
You will turn a PostScript file into an Encapsulated PostScript Interchange (EPSI) file, then check that the output exists and contains an EPS bounding box. Allow about ten minutes for a first conversion. You need a readable .ps, .cps, .eps or .epsf file and the ghostscript package. The examples use the installed Ghostscript 10.02.1 command on this machine.
The route
Jump straight to the step you need, or tick off Done means at the end.
Checkpoint
This tool reads the source and writes a new file. It does not need root privileges when both files are in a directory you can access.
1. Check the installed command
Confirm which executable your shell will run and record its Ghostscript version:
$ command -v ps2epsi
/usr/bin/ps2epsi
$ gs --version
10.02.1
The manual describes ps2epsi as a wrapper around gs. It produces EPSI, a PostScript file with a bitmap preview represented by comments near the start of the file. The preview is intended for applications that understand EPSI; the final PostScript remains the printable part of the result.
2. Convert with an explicit output name
Give the input first and a new output path second. Replace the placeholders with paths from your own working directory:
$ ps2epsi /path/to/diagram.ps /path/to/diagram.epsi
$ file /path/to/diagram.epsi
/path/to/diagram.epsi: PostScript document text conforming DSC level 3.0, type EPS
The output name is not a request to resize or redraw the source. It is the file that receives the generated EPSI. The installed wrapper passes the source to Ghostscript's eps2write device and calculates a bounding box as part of that process.
Checkpoint
Do not stop at a quiet shell prompt. Confirm that the output exists, is non-empty, and is identified as EPS or PostScript:
$ test -s /path/to/diagram.epsi && echo 'EPSI output is non-empty'
EPSI output is non-empty
$ sed -n '1,12p' /path/to/diagram.epsi
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: ...
The exact creator, date and bounding-box values depend on the input. A normal result starts with an EPSF marker and includes %%BoundingBox. Do not compare the date or the precise coordinates with a sample from another file.
3. Let ps2epsi choose the filename
With only the input argument, the Unix wrapper derives the destination in the current directory. For the standard extensions .ps, .cps, .eps and .epsf, it replaces that extension with .epsi:
$ cd /path/to/work
$ ps2epsi diagram.ps
$ test -s diagram.epsi && file diagram.epsi
diagram.epsi: PostScript document text conforming DSC level 3.0, type EPS
For another input name, such as poster.source, the installed script uses the complete basename and appends .epsi. That makes an output such as poster.source.epsi. If the derived name already exists, the command can overwrite it. Use an explicit, unused destination when the existing file matters.
4. Protect an existing output
Shell redirection is not involved here, but the wrapper still opens the named output for writing. Preserve a useful result before replacing it, or write to a temporary file and move it only after verification:
$ cp --preserve=all /path/to/diagram.epsi /path/to/diagram.epsi.bak
$ ps2epsi /path/to/diagram.ps /path/to/diagram.epsi.new
$ test -s /path/to/diagram.epsi.new
$ grep -m1 '^%%BoundingBox:' /path/to/diagram.epsi.new
%%BoundingBox: 0 0 612 792
$ mv /path/to/diagram.epsi.new /path/to/diagram.epsi
The final mv changes the destination only after the new file has passed the checks. If conversion fails, leave the original in place and inspect the diagnostic. Remove the backup only after you have opened or otherwise validated the replacement; deleting it is irreversible.
5. Treat diagnostics and exit status carefully
A common distraction is to treat a returned shell prompt as proof of success. The installed /usr/bin/ps2epsi script invokes Ghostscript and then exits with status 0 after that invocation, even when Ghostscript has printed an error. Check both standard error and the output file:
$ ps2epsi /path/to/source.ps /path/to/result.epsi
Error: /undefinedfilename in --file--
GPL Ghostscript 10.02.1: Unrecoverable error, exit code 1
$ test -s /path/to/result.epsi && grep -m1 '^%%BoundingBox:' /path/to/result.epsi
The last check should produce a bounding-box line. If it produces nothing, the conversion did not leave a usable result. A missing source, unsupported PostScript construct or source-specific Ghostscript error can prevent a correct EPSI file. Keep the original source untouched while investigating.
Do not assume that a bounding box proves visual correctness. Open the EPSI in the target word processor or publishing application, or render it with a separate trusted PostScript tool. The manual explicitly limits the guarantee: not every PostScript file can be encapsulated successfully because EPS has content restrictions.
6. Avoid unnecessary privilege and unsafe inputs
Run the conversion as your normal user. Use sudo only if the operating system already requires elevated access to read the source directory or write the destination, and prefer copying the file into a user-owned working directory when policy permits. The command passes the input path to Ghostscript with its installed file-access setting, so use paths you trust and do not process untrusted PostScript merely to preview it.
If the command prints usage text, it received neither one nor two arguments. The Unix form is ps2epsi infile.ps [outfile.epsi]. The manual also lists a DOS batch form using the .epi extension; that is not the normal Linux invocation.
Done means
ps2epsiresolves to the expected Ghostscript installation.- The source remains unchanged and the destination is a new or deliberately replaced file.
fileidentifies the result as EPS or PostScript, and%%BoundingBox:is present.- Ghostscript diagnostics were checked instead of trusting a returned prompt or wrapper status alone.
- The EPSI opens correctly in the application that will consume it.