diff --git a/README.md b/README.md index 75b2061..288cbf5 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,3 @@ -### Made by [@kilianvalkhof](https://twitter.com/kilianvalkhof) - -#### Other projects: - -- 💻 [Polypane](https://polypane.app) - Develop responsive websites and apps twice as fast on multiple screens at once -- 🖌️ [Superposition](https://superposition.design) - Kickstart your design system by extracting design tokens from your website -- 🗒️ [FromScratch](https://fromscratch.rocks) - A smart but simple autosaving scratchpad - ---- - # Trimage image compressor A cross-platform tool for optimizing PNG and JPG files. diff --git a/debian/compat b/debian/compat index b4de394..f599e28 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -11 +10 diff --git a/debian/control b/debian/control index 7396a46..9646ecf 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: graphics Priority: optional Maintainer: Kilian Valkhof Build-Depends: debhelper (>=7), python3 -Standards-Version: 4.3.0 +Standards-Version: 3.9.2 Homepage: http://trimage.org Package: trimage diff --git a/debian/pycompat b/debian/pycompat new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/debian/pycompat @@ -0,0 +1 @@ +3 diff --git a/debian/rules b/debian/rules index cbe925d..4f2c774 100755 --- a/debian/rules +++ b/debian/rules @@ -1,3 +1,4 @@ #!/usr/bin/make -f %: dh $@ + diff --git a/desktop/trimage.desktop b/desktop/trimage.desktop index 8b48fa6..2cf870a 100644 --- a/desktop/trimage.desktop +++ b/desktop/trimage.desktop @@ -7,4 +7,4 @@ Type=Application Exec=trimage Categories=Application;Qt;Graphics; StartupNotify=true -Keywords=compression;compressor;images;jpg;jpeg;png;web; + diff --git a/trimage/ThreadPool/ThreadPool.py b/trimage/ThreadPool/ThreadPool.py index 17e55e4..9f9e051 100644 --- a/trimage/ThreadPool/ThreadPool.py +++ b/trimage/ThreadPool/ThreadPool.py @@ -30,6 +30,9 @@ class ThreadPoolMixIn: def __init__(self, threadpool=None): if (threadpool == None): threadpool = ThreadPool() + self.__private_threadpool = True + else: + self.__private_threadpool = False self.__threadpool = threadpool @@ -49,6 +52,10 @@ class ThreadPoolMixIn: def process_request(self, request, client_address): self.__threadpool.add_job(self.process_request_thread, [request, client_address]) + def shutdown(self): + if (self.__private_threadpool): self.__threadpool.shutdown() + + class AddJobException(Exception): ''' Exceptoion raised when a Job could not be added diff --git a/trimage/tools.py b/trimage/tools.py index 98e0218..f787c8c 100644 --- a/trimage/tools.py +++ b/trimage/tools.py @@ -7,6 +7,7 @@ from subprocess import call, PIPE def check_dependencies(): """Check if the required command line apps exist.""" + exe = ".exe" if (sys.platform == "win32") else "" status = True dependencies = { "jpegoptim": "--version", @@ -16,7 +17,7 @@ def check_dependencies(): } for elt in dependencies: - retcode = safe_call(elt + " " + dependencies[elt]) + retcode = safe_call(elt + exe + " " + dependencies[elt]) if retcode != 0: status = False print("[error] please install {}".format(elt), file=sys.stderr) @@ -42,4 +43,4 @@ def human_readable_size(num, suffix="B"): if abs(num) < 1024.0: return "%3.1f%s%s" % (num, unit, suffix) num /= 1024.0 - return "%.1f%s%s" % (num, "Y", suffix) + return "%.1f%s%s" % (num, "Y", suffix) \ No newline at end of file diff --git a/trimage/trimage.py b/trimage/trimage.py index b618b4b..2fefedf 100644 --- a/trimage/trimage.py +++ b/trimage/trimage.py @@ -304,9 +304,8 @@ class ImageRow: def __init__(self, image, waitingIcon=None): """Build the information visible in the table image row.""" self.image = image - d = { - 'filename_w_ext': lambda i: self.statusStr().format(i.filename_w_ext), + '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) @@ -327,15 +326,15 @@ class ImageRow: def statusStr(self): """Set the status message.""" if self.image.failed: - return "ERROR: {0}" + return "ERROR: %s" if self.image.compressing: - message = "Compressing {0}..." + message = "Compressing %s..." return message if not self.image.compressed and self.image.recompression: - return "Queued for recompression {0}..." + return "Queued for recompression..." if not self.image.compressed: - return "Queued {0}..." - return "{0}" + return "Queued..." + return "%s" def __getitem__(self, key): return self.d[key](self.image) @@ -372,9 +371,10 @@ class Image: file)" self.reset() self.compressing = True + exe = ".exe" if (sys.platform == "win32") else "" runString = { - "jpeg": "jpegoptim -f --strip-all '%(file)s'", - "png": "optipng -force -o7 '%(file)s'&&advpng -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'" + "jpeg": "jpegoptim" + exe + " -f --strip-all '%(file)s'", + "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 backupfullpath = '/tmp/' + self.filename_w_ext @@ -410,6 +410,9 @@ class Worker(QThread): self.toDisplay = Queue() self.threadpool = ThreadPool(max_workers=cpu_count()) + def __del__(self): + self.threadpool.shutdown() + def compress_file(self, images, showapp, verbose, imagelist): """Start the worker thread.""" for image in images: diff --git a/website/index.html b/website/index.html index 0e7995a..0598c85 100644 --- a/website/index.html +++ b/website/index.html @@ -125,14 +125,6 @@
  1. yaourt -S trimage
- -

macOS

- Trimage is available from Homebrew, to install, type: -
    -
  1. brew install trimage
  2. -
-

Launch by executing trimage in Terminal.app

-

Other *nix

  1. Download the source via git or bzr (see repositories)
  2. @@ -150,6 +142,8 @@ >

    diff --git a/website/macos.png b/website/macos.png deleted file mode 100644 index 120e1fd..0000000 Binary files a/website/macos.png and /dev/null differ