fix handling of unicode characters in filenames, bump version to 1.0.0b2

This commit is contained in:
Kilian Valkhof 2010-03-28 16:11:50 +02:00
parent e382b579ec
commit a506c0fee4
5 changed files with 45 additions and 24 deletions

8
debian/changelog vendored
View file

@ -1,6 +1,6 @@
trimage (1.0.0b-0ubuntu1) jaunty; urgency=low
trimage (1.0.0b2-0ubuntu1) jaunty; urgency=low
* Trimage image compressor
-- Kilian Valkhof <help@trimage.org> Tue, 23 Mar 2010 20:18:17 +0100
* correct parsing of unicode characters in filenames
* changelog
-- Kilian Valkhof <kilian@kdesktop> Sun, 28 Mar 2010 16:09:45 +0200

View file

@ -3,7 +3,7 @@
from distutils.core import setup
setup(name = "trimage",
version = "1.0.0b",
version = "1.0.0b2",
description = "Trimage image compressor - A cross-platform tool for optimizing PNG and JPG files",
author = "Kilian Valkhof, Paul Chaplin",
author_email = "help@trimage.org",

View file

@ -13,7 +13,8 @@ from hurry.filesize import *
from ui import Ui_trimage
VERSION = "1.0.0b"
VERSION = "1.0.0b2"
class StartQT4(QMainWindow):
@ -100,7 +101,8 @@ class StartQT4(QMainWindow):
imagedir = listdir(directory)
filelist = QStringList()
for image in imagedir:
image = QString(path.join(dirpath, image))
image = self.unicodize(path.join(dirpath, image))
if self.checkname(image):
filelist.append(image)
self.delegator(filelist)
@ -109,13 +111,16 @@ class StartQT4(QMainWindow):
self.showapp = False
image = path.abspath(image)
filecmdlist = QStringList()
filecmdlist.append(image)
if self.checkname(image):
filecmdlist.append(self.unicodize(image))
self.delegator(filecmdlist)
def file_drop(self, images):
"""
Get a file from the drag and drop handler and send it to compress_file.
"""
for image in images:
image = self.unicodize(unicode(image).encode('utf-8'))
self.delegator(images)
def file_dialog(self):
@ -126,6 +131,10 @@ class StartQT4(QMainWindow):
"", # directory
# this is a fix for file dialog differentiating between cases
"Image files (*.png *.jpg *.jpeg *.PNG *.JPG *.JPEG)")
for image in images:
image = self.unicodize(unicode(image))
self.delegator(images)
def recompress_files(self):
@ -151,7 +160,7 @@ class StartQT4(QMainWindow):
self.imagelist.append(("Compressing...", "", "", "", image,
QIcon(QPixmap(self.ui.get_image("pixmaps/compressing.gif")))))
else:
sys.stderr.write("[error] %s not an image file" % image)
sys.stderr.write("[error] %s not an image file\n" % image)
self.update_table()
self.thread.compress_file(delegatorlist, self.showapp, self.verbose,
@ -195,7 +204,7 @@ class StartQT4(QMainWindow):
def checkname(self, name):
"""Check if the file is a jpg or png."""
return path.splitext(str(name))[1].lower() in [".jpg", ".jpeg", ".png"]
return path.splitext(unicode(name))[1].lower() in [".jpg", ".jpeg", ".png"]
def enable_recompress(self):
"""Enable the recompress button."""
@ -230,6 +239,13 @@ class StartQT4(QMainWindow):
else:
raise
def unicodize(self, obj, encoding='utf-8'):
if isinstance(obj, basestring):
if not isinstance(obj, unicode):
obj = unicode(obj, encoding)
return obj
class TriTableModel(QAbstractTableModel):
def __init__(self, parent, imagelist, header, *args):
@ -294,7 +310,7 @@ class Worker(QThread):
"""Compress the given file, get data from it and call update_table."""
for image in self.images:
#gather old file data
filename = str(image[0])
filename = unicode(image[0])
icon = image[1]
oldfile = QFileInfo(filename)
name = oldfile.fileName()
@ -305,10 +321,9 @@ class Worker(QThread):
extention = path.splitext(filename)[1]
#decide with tool to use
if extention in [".jpg", ".jpeg"]:
runString = "jpegoptim -f --strip-all '%(file)s'"
runString = u"jpegoptim -f --strip-all '%(file)s'"
elif extention in [".png"]:
runString = ("optipng -force -o7 '%(file)s';"
"advpng -z4 '%(file)s'")
runString = (u"optipng -force -o7 '%(file)s'; advpng -z4 '%(file)s'")
else:
sys.stderr.write("[error] %s not an image file" % filename)

View file

@ -9,7 +9,7 @@ class TrimageTableView(QTableView):
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
if event.mimeData().hasFormat("text/uri-list"):
if event.mimeData().hasUrls:
event.accept()
else:
event.ignore()
@ -18,10 +18,12 @@ class TrimageTableView(QTableView):
event.accept()
def dropEvent(self, event):
files = str(event.mimeData().data("text/uri-list")).strip().split()
for i, file in enumerate(files):
files[i] = QUrl(QString(file)).toLocalFile()
self.emit(SIGNAL("fileDropEvent"), (files))
event.accept()
filelist = []
for url in event.mimeData().urls():
filelist.append(unicode(url.toLocalFile()))
self.emit(SIGNAL("fileDropEvent"), (filelist))
class Ui_trimage(object):

View file

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf8">
<title>Trimage image compressor</title>
<title>Trimage (lossless) image compressor</title>
<link href="http://github.com/Kilian/sencss/raw/master/source/sen.css" rel="stylesheet" type="text/css">
<style>
body {
@ -42,7 +42,6 @@
-webkit-column-count:3;
-moz-column-gap:2em;
-webkit-column-gap:2em;
text-align:justify;
}
img {
margin-bottom:1.5em;
@ -70,8 +69,8 @@
<body>
<div id="wrap">
<h1><img src="trimage-icon.png" alt=""> Trimage image compressor &ndash; 1.0.0b (beta)</h1>
<span class="subtitle">A cross-platform tool for optimizing PNG and JPG files.</span>
<h1><img src="trimage-icon.png" alt=""> Trimage image compressor &ndash; 1.0.0b2 (beta)</h1>
<span class="subtitle">A cross-platform tool for losslessy optimizing PNG and JPG files.</span>
<p class="tri">Trimage is a cross-platform GUI and command-line interface to optimize image
files via <a href="http://optipng.sourceforge.net/">optipng</a>,
<a href="http://advancemame.sourceforge.net/comp-readme.html">advpng</a> and
@ -94,6 +93,11 @@
<li><code>sudo apt-get install trimage</code></li>
</ol>
<p>If you are still on Jaunty, read <a href="https://launchpad.net/+help/soyuz/ppa-sources-list.html">this guide</a> on installing PPA's.</p>
<h3>Arch Linux</h3>
Trimage is available from AUR, to install, type:
<ol>
<li><code>yaourt -S trimage-git</code></li>
</ol>
<h3><img src="linux.png" alt=""> Other *nix</h3>
<ol>
<li>Download the source via git or bzr (see repositories)</li>