mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 01:58:41 -05:00
Compare commits
16 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad74684272 | ||
|
|
031adf6054 | ||
|
|
f35be9c750 | ||
|
|
636b5a9750 | ||
|
|
c21089f97b | ||
|
|
f37c8b6ffc | ||
|
|
8af532f25e | ||
|
|
493a0e18d2 | ||
|
|
224f6b3503 | ||
|
|
c3244e19a6 | ||
|
|
269e052ba4 | ||
|
|
49272e0d95 | ||
|
|
1342503b54 | ||
|
|
0cbbfcdfe8 | ||
|
|
9d6edd3847 | ||
|
|
9bdd44a4e4 |
11 changed files with 32 additions and 29 deletions
10
README.md
10
README.md
|
|
@ -1,3 +1,13 @@
|
|||
### 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.
|
||||
|
|
|
|||
2
debian/compat
vendored
2
debian/compat
vendored
|
|
@ -1 +1 @@
|
|||
10
|
||||
11
|
||||
|
|
|
|||
2
debian/control
vendored
2
debian/control
vendored
|
|
@ -3,7 +3,7 @@ Section: graphics
|
|||
Priority: optional
|
||||
Maintainer: Kilian Valkhof <kilian@kilianvalkhof.com>
|
||||
Build-Depends: debhelper (>=7), python3
|
||||
Standards-Version: 3.9.2
|
||||
Standards-Version: 4.3.0
|
||||
Homepage: http://trimage.org
|
||||
|
||||
Package: trimage
|
||||
|
|
|
|||
1
debian/pycompat
vendored
1
debian/pycompat
vendored
|
|
@ -1 +0,0 @@
|
|||
3
|
||||
1
debian/rules
vendored
1
debian/rules
vendored
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/make -f
|
||||
%:
|
||||
dh $@
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ Type=Application
|
|||
Exec=trimage
|
||||
Categories=Application;Qt;Graphics;
|
||||
StartupNotify=true
|
||||
|
||||
Keywords=compression;compressor;images;jpg;jpeg;png;web;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,6 @@ class ThreadPoolMixIn:
|
|||
def __init__(self, threadpool=None):
|
||||
if (threadpool == None):
|
||||
threadpool = ThreadPool()
|
||||
self.__private_threadpool = True
|
||||
else:
|
||||
self.__private_threadpool = False
|
||||
|
||||
self.__threadpool = threadpool
|
||||
|
||||
|
|
@ -52,10 +49,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ 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",
|
||||
|
|
@ -17,7 +16,7 @@ def check_dependencies():
|
|||
}
|
||||
|
||||
for elt in dependencies:
|
||||
retcode = safe_call(elt + exe + " " + dependencies[elt])
|
||||
retcode = safe_call(elt + " " + dependencies[elt])
|
||||
if retcode != 0:
|
||||
status = False
|
||||
print("[error] please install {}".format(elt), file=sys.stderr)
|
||||
|
|
|
|||
|
|
@ -304,8 +304,9 @@ 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() % i.filename_w_ext,
|
||||
'filename_w_ext': lambda i: self.statusStr().format(i.filename_w_ext),
|
||||
'oldfilesizestr': lambda i: human_readable_size(i.oldfilesize)
|
||||
if i.compressed else "",
|
||||
'newfilesizestr': lambda i: human_readable_size(i.newfilesize)
|
||||
|
|
@ -326,15 +327,15 @@ class ImageRow:
|
|||
def statusStr(self):
|
||||
"""Set the status message."""
|
||||
if self.image.failed:
|
||||
return "ERROR: %s"
|
||||
return "ERROR: {0}"
|
||||
if self.image.compressing:
|
||||
message = "Compressing %s..."
|
||||
message = "Compressing {0}..."
|
||||
return message
|
||||
if not self.image.compressed and self.image.recompression:
|
||||
return "Queued for recompression..."
|
||||
return "Queued for recompression {0}..."
|
||||
if not self.image.compressed:
|
||||
return "Queued..."
|
||||
return "%s"
|
||||
return "Queued {0}..."
|
||||
return "{0}"
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.d[key](self.image)
|
||||
|
|
@ -371,10 +372,9 @@ class Image:
|
|||
file)"
|
||||
self.reset()
|
||||
self.compressing = True
|
||||
exe = ".exe" if (sys.platform == "win32") else ""
|
||||
runString = {
|
||||
"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'"
|
||||
"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'"
|
||||
}
|
||||
# create a backup file
|
||||
backupfullpath = '/tmp/' + self.filename_w_ext
|
||||
|
|
@ -410,9 +410,6 @@ 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:
|
||||
|
|
|
|||
|
|
@ -125,6 +125,14 @@
|
|||
<ol>
|
||||
<li><code>yaourt -S trimage</code></li>
|
||||
</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>
|
||||
<ol>
|
||||
<li>Download the source via git or bzr (see repositories)</li>
|
||||
|
|
@ -142,8 +150,6 @@
|
|||
>
|
||||
</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>
|
||||
<p>Trimage should be able to run on Windows. <a href="mailto:help@trimage.org">Help us with this</a></p>
|
||||
-->
|
||||
|
|
|
|||
BIN
website/macos.png
Normal file
BIN
website/macos.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 835 B |
Loading…
Add table
Add a link
Reference in a new issue