11-25-2021, 02:29 PM | #1 |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
[Plugin] PNGOptimizer - Lossless/lossy image optimization
Released: November 26, 2021
Current Version: "0.1.2" This plugin uses optipng for lossless optimization and pngquant for lossy optimization of PNG files. Disclaimer: Since this plugin will replace the images in your ebook with optimized images, you might want to save your ePub or create a checkpoint before running this plugin. Credits BeckyEbook created the plugin icon. System requirements This plugin requires at least Sigil 0.9.8. If you uncheck the Use Bundled Python option, you'll also need to install Python 3. Linux users will also need to install optipng (Debian Arch) and pngquant, (Debian, Arch). Installation 1. Select Manage Plugins from the Plugins menu and enable the Use Bundled Python option, if it isn't already enabled (or grayed out). 2. Click Add Plugin and select PNGOptimizer_v0.1.2.zip. This will install the plugin, which you can select via Plugins > Edit > PNGOptimizer. Settings To turn on lossy optimization, edit PNGOptimizer.json and change the lossless value to false: Code:
"lossless": false, Code:
"quality": "0-100", Windows users can also press WIN+R, paste %localappdata%\sigil-ebook\sigil\plugins_prefs\PNGOptimizer into the Run dialog box and hit Enter. License: GNU General Public License v3 (GPL-3) Last edited by Doitsu; 11-26-2021 at 02:30 PM. |
11-26-2021, 11:02 AM | #2 |
Connoisseur
Posts: 99
Karma: 10
Join Date: Jun 2014
Location: Poland, Żory
Device: Prestigio PER3464B, Onyx Lynx, Lenovo S5000 i Tab4-8"
|
I installed the JPEGOptimizer and PNGOptimizer plugins and they didn't work properly.
I have received such reports: - for the JPEGOptimizer Status: failed Lossless optimization: cover.jpeg ... Original file size: 144.70KB Traceback (most recent call last): File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 142, in launch self.exitcode = target_script.run(container) File "C:\Users\xxxx\AppData\Local\sigil-ebook\sigil\plugins\JPEGOptimizer\plugin.py", line 119, in run stdout, stderr, returncode = jo_wrapper(*args) File "C:\Users\xxxx\AppData\Local\sigil-ebook\sigil\plugins\JPEGOptimizer\plugin.py", line 35, in jo_wrapper return stdout.decode('utf-8'), stderr.decode('utf-8'), returncode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 14: invalid start byte Error: 'utf-8' codec can't decode byte 0xb3 in position 14: invalid start byte - for the PNGOptimizer Status: failed Lossless processing: exlibris.png ... Original file size: 11.21KB Traceback (most recent call last): File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 142, in launch self.exitcode = target_script.run(container) File "C:\Users\xxxx\AppData\Local\sigil-ebook\sigil\plugins\PNGOptimizer\plugin.py", line 159, in run stdout, stderr, returncode = png_wrapper(*args) File "C:\Users\xxxx\AppData\Local\sigil-ebook\sigil\plugins\PNGOptimizer\plugin.py", line 51, in png_wrapper return stdout.decode('utf-8'), stderr.decode('utf-8'), returncode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 29: invalid start byte Error: 'utf-8' codec can't decode byte 0xb3 in position 29: invalid start byte I have Sigil 1.8 and Windows 10 Home installed. My mother tongue is polish. Doitsu, can you help me? I apologize for my poor English, but I have a translator. bravosx |
Advert | |
|
11-26-2021, 11:09 AM | #3 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
A guess ... your stdin and stdout are not set to use the utf-8 character encoding but instead is set to some other encoding? Perhaps the encoding for an image file name? But just guessing here based on the error message. I am not a Windows person so I do not know how cross process stdin/stdout io is done.
|
11-26-2021, 11:09 AM | #4 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Added to the Sigil Plugin Index.
|
11-26-2021, 11:16 AM | #5 | |
Connoisseur
Posts: 99
Karma: 10
Join Date: Jun 2014
Location: Poland, Żory
Device: Prestigio PER3464B, Onyx Lynx, Lenovo S5000 i Tab4-8"
|
Quote:
bravosx |
|
Advert | |
|
11-26-2021, 11:21 AM | #6 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
|
11-26-2021, 12:21 PM | #7 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
I'll run some tests and try to update the code to fix this issue. In the meantime, try changing the following part in both plugin files: Code:
return stdout.decode('utf-8'), stderr.decode('utf-8'), returncode Code:
return stdout.decode('utf-8', 'ignore'), stderr.decode('utf-8', 'ignore'), returncode Last edited by Doitsu; 11-26-2021 at 12:47 PM. |
|
11-26-2021, 01:09 PM | #8 | |
Connoisseur
Posts: 99
Karma: 10
Join Date: Jun 2014
Location: Poland, Żory
Device: Prestigio PER3464B, Onyx Lynx, Lenovo S5000 i Tab4-8"
|
Quote:
In the PNGOptimizer plug, I changed the line as you suggested and it worked fine. I received this message: Status: success Lossless processing: exlibris.png ... Original file size: 11.21KB Optimized file size: 9.73KB (86.75%) Image replaced with optimized image. Lossless processing: logo_mon.png ... Original file size: 3.12KB Optimized file size: 2.02KB (64.63%) Image replaced with optimized image. Processing time: 0:00:00.15 Total reduction: 2.59KB Done. Click OK to close the Plugin Runner window. The JPEGOptomizer plug also worked (I made a mistake before). I have received a feedback report: Status: success Lossless optimization: cover.jpg ... Original file size: 137.45KB Optimized file size: 129.08KB (93.90%) Image replaced with optimized image. Total reduction: 8.38KB Done. Click OK to close the Plugin Runner window. I am using Windows 10 Home 21H1 OS build 19043.1348 Thank you very much, your prescription helped. regards bravosx Last edited by bravosx; 11-26-2021 at 01:40 PM. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Plugin] JPEGOptimizer - Lossless image optimization | Doitsu | Plugins | 5 | 12-06-2022 12:03 PM |
Strange behavior of image lossless compression since it has been "fixed" | Francois_C | Editor | 2 | 05-18-2018 03:23 AM |
Using image in plugin code | Jellby | Development | 7 | 03-11-2014 10:56 PM |
Conversion Lossy or Lossless? | KrowNB | Conversion | 6 | 03-11-2011 08:31 AM |
Image optimization for Kindle 2 | thelostemperor | Amazon Kindle | 10 | 03-13-2009 05:34 PM |