A couple of people have asked me where to find these- look for imgvtopgm which converts both ways. For instance here.
Scripts etc are provided as is, with no warranty of any kind, express or implied. Use at your own risk.
You need the pbmplus package.
First a script to view Album2go images:
function viewalbum () { strings $1 | head -1 && rawtopgm -headerskip 154 80 160 $1 | pnminvert| pnmscale -xscale 2 | pnmtoxwd | xwud ; }
To convert an image to album2go format, Run the following script. It
calls the C program below that you must have compiled.
#!/bin/bash
# Take an image file #1 and convert it to a prc file #2 for Albumtogo
# Title of the file is #3 if given, otherwise it's derived from the filename
# Defaults to cropping the top left corner
# If there's an inital -f parameter it fits the image
if [ "$1" = "-f" ]; then fit="t"; shift; fi
if [ "$1" = "-i" ]; then install="t"; shift; fi
file="$1"; out="$2";
if [ ! -f "$file" ]; then echo "Can't find $file"; exit 1; fi
if [ -z "$out" ]; then out=${file%.*}.prc; fi
if [ -z "$3" ]; then
fileroot="${file##*/}"; fileroot="${fileroot%%.*}";
else
fileroot="$3";
fi
initial=anytopnm;
if [ ${file%jpg} != "${file}" ]; then initial=djpeg; fi;
$initial $file | ppmtopgm > /tmp/album.pgm &&
if [ -n "$fit" ]; then
scale=`pnmfile /tmp/album.pgm | awk '{ if ($4 > $6) print "-xsize"; else print "-ysize"; }'` &&
pnmscale $scale 160 /tmp/album.pgm> /tmp/album1.pgm
else
scale=`pnmfile /tmp/album.pgm | awk '{ if ($4 < $6) print "-xsize"; else print "-ysize"; }'` &&
pnmscale $scale 160 /tmp/album.pgm| pnmcut 0 0 160 160 > /tmp/album1.pgm
fi
echo -n "$fileroot"> ${out} && len=${#fileroot}
tail -c +$[ $len + 1 ] $HOME/various/header.prc >> ${out} &&
pnmpaste -replace /tmp/album1.pgm 0 0 $HOME/various/icons/black.pgm| pnminvert | pnmdepth 15 |tail +4 | ~/bin/packnibbles>> ${out}
if [ $? ]; then
echo "Something went wrong";
exit 1
fi
if [ -n "$install" ]; then
echo "Queuing $out for installation on palm"
gpilot-install-file -l ${out} ;
rm ${out};
fi
rm -f /tmp/album*.pgm;
The C program packnibbles.c. This just takes two bytes and puts the least-significant 4 bits of each into a single byte. Trivial, but I didn't know a standard Unix tool that would do it. Let me know if you have one. Compile with gcc packnibbles.C -o packnibbles
#includeYou also need the file header.prc. And you need to make black.pgm with something like the following:/* gcc packnibbles.c -o ../packnibbles */ main () { while(!feof(stdin)) { unsigned char c,c2; c=getchar(); c2=getchar(); putchar((c&0xf)<<4|(c2&0xf)); } exit(0); }
ppmmake black 160 160 | ppmtopgm > black.pgm