#!/usr/local/bin/python #one should set the line above to fit the enviroment python interpreter ######### L I C E N S I N G / C O P Y I N G ############## """ You are FREE to use, modify and distribute(modified or not) this piece of software under the terms of GNU GPL(General Public License) version 2*(or any other later versions released/created/updated by FSF-Free Software Foundation**). Copying and licensing disclaimers/notices about using and distributing Sign Writing symbols may be searched through http://www.signwriting.org * http://www.gnu.org/licenses/gpl.html ** http://www.fsf.org/ You CANNOT distribute this piece of code without this copyright/license notice """ ########################################################## import os import string import sys # version 0.2 """Commented Version by machado at softwarelivre dot org""" # version 0.1 """first running Version by machado at softwarelivre dot org""" #Usage notes: """ You're supposed to have this script under a directory which should contain (at least) a subdirectory named 'SSS-2204' containing png images of SW-Symbols, a subdirectory named 'SSS-2004pnm' and a subdirectory named 'SSS-2004png'. Like this: current | |- SSS-2004 |- SSS-2004pnm |- SSS-2004png |-gera_svg_sss2004_2.py |-... You MUST have read, write and execute privileges in all cited directories, including """ # Enviroment notes: """ This script was made/tested in a Debian GNU/Linux (Etch/testing)*** YOU MUST have in your enviroment: * netpbm (tested version was 10.0-10(or 2:10.0-10)) * potrace (tested version was 1.7-1) Both are available in Debian GNU/linux main repositories. other types of packages(rpm, emerge,...) are available for different GNU/Linux versions Refer to your distribution documentation about how to obtain them. In the "worst" case, source code are available for the situations when full compilation is required. If you only have access to gif versions os SW symbols, you can convert them using gif2png (tested version was 2.5.1-1. From Debian repositories as well) *** http://www.debian.org """ # lista arquivos png no diretorio SSS-2004 #list png files in SSS-2004 directory os.system('ls ./SSS-2004/ > arquivos_png.txt') arquivos_png = open('arquivos_png.txt','r') #para cada arquivo encontrado, gera um .pnm # for each png file found, generates a pnm file for line in arquivos_png: line.strip() if not line: continue line = line [0:-5] os.system('pngtopnm SSS-2004/%s.png > SSS-2004pnm/%s.pnm'%(line,line)) # lista arquivos png no diretorio SSS-2004pnm # list pnm files in SSS-2004pnm directory os.system('ls ./SSS-2004pnm/ > arquivos_pnm.txt') arquivos_pnm = open('arquivos_pnm.txt','r') #para cada arquivo encontrado, gera um .svg # for each png file found, generates a svg file for line in arquivos_pnm: line.strip() if not line: continue line = line [0:-5] os.system('potrace -s SSS-2004pnm/%s.pnm -o SSS-2004svg/%s.svg'%(line,line)) #close files : ) arquivos_png.close() arquivos_pnm.close() # TODO notes: """ * Parameterize options like SSS2004(source) directories, intermediate/temporary (pnm)directories and target (SSS-2004svg)directories. * Parameterize options like path to pngtopnm, path to potrace, to python, etcetera... * include option to convert directly from gif to svg files ** Better, include option to select 'from' and 'to' formats * use main/ __init__ methods to be more 'elegant' * create a Graphical User Interface in GTK+ or Qt or wxWidgets * use png, pnm, gif and svg python llibraries. Today, most of work are done by tools/programs external to python. The current way is simpler, but the python modules/libraries way must be reeeeally faster! """