Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 02-02-2016, 07:14 AM   #1
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
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"
Attached Files
File Type: zip ImageOptimizer_0.2.1-plugin.zip (525.8 KB, 642 views)

Last edited by Toxaris; 02-03-2016 at 12:45 PM.
Toxaris is offline   Reply With Quote
Old 02-02-2016, 08:09 AM   #2
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
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.
roger64 is offline   Reply With Quote
Advert
Old 02-02-2016, 09:08 AM   #3
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
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.
Toxaris is offline   Reply With Quote
Old 02-02-2016, 09:55 AM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
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.
eschwartz is offline   Reply With Quote
Old 02-02-2016, 08:35 PM   #5
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
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.
roger64 is offline   Reply With Quote
Advert
Old 02-03-2016, 02:21 AM   #6
rubeus
Banned
rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.
 
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.
rubeus is offline   Reply With Quote
Old 02-03-2016, 02:48 AM   #7
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
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.
Toxaris is offline   Reply With Quote
Old 02-03-2016, 05:15 AM   #8
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by roger64;3251189I installed [I
optipng[/I] 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...).
Can you please check the version number of jpegtran? Toxaris's plugin uses version 9, which uses a different syntax than the previous version which accepts only one file name parameter.

The old version has the following syntax:

Code:
usage: jpegtran [switches] [inputfile]
however, the new version uses the following syntax:

Code:
usage: jpegtran [switches] [inputfile] [outputfile]
If you use the new syntax with the old version, it enters an endless loop, which causes the plugin to hang.

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.
Doitsu is offline   Reply With Quote
Old 02-03-2016, 05:31 AM   #9
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
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 ~]$
I noted that the jpegtran in /usr has a 31k size, while the same in /opt has a 493k size. Should I exchange one for another?

Last edited by roger64; 02-03-2016 at 05:59 AM.
roger64 is offline   Reply With Quote
Old 02-03-2016, 06:01 AM   #10
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by Doitsu View Post
Can you please check the version number of jpegtran? Toxaris's plugin uses version 9, which uses a different syntax than the previous version which accepts only one file name parameter.

The old version has the following syntax:

Code:
usage: jpegtran [switches] [inputfile]
however, the new version uses the following syntax:

Code:
usage: jpegtran [switches] [inputfile] [outputfile]
If you use the new syntax with the old version, it enters an endless loop, which causes the plugin to hang.

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.
That is useful info, thanks! I can probably work with that. I haven't been able to test it myself, I spent all morning building Sigil 0.9.3 on my Linux machine and it still doesn't work (my fault probably...).
Toxaris is offline   Reply With Quote
Old 02-03-2016, 06:18 AM   #11
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
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]
new version:

Code:
            exe_path = os.path.join(SCRIPT_DIR,'win', 'jpegtran.exe')
                
        args = ['wine', exe_path]
Make sure not to mess with the indentation otherwise Python will display some cryptic error messages.
Doitsu is offline   Reply With Quote
Old 02-03-2016, 07:57 AM   #12
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
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
Then somewhere in your platform logic:
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)
Or something similar. I've not actually looked at the plugin code.

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.
DiapDealer is offline   Reply With Quote
Old 02-03-2016, 08:14 AM   #13
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Quote:
Originally Posted by Doitsu View Post
@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
This is to report success.
The images went from
146 to 127k
334 to 244k
863 to 812k
Attached Thumbnails
Click image for larger version

Name:	doitsu.png
Views:	406
Size:	26.0 KB
ID:	146016  
roger64 is offline   Reply With Quote
Old 02-03-2016, 08:29 AM   #14
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by roger64 View Post
This is to report success.
The images went from
146 to 127k
334 to 244k
863 to 812k
Keep in mind that your code changes will be lost if you ever re-install the plugin or upgrade.
DiapDealer is offline   Reply With Quote
Old 02-03-2016, 09:23 AM   #15
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Quote:
Originally Posted by DiapDealer View Post
Keep in mind that your code changes will be lost if you ever re-install the plugin or upgrade.
OK Thanks again.
roger64 is offline   Reply With Quote
Reply


Forum Jump


All times are GMT -4. The time now is 10:27 PM.


MobileRead.com is a privately owned, operated and funded community.