* 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&section=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:
Linux 2017-07-09 12:48:01 +03:00
parent e47888e067
commit 4255dd7b62
5 changed files with 26 additions and 11 deletions

4
debian/control vendored
View file

@ -9,11 +9,11 @@ Homepage: http://trimage.org
Package: trimage
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}
Description: GUI and command-line interface to optimize image files
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
compressed on the highest available compression levels. Trimage gives you
various input functions to fit your own workflow: A regular file dialog,

View file

@ -1,6 +1,8 @@
[Desktop Entry]
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
Icon=trimage
Type=Application

View file

@ -24,7 +24,7 @@ setup(name = "trimage",
('share/applications', ['desktop/trimage.desktop']),
('share/man/man1', ['doc/trimage.1'])],
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)"],
#for py2exe

View file

@ -22,7 +22,8 @@ from multiprocessing import cpu_count
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):
@ -86,7 +87,7 @@ class StartQT4(QMainWindow):
"""Set up the command line options."""
parser = OptionParser(version="%prog " + VERSION,
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.add_option("-v", "--verbose", action="store_true",
@ -261,10 +262,12 @@ class StartQT4(QMainWindow):
"""Check if the required command line apps exist."""
exe = ".exe" if (sys.platform == "win32") else ""
status = False
retcode = self.safe_call("jpegoptim" + exe + " --version")
if retcode != 0:
status = True
sys.stderr.write("[error] please install jpegoptim")
# guetzli does the compression job much better than jpegoptim (and much slower)
#retcode = self.safe_call("jpegoptim" + exe + " --version")
#if retcode != 0:
#status = True
#sys.stderr.write("[error] please install jpegoptim")
retcode = self.safe_call("optipng" + exe + " -v")
if retcode != 0:
@ -282,6 +285,13 @@ class StartQT4(QMainWindow):
sys.stderr.write("[error] please install pngcrush")
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):
""" cross-platform command-line check """
while True:
@ -431,7 +441,10 @@ class Image:
self.compressing = True
exe = ".exe" if (sys.platform == "win32") else ""
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'"
}
# Create a backup file

0
trimage Normal file → Executable file
View file