Finito di leggere il tutorial ufficiale segnalato in uno scritto precedente, lo stile è migliorato tantissimo e molte cose sono più chiare.
Il numero di script convertiti aumenta; l'ultimo cui è toccata questa sorte è gpng2jpg: un convertitore di file PNG.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# AUTHOR: Maurizio di NuvoleSparse
#
# License: GNU General Public version 2 or any later version.
# This program comes with ABSOLUTELY NO WARRANTY; for details
# see the COPYING file or visit "http://www.gnu.org/licenses/gpl.html".
# This is free software, and you are welcome to redistribute it under
# certain conditions. See the GPL license for details.
#
# Dependence:
# ImageMagick
# python
# zenity
import os
from sys import argv, exit
from re import search
from commands import getoutput
if len(argv[1:]) == 0:
os.system('zenity --title="Attenzione - gpng2jpg" --error\
--text="Seleziona almeno un file."')
exit(1)
livello = getoutput(str('zenity --scale --title="gpng2jpg" --text \
"Qualità di compressione:" --min-value=0 --max-value=100 --value=85 \
--step 1'))
if len(livello) == 0: exit(1)
count = 1
while count < len(argv):
if search(r"\.[pP][nN][gG]$", argv[count]):
imageJPG = str(argv[count].replace("png", "jpg", -1))
os.system("convert -compress JPEG -quality "+livello+" \
"+argv[count]+" "+imageJPG+" 2>>/tmp/gpng2jpg.log")
else:
os.system('echo -e "Attenzione: \''+argv[count]+\
'\' non e\' un png." >>/tmp/gpng2jpg.log')
count = count + 1
if os.path.isfile("/tmp/gpng2jpg.log") and \
os.path.getsize("/tmp/gpng2jpg.log") != 0:
os.system("cat /tmp/gpng2jpg.log | zenity \
--title='Errore - gpng2jpg' --text-info")
os.remove("/tmp/gpng2jpg.log")
Ultimo aggiornamento 06 Aprile 2006