02-02-2016, 07:14 AM | #1 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
ImageOptimizer
This is an edit plugin that should work on Windows, Linux and OSX.
It is a wrapper plugin around several image optimization programs. It can optimize optimize JPG, PNG and GIF images. The programs used are equal to my ePUBOptimizer program, but this plugin is Python only and will not subset fonts. Prereqs: Sigil 0.8.2 (or higher). On Sigil 0.9.3 and higher it will make use of autostart and autoclose. Prerequisite is that on Linux the programs jpegtran/optipng/gifsicle are required. For Windows and OSX these are included. The program jpegtran is included in libjpeg-progs on Linux. Upon first execution a preference file will be created in the plugin_prefs directory. If required another version of jpegtran can be entered or the usage of wine, and thereby the included windows executables, can be activated. By default the standard jpegtran will be used and is wine not enabled. Current Version: "0.2.1" Last edited by Toxaris; 02-03-2016 at 12:45 PM. |
02-02-2016, 08:09 AM | #2 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Hi
Thank very much you for porting this plugin to Sigil. I tried it on Archlinux 64 bits with Sigil 9.2. I installed optipng and gifsicle. However I did not find jpegtran or libjpeg-progs (they probably have other names) and so my trial for today was unconclusive (the program kept waiting left-right-left-right...). I had good hopes since I use Imagemagick 6.9.3. but no. |
Advert | |
|
02-02-2016, 09:08 AM | #3 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Roger, a quick search for Archlinux tells me that the library libjpeg-turbo contains jpegtran. That should do the trick.
It is strange the program kept waiting, it should just report the return code if the program is not found. |
02-02-2016, 09:55 AM | #4 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
roger64 -- in future, an excellent way to find needed programs on Arch Linux is to use "pkgfile".
libjpeg-turbo is required by qt5-base, so it is already an indirect dependency of sigil. |
02-02-2016, 08:35 PM | #5 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Thanks for pkgfile. I did not not know.
I installed this libjpeg-turbo to learn that.. it was already installed. So, the situation is the same: the plugin does not work for me on one valid EPUB3 file with three jpegs. It keeps "running" and never stops. |
Advert | |
|
02-03-2016, 02:21 AM | #6 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Can you see in the process list the hpegtrans program running? So maybe the plugin is just waiting for the exteranl program which is waiting for whatever.
|
02-03-2016, 02:48 AM | #7 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
I will check again on my Linux machines.
|
02-03-2016, 05:15 AM | #8 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
The old version has the following syntax: Code:
usage: jpegtran [switches] [inputfile] Code:
usage: jpegtran [switches] [inputfile] [outputfile] AFAIK, libjpeg-turbo is a fork of jpegtran that uses the old syntax. I.e. you can't use it to optimize .jpeg files under Linux. |
|
02-03-2016, 05:31 AM | #9 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
@Doitsu
I don't know if this answers your question. It's cryptic for me Code:
[roger@anterg ~]$ jpegtran -v libjpeg-turbo version 1.4.2 (build 20151205) Copyright (C) 1991-2012 Thomas G. Lane, Guido Vollbeding Copyright (C) 1999-2006 MIYASAKA Masaru Copyright (C) 2009 Pierre Ossman for Cendio AB Copyright (C) 2009-2015 D. R. Commander Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies) Copyright (C) 2013-2014 MIPS Technologies, Inc. Copyright (C) 2013 Linaro Limited Emulating The Independent JPEG Group's software, version 8d 15-Jan-2012 Code:
[roger@anterg ~]$ locate jpegtran /home/roger/.local/share/sigil-ebook/sigil/plugins/ImageOptimizer/osx/jpegtran /home/roger/.local/share/sigil-ebook/sigil/plugins/ImageOptimizer/win/jpegtran.exe /home/roger/.local/share/sigil-ebook/sigil/plugins/ePUBOptimizer/osx/jpegtran /home/roger/.local/share/sigil-ebook/sigil/plugins/ePUBOptimizer/win/jpegtran.exe /opt/calibre/bin/jpegtran /usr/bin/jpegtran /usr/share/man/man1/jpegtran.1.gz [roger@anterg ~]$ Last edited by roger64; 02-03-2016 at 05:59 AM. |
02-03-2016, 06:01 AM | #10 | |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Quote:
|
|
02-03-2016, 06:18 AM | #11 |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
@roger64: The jpegtran version that you've installed is the fork that I mentioned that still uses the old syntax and will most likely not work.
I'd recommend the following workaround: 1. Install the Wine windows emulator, if you haven't already done so. 2. Change lines 83 and 85 in plugin.py as follows: old version: Code:
exe_path = 'jpegtran' args = [exe_path] Code:
exe_path = os.path.join(SCRIPT_DIR,'win', 'jpegtran.exe') args = ['wine', exe_path] |
02-03-2016, 07:57 AM | #12 |
Grand Sorcerer
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Why not allow the user to override paths to external programs via the prefs json?
Code:
prefs = bk.get_prefs() #Default to none if 'jpegtrans_path' not in prefs prefs['jpegtran_path'] = None # Default to false if 'use_wine' not in prefs prefs['use_wine'] = False Code:
islinux = sys.platform.startswith('linux') if islinux and prefs['jpegtran_path'] is not None: exe_path = prefs['jpegtran_path'] else: exe_path = 'jpegtran' if islinux and prefs['use_wine']: args = ['wine', path_to_included_windows_exe] else: args = [exe_path] ''' Plugin processing ''' # Need a call to savePrefs so the json file gets created after first run bk.savePrefs(prefs) That way the user can just modify the json prefs file to 1) point to a newer version of jpegtran (which I'm betting calibre's is); or 2) use wine to run the included Windows version. Last edited by DiapDealer; 02-03-2016 at 08:36 AM. |
02-03-2016, 08:14 AM | #13 | |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Quote:
The images went from 146 to 127k 334 to 244k 863 to 812k |
|
02-03-2016, 08:29 AM | #14 |
Grand Sorcerer
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
|
02-03-2016, 09:23 AM | #15 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
|