mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 10:08:40 -05:00
py2exe support
Usage: setup.py py2exe You must be able to start trimage.py before even attempting to use py2exe. It generates a standalone executable. That standalone exacutable starts up only if the following files can be found on the path: jpegoptim.exe optipng.exe advpng.exe (they must return 0) Compression does not work yet and the Windows versions of these tools are a lot slower than on Linux. The binaries I found were pretty old. They should most probably be recompiled to make use of new cpu features. Or we should find other tools. trimage.hurry.filename -> trimage.filename because py2exe couldn't deal with it
This commit is contained in:
parent
464337d033
commit
d282bcf8e9
5 changed files with 140 additions and 8 deletions
14
src/trimage/trimage.py
Executable file → Normal file
14
src/trimage/trimage.py
Executable file → Normal file
|
|
@ -9,7 +9,7 @@ from optparse import OptionParser
|
|||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from hurry.filesize import *
|
||||
from filesize import *
|
||||
from imghdr import what as determinetype
|
||||
|
||||
from Queue import Queue
|
||||
|
|
@ -209,18 +209,19 @@ class StartQT4(QMainWindow):
|
|||
|
||||
def checkapps(self):
|
||||
"""Check if the required command line apps exist."""
|
||||
exe=".exe" if (sys.platform=="win32") else ""
|
||||
status = False
|
||||
retcode = self.safe_call("jpegoptim --version")
|
||||
retcode = self.safe_call("jpegoptim"+exe+" --version")
|
||||
if retcode != 0:
|
||||
status = True
|
||||
sys.stderr.write("[error] please install jpegoptim")
|
||||
|
||||
retcode = self.safe_call("optipng -v")
|
||||
retcode = self.safe_call("optipng"+exe+" -v")
|
||||
if retcode != 0:
|
||||
status = True
|
||||
sys.stderr.write("[error] please install optipng")
|
||||
|
||||
retcode = self.safe_call("advpng --version")
|
||||
retcode = self.safe_call("advpng"+exe+" --version")
|
||||
if retcode != 0:
|
||||
status = True
|
||||
sys.stderr.write("[error] please install advancecomp")
|
||||
|
|
@ -343,9 +344,10 @@ class Image:
|
|||
raise "Tried to compress invalid image (unsupported format or not file)"
|
||||
self.reset()
|
||||
self.compressing=True
|
||||
exe=".exe" if (sys.platform=="win32") else ""
|
||||
runString = {
|
||||
"jpeg": u"jpegoptim -f --strip-all '%(file)s'",
|
||||
"png" : u"optipng -force -o7 '%(file)s'&&advpng -z4 '%(file)s'"}
|
||||
"jpeg": u"jpegoptim"+exe+" -f --strip-all '%(file)s'",
|
||||
"png" : u"optipng"+exe+" -force -o7 '%(file)s'&&advpng"+exe+" -z4 '%(file)s'"}
|
||||
try:
|
||||
retcode = call(runString[self.filetype] % {"file": self.fullpath},
|
||||
shell = True, stdout=PIPE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue