sam2p
sam2p is a UNIX command line utility written in ANSI C++ that converts
many
raster (bitmap) image formats into Adobe PostScript or PDF files and several
other formats. The images
are not vectorized. sam2p gives full control to the user to specify
standards-compliance, compression, and bit depths. In some cases sam2p can
compress an image 100 times smaller than the PostScript output of many other
common image converters. sam2p provides ZIP, RLE and LZW (de)compression
filters even on Level1 devices.
Parts of this page may be obsolete.
See sam2p on GitHub
instead.
A testimonail from Grant Ingram, UK:
Anyway this is just a quick note to say thanks for writing the sam2p
utility which I am using to create EPS figures of photographs for my
thesis -- it works very well producing image sizes that are some 3% of
the ones produced by ImageMagick.
The author of sam2p recommends his program over other image image converts
because of the following reasons:
- sam2p produces much smaller output
- sam2p gives the user complete control over the data layout of the output
image, including Compression, SampleFormat and TransferEncoding
- sam2p is fast
- sam2p doesn't depend on external libraries. (But it depends on external
programs for _reading_ JPEG, TIFF and PNG files. These programs are
provided as additional, separate packages, available from download from
the sam2p web site.)
- sam2p supports the mainstream image formats of today without compromise.
sam2p has many file format fine-tuning features that are missing from
most other converter utilities. For example:
TIFF ZIP compression, TIFF LZW compression, TIFF
JPEG compression, transparent PNG files, BMP RLE-4 and RLE-8
compression etc.
- sam2p can create EPS and PDF images with transparency
- sam2p supports all levels (versions) of the PostScript language, and
output images have the smallest file size allowed by the LanguageLevel.
- PostScript ZIP, RLE and LZW compression is provided for _all_
LanguageLevels (!), even for PSL1 appeared in 1985. You can print your
ZIP-compressed images onto your ancient printer of the 1980s.
- sam2p supports all versions of PDF, and
output images have the smallest file size allowed by the version.
- output images of sam2p are always compliant to the standard selected by
the user
- output images of sam2p are real-world compatible, i.e the author has
tested them with many common image processing programs, for example:
Ghostscript, pdfTeX, xpdf, Acrobat Reader, The GIMP, ImageMagick, xv,
Acrobat Distiller, QuarkXPress, InDesign. The author has also tested
PostScript files on HP and OkiData printers.
- sam2p converts every pixel faithfully, preserving all the 24 RGB bits
intact. There is no quality or information loss unless you ask for it.
- sam2p uses only a minimal number of libraries. You don't have to install
33Mb of ballast software to use sam2p. Image libraries (libtiff etc.) are
_not_ used, the math library is not used, libstdc++ is not used, zlib is
not used.
The author of sam2p recommends his program over ImageMagick:
- sam2p produces much smaller output. A speed increase of a factor of 100 (10000%) in file
size can be achieved in extreme circumstances.
- sam2p gives the user complete control over the data layout of the output
image, including Compression, SampleFormat and TransferEncoding.
ImageMagick provides only a single -compress option, which is
often ignored or not used at full capability provided by the file format.
- sam2p is fast, often 10 times faster than ImageMagick
- sam2p doesn't depend on external libraries. You don't have to waste
effort for installing zillions of libraries (with versions possibly
incompatible with your libc or system) just to convert a GIF file to EPS.
You don't have to install 33Mb of ballast software to use sam2p.
Image libraries (libtiff etc.) are
_not_ used, the math library is not used, libstdc++ is not used, zlib is
not used.
As a contrast, ImageMagick needs liblcms, libtiff, libfreetype, libjpeg,
libpng, libwmflite, X11, libbz2, libxml2, zlib and libpthread.
- sam2p supports the mainstream image formats of today without compromise.
sam2p has many file format fine-tuning features that are missing from
most other converter utilities. For example:
TIFF ZIP compression, TIFF LZW compression, TIFF
JPEG compression, transparent PNG files, BMP RLE-4 and RLE-8
compression etc. ImageMagick lacks much of these capabilities. However,
sam2p cannot do visible transformations on the image -- use ImageMagick
to these transformations, and convert its output with sam2p.
- sam2p can create EPS and PDF images with transparency, ImageMagick
cannot.
- sam2p supports all levels (versions) of the PostScript language, and
output images have the smallest file size allowed by the LanguageLevel.
ImageMagick creates incompliant, incompatible and very large EPS files.
- PostScript ZIP, RLE and LZW compression is provided for _all_
LanguageLevels (!), even for PSL1 appeared in 1985. You can print your
ZIP-compressed images onto your ancient printer of the 1980s. ImageMagick
provides compression only for PSL2 and PSL3.
- sam2p supports all versions of PDF, and
output images have the smallest file size allowed by the version.
ImageMagick cannot even create PDF files.
- output images of sam2p are always compliant to the standard selected by
the user. ImageMagick sometimes puts the Adobes DSC comments wrong, so
the output EPS file is not suitable for embedding.
- output images of sam2p are real-world compatible, i.e the author has
tested them with many common image processing programs, for example:
Ghostscript, pdfTeX, xpdf, Acrobat Reader, The GIMP, ImageMagick, xv,
Acrobat Distiller, QuarkXPress, InDesign. The author has also tested
PostScript files on HP and OkiData printers. The subjective opinion of
the author is that images created by sam2p are generally more compatible
than those created by ImageMagick.
- sam2p converts every pixel faithfully, preserving all the 24 RGB bits
intact. There is no quality or information loss unless you ask for it.
ImageMagick sometimes downsamples a 24 bit image to a 256-color palette,
without displaying any warnings.
Long-term limitations:
- only DeviceRGB color space, with the Indexed, Gray and RGB image types
- Indexed images can have 0..256 colors
- alpha channel and transparency supported only for Indexed images: only
one color may be transparent
For more information about sam2p, see the README README (for version 0.42).
Please download the
latest sources, and read the most
recent version of the README there.
If you are new to sam2p, please read this before reading anything else.
You may contact the author of sam2p by e-mail: pts@fazekas.hu.
Downloads
Linux and Windows binaries and the C++ sources are available from
here.
Please
note that the binaries may be out-of-date. If you need the latest version,
compile the sources for yourself. You need
a GNU-compatible system (tested on Linux, Mac OS/X, Solaris, Windows MinGW),
Perl and GCC G++ to compile sam2p. (If you are a
deep wizard, you may try re-compiling under Win32 using cygwin or mingw.)
You can easily build a Debian package from these sources.
sam2p uses the cjpeg and djpeg utilities from libjpeg
(Debian package libjpeg-progs). sam2p uses the tif22pnm and
png22pnm utilities to read TIFF and PNG files; both utilities are
written by the author of sam2p -- they are available as source form
here and
here.
Win32 binaries for the dependencies are available
here.
sam2p updates are announced on Freshmeat.
An earlier version of sam2p is uploaded to CTAN.
Abstract for EuroBachoTeX 2002
Final version of my article, PDF
Presentation slides for EuroBachoTeX 2002, PDF
EuroBachoTeX 2002 home page
Inserting figures into TeX documents
by Szabó Péter <pts@fazekas.hu>
My article deals with the practical considerations of inserting sampled
figures into TeX documents. Sub-topics:
- Choosing the appropriate compression for sampled images. Software
patents. PostScript and PDF compatibility.
- Conversion of PNG, JPEG, TIFF and GIF files to PDF (for pdfTeX) and
(for dvips). sam2p, a conversion utility I've developed recently.
- Creating pixel-based figures with transparent pixels. Transparency
support in sam2p.
sam2p in the world
Richard Solcher has packaged sam2p for Win32 and added a .bat file
which automates converting from PNG and JPEG files. Get his software
PNG to EPS and JPG to EPS Converter from
here.
Mikkel Meinike-Nielsen uses sam2p for adding sampled images to
hand-written PostScript documents. See his Text with images
tutorial here.
sam2p at
Soft5000. Linux software at
Soft5000