Convert X bitmaps (.xbm) to PNG - example of Pozkanzer tools
Poskanzer's bitmap / pixmap tools have been around for nearly
twenty years. They go under names such as xbmtopbm
or
pnmtopng
. Each tool converts one or other kind of file into
another format. The tools are still useful today, after twenty years.
The following script converts xbm (X Windows bitmap) format files into png (Portable Network Graphics).
One gotcha is that anytopnm
fails to detect xbm files
correctly, so this uses xbmtopbm
followed by anytopnm
to
do the conversions, finishing with pnmtopng
.
#!/usr/bin/perl use warnings; use strict; opendir (DIR,"."); my @files = readdir (DIR); closedir (DIR); my @xbmfiles = grep /.xbm$/, @files; print "@xbmfiles\n"; foreach my $file (@xbmfiles) { my $outputfile = $file; $outputfile =~ s/.xbm/.png/ or die "Bad file name '$file'"; system ("xbmtopbm $outputfile"); }
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com) or use the discussion group at Google Groups.
/
Privacy /
Disclaimer