Sam2p: commandline

Paint programs, vector editors, 3d modelers, animation editors, etc.
Post Reply
Message
Author
muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

Sam2p: commandline

#1 Post 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.
Last edited by muggins on Tue 23 Nov 2010, 05:15, edited 6 times in total.

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

#2 Post 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?
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#3 Post 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.

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#4 Post by muggins »

Uploaded v0.46.

kuapao
Posts: 94
Joined: Tue 01 Jul 2008, 05:30

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

#5 Post 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.
Attachments
libjpeg62_6b-14-i386.pet
libjpeg62_6b-14-i386 from Debian package
(76.8 KiB) Downloaded 1097 times

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

#6 Post 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?
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#7 Post 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

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

#8 Post 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)
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#9 Post 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

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#10 Post by muggins »

Uploaded v0.47.

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

sam2p for puppy linux 3.01

#11 Post 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
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#12 Post 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

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#13 Post by muggins »

Hello Charlie,

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

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

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#14 Post 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
Attachments
sam2p_right-click-PS_to_PNG-0.0.1.pet
right click PS to PNG conversion
(3.29 KiB) Downloaded 875 times
sam2p_right-click-PNG_to_PS-0.0.1.pet
right click PNG to PS conversion
(3.23 KiB) Downloaded 869 times

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

compiling png22pnm and tif22pnm

#15 Post 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
Attachments
tif_png22pnm_wheezy-i386.pet
(34.27 KiB) Downloaded 298 times

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

sam2p-0.49.2-i486

#16 Post 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

Post Reply