mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 10:08:40 -05:00
* Change jpegoptim to guetzli
* guetzli compresses JPGs MUCH better than jpegoptim, the output quality is near to the original image * guetzli needs a lot of CPU and RAM resources to work, but it is compensated with much better reduce of the size of the image * guetzli's git is here: https://github.com/google/guetzli; it is already in Debian's repos: https://packages.debian.org/search?keywords=guetzli&searchon=names&suite=all§ion=all, it has also already been packaged for ALT Linux and Slackware: https://pkgs.org/download/guetzli * Added Russian translations into the .desktop file
This commit is contained in:
parent
e47888e067
commit
4255dd7b62
5 changed files with 26 additions and 11 deletions
4
debian/control
vendored
4
debian/control
vendored
|
|
@ -9,11 +9,11 @@ Homepage: http://trimage.org
|
||||||
|
|
||||||
Package: trimage
|
Package: trimage
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: ${misc:Depends}, ${python:Depends}, python-qt4 (>=4.4), optipng (>=0.6.2.1), advancecomp (>=1.15), jpegoptim (>=1.2.2), pngcrush (>=1.6.7)
|
Depends: ${misc:Depends}, ${python:Depends}, python-qt4 (>=4.4), optipng (>=0.6.2.1), advancecomp (>=1.15), guetzli, pngcrush (>=1.6.7)
|
||||||
XB-Python-Version: ${python:Versions}
|
XB-Python-Version: ${python:Versions}
|
||||||
Description: GUI and command-line interface to optimize image files
|
Description: GUI and command-line interface to optimize image files
|
||||||
Trimage is a cross-platform GUI and command-line interface to optimize image
|
Trimage is a cross-platform GUI and command-line interface to optimize image
|
||||||
files via optipng, advpng, pngcrush and jpegoptim, depending on the filetype
|
files via optipng, advpng, pngcrush and guetzli, depending on the filetype
|
||||||
(currently, PNG and JPG files are supported). All image files are losslessly
|
(currently, PNG and JPG files are supported). All image files are losslessly
|
||||||
compressed on the highest available compression levels. Trimage gives you
|
compressed on the highest available compression levels. Trimage gives you
|
||||||
various input functions to fit your own workflow: A regular file dialog,
|
various input functions to fit your own workflow: A regular file dialog,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Trimage image compressor
|
Name=Trimage image compressor
|
||||||
Comment=A cross-platform tool for optimizing PNG and JPG files.
|
Name[ru]=Программа для уменьшения веса картинок Trimage
|
||||||
|
Comment=A cross-platform tool for optimizing PNG and JPG files
|
||||||
|
Comment[ru]=Кросс-платформенная утилита для оптимизации файлов PNG и JPG
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Icon=trimage
|
Icon=trimage
|
||||||
Type=Application
|
Type=Application
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -24,7 +24,7 @@ setup(name = "trimage",
|
||||||
('share/applications', ['desktop/trimage.desktop']),
|
('share/applications', ['desktop/trimage.desktop']),
|
||||||
('share/man/man1', ['doc/trimage.1'])],
|
('share/man/man1', ['doc/trimage.1'])],
|
||||||
scripts = ["trimage"],
|
scripts = ["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.""",
|
long_description = """Trimage is a cross-platform GUI and command-line interface to optimize image files via optipng, advpng and guetzli, 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 = ["PyQt4 (>=4.4)"],
|
requires = ["PyQt4 (>=4.4)"],
|
||||||
|
|
||||||
#for py2exe
|
#for py2exe
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ from multiprocessing import cpu_count
|
||||||
|
|
||||||
from ui import Ui_trimage
|
from ui import Ui_trimage
|
||||||
|
|
||||||
VERSION = "1.0.5"
|
# change version to 1.1 after replacing jpegoptim with guetzli
|
||||||
|
VERSION = "1.1"
|
||||||
|
|
||||||
|
|
||||||
class StartQT4(QMainWindow):
|
class StartQT4(QMainWindow):
|
||||||
|
|
@ -86,7 +87,7 @@ class StartQT4(QMainWindow):
|
||||||
"""Set up the command line options."""
|
"""Set up the command line options."""
|
||||||
parser = OptionParser(version="%prog " + VERSION,
|
parser = OptionParser(version="%prog " + VERSION,
|
||||||
description="GUI front-end to compress png and jpg images via "
|
description="GUI front-end to compress png and jpg images via "
|
||||||
"optipng, advpng and jpegoptim")
|
"optipng, advpng and guetzli")
|
||||||
|
|
||||||
parser.set_defaults(verbose=True)
|
parser.set_defaults(verbose=True)
|
||||||
parser.add_option("-v", "--verbose", action="store_true",
|
parser.add_option("-v", "--verbose", action="store_true",
|
||||||
|
|
@ -261,10 +262,12 @@ class StartQT4(QMainWindow):
|
||||||
"""Check if the required command line apps exist."""
|
"""Check if the required command line apps exist."""
|
||||||
exe = ".exe" if (sys.platform == "win32") else ""
|
exe = ".exe" if (sys.platform == "win32") else ""
|
||||||
status = False
|
status = False
|
||||||
retcode = self.safe_call("jpegoptim" + exe + " --version")
|
|
||||||
if retcode != 0:
|
# guetzli does the compression job much better than jpegoptim (and much slower)
|
||||||
status = True
|
#retcode = self.safe_call("jpegoptim" + exe + " --version")
|
||||||
sys.stderr.write("[error] please install jpegoptim")
|
#if retcode != 0:
|
||||||
|
#status = True
|
||||||
|
#sys.stderr.write("[error] please install jpegoptim")
|
||||||
|
|
||||||
retcode = self.safe_call("optipng" + exe + " -v")
|
retcode = self.safe_call("optipng" + exe + " -v")
|
||||||
if retcode != 0:
|
if retcode != 0:
|
||||||
|
|
@ -281,6 +284,13 @@ class StartQT4(QMainWindow):
|
||||||
status = True
|
status = True
|
||||||
sys.stderr.write("[error] please install pngcrush")
|
sys.stderr.write("[error] please install pngcrush")
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
# guetzli currently does not have neither --version not --help flags
|
||||||
|
retcode = self.safe_call("guetzli" + exe)
|
||||||
|
if retcode != 0:
|
||||||
|
status = True
|
||||||
|
sys.stderr.write("[error] please install guetzli")
|
||||||
|
return status
|
||||||
|
|
||||||
def safe_call(self, command):
|
def safe_call(self, command):
|
||||||
""" cross-platform command-line check """
|
""" cross-platform command-line check """
|
||||||
|
|
@ -431,7 +441,10 @@ class Image:
|
||||||
self.compressing = True
|
self.compressing = True
|
||||||
exe = ".exe" if (sys.platform == "win32") else ""
|
exe = ".exe" if (sys.platform == "win32") else ""
|
||||||
runString = {
|
runString = {
|
||||||
"jpeg": u"jpegoptim" + exe + " -f --strip-all '%(file)s'",
|
# "jpeg": u"jpegoptim" + exe + " -f --strip-all '%(file)s'",
|
||||||
|
# I commented out jpegoptim because guetzli compresses MUCH BETTER having a similar output quality
|
||||||
|
# the default quality level for guetzli, if the parameter '--quality Q' is not passed, it 95.
|
||||||
|
"jpeg": u"guetzli" + exe + " --quality 95 '%(file)s' '%(file)s.bak' && mv '%(file)s.bak' '%(file)s'",
|
||||||
"png": u"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'"
|
"png": u"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
|
# Create a backup file
|
||||||
|
|
|
||||||
0
trimage
Normal file → Executable file
0
trimage
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue