Compare commits

...

16 commits

Author SHA1 Message Date
Kilian Valkhof
ad74684272
Merge pull request #83 from Mte90/patch-2
Fix incomplete code of #77
2021-03-10 14:41:44 +01:00
Daniele Scasciafratte
031adf6054
Fix incomplete code of #77
I forgot to change the various `%s` in the pull request with the rest of the function or it will be print "Compressing %s".
2021-03-10 12:58:46 +01:00
Kilian Valkhof
f35be9c750
Merge pull request #82 from Mte90/patch-1
Fix #77
2021-03-08 14:03:34 +01:00
Daniele Scasciafratte
636b5a9750
Fix #77
This fix https://github.com/Kilian/Trimage/issues/77
As debian user this fix the issue for me
2021-03-04 19:26:55 +01:00
Kilian Valkhof
c21089f97b
Merge pull request #74 from carsonreinke/fix-typeerror
Missing format specifier for arguments of image status
2020-09-30 13:21:24 +02:00
Kilian Valkhof
f37c8b6ffc
Merge pull request #76 from featherbear/master
Remove unreachable shutdown code
2020-09-30 13:19:37 +02:00
Andrew Wong
8af532f25e Remove unreachable shutdown code
* Implementing `__del__` is discouraged
  * Imports (i.e. `import logging`) are cleaned up, leading to NoneType related errors
* When running via GUI mode, the shutdown code is never reached; we can let Python's internal GC clean everything
2020-09-30 19:22:46 +10:00
Carson Reinke
493a0e18d2 Missing format specifier for arguments of image status
Fixes https://github.com/Kilian/Trimage/issues/73
2020-06-23 15:30:34 -04:00
Kilian Valkhof
224f6b3503
Merge pull request #71 from kalmi/macos
Add macOS instructions to website
2020-04-24 09:35:43 +02:00
Kálmán Tarnay
c3244e19a6 add macos instructions to website 2020-04-23 17:44:12 +02:00
Kilian Valkhof
269e052ba4
Update README.md 2019-12-20 16:51:10 +01:00
Kilian Valkhof
49272e0d95
Merge pull request #66 from hosiet/patch-1
Fix trimage.desktop grammar
2019-12-04 09:52:17 +01:00
Boyuan Yang
1342503b54
Fix trimage.desktop grammar
According to https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s04.html , Keywords should be split by semicolons, not commas.
2019-12-03 17:00:44 -05:00
Kilian Valkhof
0cbbfcdfe8
Merge pull request #64 from Huluti/remove-win32-support
Remove win32 bytes following d6118b5
2019-10-14 17:00:36 +02:00
Hugo Posnic
9d6edd3847 Remove win32 bytes following d6118b5 2019-10-03 17:05:33 +02:00
kilian
9bdd44a4e4 further refinement/updates of debian folder 2019-03-12 12:36:32 +01:00
11 changed files with 32 additions and 29 deletions

View file

@ -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 # 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
View file

@ -1 +1 @@
10 11

2
debian/control vendored
View file

@ -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: 3.9.2 Standards-Version: 4.3.0
Homepage: http://trimage.org Homepage: http://trimage.org
Package: trimage Package: trimage

1
debian/pycompat vendored
View file

@ -1 +0,0 @@
3

1
debian/rules vendored
View file

@ -1,4 +1,3 @@
#!/usr/bin/make -f #!/usr/bin/make -f
%: %:
dh $@ dh $@

View file

@ -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;

View file

@ -30,9 +30,6 @@ 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
@ -52,10 +49,6 @@ 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

View file

@ -7,7 +7,6 @@ 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",
@ -17,7 +16,7 @@ def check_dependencies():
} }
for elt in dependencies: for elt in dependencies:
retcode = safe_call(elt + exe + " " + dependencies[elt]) retcode = safe_call(elt + " " + 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)
@ -43,4 +42,4 @@ def human_readable_size(num, suffix="B"):
if abs(num) < 1024.0: if abs(num) < 1024.0:
return "%3.1f%s%s" % (num, unit, suffix) return "%3.1f%s%s" % (num, unit, suffix)
num /= 1024.0 num /= 1024.0
return "%.1f%s%s" % (num, "Y", suffix) return "%.1f%s%s" % (num, "Y", suffix)

View file

@ -304,8 +304,9 @@ 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() % i.filename_w_ext, 'filename_w_ext': lambda i: self.statusStr().format(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)
@ -326,15 +327,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: %s" return "ERROR: {0}"
if self.image.compressing: if self.image.compressing:
message = "Compressing %s..." message = "Compressing {0}..."
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..." return "Queued for recompression {0}..."
if not self.image.compressed: if not self.image.compressed:
return "Queued..." return "Queued {0}..."
return "%s" return "{0}"
def __getitem__(self, key): def __getitem__(self, key):
return self.d[key](self.image) return self.d[key](self.image)
@ -371,10 +372,9 @@ 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" + exe + " -f --strip-all '%(file)s'", "jpeg": "jpegoptim -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'" "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 # create a backup file
backupfullpath = '/tmp/' + self.filename_w_ext backupfullpath = '/tmp/' + self.filename_w_ext
@ -410,9 +410,6 @@ 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:

View file

@ -125,6 +125,14 @@
<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>
@ -142,8 +150,6 @@
> >
</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>
--> -->

BIN
website/macos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B