mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-27 10:28:41 -05:00
Compare commits
No commits in common. "master" and "1.0.6" have entirely different histories.
11 changed files with 29 additions and 32 deletions
10
README.md
10
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
|
# Trimage image compressor
|
||||||
|
|
||||||
A cross-platform tool for optimizing PNG and JPG files.
|
A cross-platform tool for optimizing PNG and JPG files.
|
||||||
|
|
|
||||||
2
debian/compat
vendored
2
debian/compat
vendored
|
|
@ -1 +1 @@
|
||||||
11
|
10
|
||||||
|
|
|
||||||
2
debian/control
vendored
2
debian/control
vendored
|
|
@ -3,7 +3,7 @@ Section: graphics
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: Kilian Valkhof <kilian@kilianvalkhof.com>
|
Maintainer: Kilian Valkhof <kilian@kilianvalkhof.com>
|
||||||
Build-Depends: debhelper (>=7), python3
|
Build-Depends: debhelper (>=7), python3
|
||||||
Standards-Version: 4.3.0
|
Standards-Version: 3.9.2
|
||||||
Homepage: http://trimage.org
|
Homepage: http://trimage.org
|
||||||
|
|
||||||
Package: trimage
|
Package: trimage
|
||||||
|
|
|
||||||
1
debian/pycompat
vendored
Normal file
1
debian/pycompat
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
3
|
||||||
1
debian/rules
vendored
1
debian/rules
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
%:
|
%:
|
||||||
dh $@
|
dh $@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ Type=Application
|
||||||
Exec=trimage
|
Exec=trimage
|
||||||
Categories=Application;Qt;Graphics;
|
Categories=Application;Qt;Graphics;
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
Keywords=compression;compressor;images;jpg;jpeg;png;web;
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ class ThreadPoolMixIn:
|
||||||
def __init__(self, threadpool=None):
|
def __init__(self, threadpool=None):
|
||||||
if (threadpool == None):
|
if (threadpool == None):
|
||||||
threadpool = ThreadPool()
|
threadpool = ThreadPool()
|
||||||
|
self.__private_threadpool = True
|
||||||
|
else:
|
||||||
|
self.__private_threadpool = False
|
||||||
|
|
||||||
self.__threadpool = threadpool
|
self.__threadpool = threadpool
|
||||||
|
|
||||||
|
|
@ -49,6 +52,10 @@ class ThreadPoolMixIn:
|
||||||
def process_request(self, request, client_address):
|
def process_request(self, request, client_address):
|
||||||
self.__threadpool.add_job(self.process_request_thread, [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):
|
class AddJobException(Exception):
|
||||||
'''
|
'''
|
||||||
Exceptoion raised when a Job could not be added
|
Exceptoion raised when a Job could not be added
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ from subprocess import call, PIPE
|
||||||
|
|
||||||
def check_dependencies():
|
def check_dependencies():
|
||||||
"""Check if the required command line apps exist."""
|
"""Check if the required command line apps exist."""
|
||||||
|
exe = ".exe" if (sys.platform == "win32") else ""
|
||||||
status = True
|
status = True
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"jpegoptim": "--version",
|
"jpegoptim": "--version",
|
||||||
|
|
@ -16,7 +17,7 @@ def check_dependencies():
|
||||||
}
|
}
|
||||||
|
|
||||||
for elt in dependencies:
|
for elt in dependencies:
|
||||||
retcode = safe_call(elt + " " + dependencies[elt])
|
retcode = safe_call(elt + exe + " " + dependencies[elt])
|
||||||
if retcode != 0:
|
if retcode != 0:
|
||||||
status = False
|
status = False
|
||||||
print("[error] please install {}".format(elt), file=sys.stderr)
|
print("[error] please install {}".format(elt), file=sys.stderr)
|
||||||
|
|
|
||||||
|
|
@ -304,9 +304,8 @@ class ImageRow:
|
||||||
def __init__(self, image, waitingIcon=None):
|
def __init__(self, image, waitingIcon=None):
|
||||||
"""Build the information visible in the table image row."""
|
"""Build the information visible in the table image row."""
|
||||||
self.image = image
|
self.image = image
|
||||||
|
|
||||||
d = {
|
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)
|
'oldfilesizestr': lambda i: human_readable_size(i.oldfilesize)
|
||||||
if i.compressed else "",
|
if i.compressed else "",
|
||||||
'newfilesizestr': lambda i: human_readable_size(i.newfilesize)
|
'newfilesizestr': lambda i: human_readable_size(i.newfilesize)
|
||||||
|
|
@ -327,15 +326,15 @@ class ImageRow:
|
||||||
def statusStr(self):
|
def statusStr(self):
|
||||||
"""Set the status message."""
|
"""Set the status message."""
|
||||||
if self.image.failed:
|
if self.image.failed:
|
||||||
return "ERROR: {0}"
|
return "ERROR: %s"
|
||||||
if self.image.compressing:
|
if self.image.compressing:
|
||||||
message = "Compressing {0}..."
|
message = "Compressing %s..."
|
||||||
return message
|
return message
|
||||||
if not self.image.compressed and self.image.recompression:
|
if not self.image.compressed and self.image.recompression:
|
||||||
return "Queued for recompression {0}..."
|
return "Queued for recompression..."
|
||||||
if not self.image.compressed:
|
if not self.image.compressed:
|
||||||
return "Queued {0}..."
|
return "Queued..."
|
||||||
return "{0}"
|
return "%s"
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self.d[key](self.image)
|
return self.d[key](self.image)
|
||||||
|
|
@ -372,9 +371,10 @@ class Image:
|
||||||
file)"
|
file)"
|
||||||
self.reset()
|
self.reset()
|
||||||
self.compressing = True
|
self.compressing = True
|
||||||
|
exe = ".exe" if (sys.platform == "win32") else ""
|
||||||
runString = {
|
runString = {
|
||||||
"jpeg": "jpegoptim -f --strip-all '%(file)s'",
|
"jpeg": "jpegoptim" + exe + " -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'"
|
"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
|
# create a backup file
|
||||||
backupfullpath = '/tmp/' + self.filename_w_ext
|
backupfullpath = '/tmp/' + self.filename_w_ext
|
||||||
|
|
@ -410,6 +410,9 @@ class Worker(QThread):
|
||||||
self.toDisplay = Queue()
|
self.toDisplay = Queue()
|
||||||
self.threadpool = ThreadPool(max_workers=cpu_count())
|
self.threadpool = ThreadPool(max_workers=cpu_count())
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.threadpool.shutdown()
|
||||||
|
|
||||||
def compress_file(self, images, showapp, verbose, imagelist):
|
def compress_file(self, images, showapp, verbose, imagelist):
|
||||||
"""Start the worker thread."""
|
"""Start the worker thread."""
|
||||||
for image in images:
|
for image in images:
|
||||||
|
|
|
||||||
|
|
@ -125,14 +125,6 @@
|
||||||
<ol>
|
<ol>
|
||||||
<li><code>yaourt -S trimage</code></li>
|
<li><code>yaourt -S trimage</code></li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<h3><img src="macos.png" alt="" /> macOS</h3><!-- Attribution for the image: VICDJES21 / CC BY-SA (https://creativecommons.org/licenses/by-sa/4.0) -->
|
|
||||||
Trimage is available from Homebrew, to install, type:
|
|
||||||
<ol>
|
|
||||||
<li><code>brew install trimage</code></li>
|
|
||||||
</ol>
|
|
||||||
<p>Launch by executing <code>trimage</code> in Terminal.app</p>
|
|
||||||
|
|
||||||
<h3><img src="linux.png" alt="" /> Other *nix</h3>
|
<h3><img src="linux.png" alt="" /> Other *nix</h3>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Download the source via git or bzr (see repositories)</li>
|
<li>Download the source via git or bzr (see repositories)</li>
|
||||||
|
|
@ -150,6 +142,8 @@
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<!--
|
<!--
|
||||||
|
<h3><img src="mac.png" alt=""> Mac</h3>
|
||||||
|
<p>Trimage should be able to run on Mac. <a href="mailto:help@trimage.org">Help us with this</a></p>
|
||||||
<h3><img src="windows.png" alt=""> Windows</h3>
|
<h3><img src="windows.png" alt=""> Windows</h3>
|
||||||
<p>Trimage should be able to run on Windows. <a href="mailto:help@trimage.org">Help us with this</a></p>
|
<p>Trimage should be able to run on Windows. <a href="mailto:help@trimage.org">Help us with this</a></p>
|
||||||
-->
|
-->
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 835 B |
Loading…
Add table
Add a link
Reference in a new issue