diff --git a/setup.py b/setup.py index abb3796..dc8cfe3 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,8 @@ #!/usr/bin/env python3 -import sys -win=(sys.platform == "win32") -if win: - import py2exe - sys.path.append("trimage") - from distutils.core import setup + setup(name = "trimage", version = "1.0.5", description = "Trimage image compressor - A cross-platform tool for optimizing PNG and JPG files", @@ -22,18 +17,6 @@ setup(name = "trimage", ('share/applications', ['desktop/trimage.desktop']), ('share/man/man1', ['doc/trimage.1'])], scripts = ["bin/trimage"], - long_description = """Trimage is a cross-platform GUI and command-line interface to optimize image files via optipng, advpng and jpegoptim, depending on the filetype (currently, PNG and JPG files are supported). It was inspired by imageoptim. All image files are losslessy compressed on the highest available compression levels. Trimage gives you various input functions to fit your own workflow: A regular file dialog, dragging and dropping and various command line options.""", - requires = ["PyQt5"], - - #for py2exe - windows=[r'trimage\trimage.py'], - zipfile=None, - options={"py2exe":{ - "optimize":2, - "compressed":1, - "bundle_files":1, - "includes":["sip",], - "excludes":['email'], - }, - }, + long_description = """Trimage is a cross-platform GUI and command-line interface to optimize image files via advpng, jpegoptim, optipng and pngcrush, depending on the filetype (currently, PNG and JPG files are supported). It was inspired by imageoptim. All image files are losslessy compressed on the highest available compression levels. Trimage gives you various input functions to fit your own workflow: A regular file dialog, dragging and dropping and various command line options.""", + requires = ["PyQt5"] ) diff --git a/trimage/trimage.py b/trimage/trimage.py index a32a1d5..a0f7092 100644 --- a/trimage/trimage.py +++ b/trimage/trimage.py @@ -305,7 +305,7 @@ class ImageRow: """Build the information visible in the table image row.""" self.image = image d = { - 'shortname': lambda i: self.statusStr() % i.shortname, + 'filename_w_ext': lambda i: self.statusStr() % i.filename_w_ext, 'oldfilesizestr': lambda i: human_readable_size(i.oldfilesize) if i.compressed else "", 'newfilesizestr': lambda i: human_readable_size(i.newfilesize) @@ -316,7 +316,7 @@ class ImageRow: 'icon': lambda i: i.icon if i.compressed else waitingIcon, 'fullpath': lambda i: i.fullpath, #only used by cli } - names = ['shortname', 'oldfilesizestr', 'newfilesizestr', + names = ['filename_w_ext', 'oldfilesizestr', 'newfilesizestr', 'ratiostr', 'icon'] for i, n in enumerate(names): d[i] = d[n] @@ -346,13 +346,14 @@ class Image: self.valid = False self.reset() self.fullpath = fullpath + self.filename_w_ext = path.basename(self.fullpath) + self.filename, self.filetype = path.splitext(self.filename_w_ext) if path.isfile(self.fullpath) and access(self.fullpath, W_OK): - self.filetype = path.splitext(self.fullpath)[1][1:].lower() + self.filetype = self.filetype[1:].lower() if self.filetype == "jpg": self.filetype = "jpeg" if self.filetype in ["jpeg", "png"]: oldfile = QFileInfo(self.fullpath) - self.shortname = oldfile.fileName() self.oldfilesize = oldfile.size() self.icon = QIcon(self.fullpath) self.valid = True @@ -376,7 +377,8 @@ class Image: "png": "optipng" + exe + " -force -o7 '%(file)s'&&advpng" + exe + " -z4 '%(file)s' && pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time '%(file)s' '%(file)s.bak' && mv '%(file)s.bak' '%(file)s'" } # create a backup file - copy(self.fullpath, self.fullpath + '~') + backupfullpath = '/tmp/' + self.filename_w_ext + copy(self.fullpath, backupfullpath) try: retcode = call(runString[self.filetype] % {"file": self.fullpath}, shell=True, stdout=PIPE) @@ -388,11 +390,11 @@ class Image: # checks the new file and copy the backup if self.newfilesize >= self.oldfilesize: - copy(self.fullpath + '~', self.fullpath) + copy(backupfullpath, self.fullpath) self.newfilesize = self.oldfilesize # removes the backup file - remove(self.fullpath + '~') + remove(backupfullpath) else: self.failed = True self.compressing = False