Page 1 of 1

Sam2p: commandline

Posted: Mon 25 Aug 2008, 03:40
by muggins
http://www.inf.bme.hu/~pts/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.
I use this program quite a bit, and thought I'd post it as it has a lot of functionality contained in the one small program. e.g to convert a .gif to a .png is as simple as:

Code: Select all

sam2p xxx.gif xxx.png
To convert an entire directory of .gif files, you could do:

Code: Select all

#!/bin/bash

directory=`pwd` 

for file in $directory/*.gif 
do
	filename=${file%.gif} 
	sam2p $filename.gif $filename.png
done
If you run the program without any arguments, sam2p is very modest about it's abilities. You really need to refer to the online README to see it's many options.

Posted: Wed 27 Aug 2008, 22:59
by Dingo
a dumb question.

assuming I have several images in a directory I want convert all together into one pdf file, How can I made this with samp2p?

Posted: Thu 28 Aug 2008, 00:57
by muggins
Dingo,

AFAIK, whilst sam2p can create individual .pdf files from images, it can't then merge the .pdf files into a single .pdf. If that's what you wanted, then you could create individual .pdf files from .jpg files, by altering the above script to:

Code: Select all

#!/bin/bash


directory=`pwd`

for file in $directory/*.jpg
do
   filename=${file%.jpg}
   sam2p $filename.jpg $filename.pdf
done
save this with an appropriate name, like /usr/bin/jpg2pdf, give it executable permissions, then run it on the target directory, then use Disciple's joinPdf to merge them all into the one file.

Posted: Fri 10 Apr 2009, 13:17
by muggins
Uploaded v0.46.

here's the libjpeg PET file that's missing in Puppy 4.x

Posted: Wed 22 Apr 2009, 04:31
by kuapao
This is a very useful utility, thanks for posting it!

The program cjpeg is required to convert to JPEGs. I've posted it here.

Posted: Mon 08 Jun 2009, 09:44
by Dingo
I'am using sam2p in puppy 3.01. strange error message showed today:
# sam2p logo.png logo.pdf
This is sam2p v0.46.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
png22pnm: /usr/lib/libpng12.so.0: no version information available (required by png22pnm)
what's?

Posted: Mon 08 Jun 2009, 10:00
by muggins
@Dingo,

I think it's just a libpango incompatibility between that used on p412, (where I compiled sam2p & png22pnm) & the one on p301. Was it working before & just stopped working? I don't have a p301 environment...can you compile apps? If you have the relevant devx working, then it compiles easily & is just a matter of downloading tif22pnm-latest.tar.gz & sam2p-latest.tar.gz, then extracting both, changing to the respective directories, then:

Code: Select all

./configure --prefix=/usr
make
make install

Posted: Mon 08 Jun 2009, 10:27
by Dingo
thanks I'm very busy actually. I have not a devx already configured as sfs module, so, I'll use develpup derivative to compile (I remember develpup was build from 3.01 puppy)

Posted: Thu 10 Sep 2009, 15:17
by charlie6
Hi Dingo !

Code: Select all

# sam2p logo.png logo.pdf
This is sam2p v0.46.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA. 
you should try this syntax instead: returns «Success» when done

Code: Select all

# sam2p logo.png PDF: logo.pdf
...
Success
#
If already known that disregard this post.
Cheers
Charlie

Posted: Sat 12 Sep 2009, 00:43
by muggins
Uploaded v0.47.

sam2p for puppy linux 3.01

Posted: Sun 17 Jan 2010, 23:50
by Dingo
Sorry for delay 8)

For the joy of Puppy 3.01 users, here I compiled sam2p (with lzw and gif support enabled) without annoying warning about libpng

download here

Posted: Thu 29 Jul 2010, 08:29
by charlie6
Hi Dingo,
sorry for ... delay
Dingo wrote:a dumb question.
assuming I have several images in a directory I want convert all together into one pdf file, How can I made this with samp2p?
Not that much dumb ...

using GQView (it has been part of several puppy distros and there is a pet somewhere):

Provided you have a CUPS-PDF printer installed, and have your images stored into the same folder, just
open GQView and open that folder ;
in the left window of the dialog box, highlight (keep CTRL key pressed + mouse or up/down keys) all the images to print into one file;
then File/print;
there you may choose the CUPS-PDF printer
+ other settings as the scale (important: if one image is printed on more than one page, adjust the scale),
number of image printed on one page,
print image file name, etc...,
adjust resolution;
then chose also where to save the pdf file;
then OK
and ... it is done !

Hope this helps!
Cheers, Charlie

Posted: Fri 30 Jul 2010, 02:55
by muggins
Hello Charlie,

I think Dingo already has a solution, using sam2p. See here:

http://murga-linux.com/puppy/viewtopic.php?t=57368

Posted: Sat 31 Mar 2012, 12:37
by charlie6
Hi,
here is the sam2p later version pet (compiled on Exprimo kernel 3.2.11
Have fun
Charlie
edited: comment erased
edited 13 october 2012: right click conversion pets PNG <==> PS files

notes:
0. ...quite trivial ...sam2p MUST be installed ... :wink:
1. The above may be modified for other conversion by the user: just edit and rename the /usr/local/bin script accordingly; as also the folder, var and symlinks name in the pets; then rename the pet name before making the new pet.
2. the resolution of the output file may be modified using the sam2p options; see sam2p instructions:
sam2p instructions and FAQ extract wrote:Q39. Can sam2p load an EPS or PDF file with an arbitrary resoultion?

A39. Yes. For example use one of

sam2p -l:gs=-r216 in.eps out.png
sam2p -l:gs=-r216 in.pdf out.png

to have resoultion 216 DPI (image scaled 3 times to both directions).
Without scaling, 72 DPI is the default.
3. not to forget ...thanks also to forum member don570 for his work in developping right-click application
Have fun
Charlie

compiling png22pnm and tif22pnm

Posted: Tue 25 Mar 2014, 16:42
by charlie6
Hi,
using sam2p-v-0.49 on wheezy-3.5.2.11:
while converting from png to pdf:
as reported in an above post, i got the comment png22pnm was missing.
So got a try to compile it:
upon the make step, i got the error message:
...
/usr/bin/ld: png22pnm.o: undefined reference to symbol 'pow@@GLIBC_2.0'
/usr/bin/ld: note: 'pow@@GLIBC_2.0' is defined in DSO /lib/libm.so.6 so try adding it to the linker command line
/lib/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [compiled.stamp] Error 1
which tells that ld does not see libm.so.6 ;
to fix it:
just do what the linker (i.e. /usr/bin/ld) tells to do:
edit cc_help.sh in geany and add -lm - standing for libm , letting drop down the «-ib-» characters - , for instance to line with LIBS_PNG , as also to line with LDFLAG (found in another post):
here is the modified code of folder-where-compiling/tif22pnm-0.14/cc_help.sh

Code: Select all

if test x"$CC" = x; then
  CC='gcc'
fi
prefix='/usr'
LD='gcc'
LIBS_PNG='-lpng -lm'
LIBS_TIFF='-ltiff '
ENABLE_DEBUG='assert'
GFLAG='-g'
CFLAGS=' '
CFLAGSB=' -ansi -pedantic -Wall -W -Wnested-externs -Wbad-function-cast -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wcast-align -Winline -Wcast-qual -Wmissing-prototypes'
LDFLAGS='-lm'
# ^^^ -L...
CPPFLAGS=''
# ^^^ -I...
# CCXX=... LDXX=...
when done, just run
# make clean
and then compile again running
# make

sorry if this looks academic ... :? :oops:

here is a link that helped me to fix this
http://linuxowy.blogspot.be/2012/03/com ... 4-bit.html

hope this helps
charlie

sam2p-0.49.2-i486

Posted: Tue 25 Mar 2014, 17:22
by charlie6
Hi,
and here is version 0.49-2 compiled on wheezy-3.5.2.11
this pet has already png22pnm and tif22pnm in it !
enjoy
charlie