[Coco] perl script to convert pics for Sockmaster's Hicolor prog
Joel Ewy
jcewy at swbell.net
Fri Jul 21 10:39:27 EDT 2006
Here's a little perl script I cooked up -- it's pretty raw and doesn't do any error checking, etc. It's only been tested on a single computer runing RedHat Linux 8. No warranty, no responsibility, bla, bla, bla.
The purpose is to take multiple .jpg files of arbitrary dimensions, scale them en masse so that they fit inside a 320 x 200 CoCo screen, and convert them to 8-bit BMP files that can be displayed by John Kowalski's HiColor program.
You need to have the NETPBM utils installed. I have used djpeg instead of jpegtopnm -- I don't really exactly remember why, but for some reason it worked better for me. djpeg probably comes from the JPEG library, but the jpegtopnm utility from NETPBM can probably be substituted though I think the syntax would need to be changed.
Though I haven't tested this, I would think it could be made to work under MS-Windows in Cygwin. And, the NETPBM tools have been ported to OS9-68K. I have on floppy a binary of Perl 4 that somebody from the EFFO (I think) compiled for 68k and emailed to me around 1995 or 1996. He suggested that source would be available sometime, but I never saw it. I haven't studied Perl's Artistic Licence enough to know whether it is proper to distribute this binary without source, but if anyone wants a copy I'd be happy to share. I haven't tried cocovert.pl on the MM/1, but it's simple enough it should be adaptable. And it could easily be rewritten as a shell script or maybe in OddJob.
Anybody who would like to modify this for whatever purpose is welcome. I would be inclined to GPL it, though I don't feel the urge to tack a copy of the license onto this email if nobody is especially interested in it. Maybe that should be done if it gets archived and posted on rtsi.com.
Code follows:
cocovert.pl
----------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
# cocovert.pl Scale and convert JPEG images for use with Sockmaster's HiColor
# viewer on the Tandy CoCo3. Joel Ewy 2005
@filelist = @ARGV;
if (!(-s "blackmatte.ppm")) {
system ("ppmmake black 320 200 >blackmatte.ppm");
}
for ($i = 0; $i < (@ARGV); $i++) {
$filelist[$i] =~ s/jpg/bmp/i;
system ("djpeg $ARGV[$i] | pnmscale -xysize 320 200 >$filelist[$i].ppm");
system ("pnmcomp -align=center -valign=middle $filelist[$i].ppm blackmatte.ppm >$filelist[$i]1.ppm");
system ("ppmquantneural <$filelist[$i]1.ppm 256 >map.ppm");
system ("pnmremap -mapfile=map.ppm <$filelist[i]1.ppm >$filelist[$i].ppm");
system ("ppmtobmp -bpp=8 <$filelist[$i].ppm >$filelist[$i]");
# system ("rm $filelist[$i]*.ppm");
}
----------------------------------------------------------------------------------------------------------------------
More information about the Coco
mailing list