Skip to content

Instantly share code, notes, and snippets.

@ryanwoodsmall
Last active August 28, 2020 21:39
Show Gist options
  • Save ryanwoodsmall/6f4942fb86e9b53b7d80aeacfe5c18c0 to your computer and use it in GitHub Desktop.
Save ryanwoodsmall/6f4942fb86e9b53b7d80aeacfe5c18c0 to your computer and use it in GitHub Desktop.
netpbmto.py
#!/usr/bin/env python3
#
# show conversions for a (custom built) netpbm
#
# ex: ./netpbmto.py | egrep "\['png'.*'xpm'\]"
#
from os import walk
import re
rs = []
def recfind(k):
if not fc[k]:
return
print(rs)
if (k in rs):
return
else:
rs.append(k)
for e in fc[k]:
recfind(e)
rs.remove(k)
dir2read = "/home/ryan/Downloads/netpbm/netpbm-10.73.30-built/bin"
fl = []
for (dirpath, dirnames, filenames) in walk(dir2read):
fl.extend(filenames)
fc = {}
for f in fl:
if (re.search(r".*to.*", f)):
(s,d) = f.replace("to","|",1).split("|")
try:
fc[s].append(d)
except KeyError:
fc[s] = [d]
try:
if fc[d]:
continue
except KeyError:
fc[d] = []
for k in fc:
#for k in ['png']:
#print(k + ": " + str(fc[k]))
recfind(k)
#!/bin/sh
for i in /tmp/ginaapbo11?.png ; do
x=${i//.png/.xpm}
echo $i : $x
pngtopam < $i | pamtotga | tgatoppm | ppmtoxpm > $x
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment