Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-02-2023, 11:44 PM   #16
bread22
Junior Member
bread22 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2023
Device: Kindle Paperwhite
How do I save after all actions are done? It seems there is no "save" action and I have to save it manually by clicking the button. Which also make it useless with Action Chain when I try to batch process multiple book from main GUI, nothing is saved.

Thanks.
bread22 is offline   Reply With Quote
Old 03-05-2023, 02:28 AM   #17
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,092
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by bread22 View Post
How do I save after all actions are done? It seems there is no "save" action and I have to save it manually by clicking the button. Which also make it useless with Action Chain when I try to batch process multiple book from main GUI, nothing is saved.

Thanks.
When used with Actions Chains, it automatically saves all the changes. It also keeps a backup of the old file (there is a setting to turn this off).
capink is offline   Reply With Quote
Advert
Old 03-06-2023, 03:50 PM   #18
bread22
Junior Member
bread22 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2023
Device: Kindle Paperwhite
Quote:
Originally Posted by capink View Post
When used with Actions Chains, it automatically saves all the changes. It also keeps a backup of the old file (there is a setting to turn this off).
Yes, I found that it does save when I run action chains.
But the issue I have now is that the result is different when I run Action Chains from when I run Editor Chains. Even though the only step in Action Chains is calling the exact chain in Editor Chains.

The chain is quite simple

- Conver to epub3
- embed fonts
- subset fonts
- fix HTML
- beautify all


If I run Editor chains, everything is executed as expected. After the chain I run "fix HTML/beautify" from menu and nothing will be changed.

But if I run Action Chains, fix HTML and beautify doesn't seem to work. Once it completes, I edit the book and run fix HTML/beautify from menu, there are still a lot changes.
bread22 is offline   Reply With Quote
Old 03-10-2023, 03:52 PM   #19
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,092
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
The difference between what happens when in editor mode and what happens in Action Chains, is caused by the fact the calibre parses html differently when in editor mode. When in editor mode, calibre will remove some meta tags, that are otherwise not deleted. I don't know the exact reasons for why calibre does this, but I trust that Kovid has done this for good reasons.

It is trivial (in terms of code) to change the plugin to have it perform exactly the same in both modes. But I don't know if this would break some other action or functionality of the plugin. What is not trivial, however, is repeating all the hours of testing that has gone into the plugin to ensure nothing else breaks because of this change, which is not something I am prepared to do.

Anyway, The difference in output is not significant (some meta tags and whitespace) and does not affect the end result. The bottom line is that the html files are beautified and fixed in both modes. If you are bent on having them exactly the same, try the chain attached below, which deletes the culprit meta tags. If you are still not getting the result you want, there is nothing to be done as the changes required for this require huge amount of testing that I am not ready to do.

Spoiler:

*** This part is intended as a documentation of the issue for the future reference. ***

When coding the batch mode of the plugin (which is called from Action Chains and command line), I preferred to to use the same code that calibre's polish functionality uses:

from calibre.ebooks.oeb.polish.container import get_container
container = get_container(book_path)

On contrast, the editor uses a similar function also called get_container() that will additionaly set a variable called tweak_mode as True

from calibre.gui2.tweak_book.boss import get_container
container = get_container(book_path)

As the result of this, html files are parsed differently based on the value of tweak_mode variable. See ContainerBase.parse_xhtml()
Attached Files
File Type: zip Misc Actions.zip (678 Bytes, 116 views)
capink is offline   Reply With Quote
Old 05-21-2023, 05:46 PM   #20
azuravian
Enthusiast
azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 31
Karma: 30848
Join Date: Feb 2012
Device: Kobo Aura One
This is fantastic. I have created a reduce file size chain with subset embedded fonts, remove unused CSS, and compress pictures down to 50%.

From within the editor, it makes the changes, I save, and I can immediately see the reduction in filesize. When running from Action Chains, it runs and completes and does reduce the size as expected, but the change in filesize is not shown. Even closing and reopening Calibre does not show the change in size. I have to edit the book, add and remove a space to a single file and then save to see the results of the chain.
azuravian is offline   Reply With Quote
Advert
Old 05-22-2023, 05:27 AM   #21
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,092
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Version 0.8.7

  • Fix: When running from Action Chains, notify calibre to update filesizes of modified files.
capink is offline   Reply With Quote
Old 05-22-2023, 02:06 PM   #22
azuravian
Enthusiast
azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.azuravian can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 31
Karma: 30848
Join Date: Feb 2012
Device: Kobo Aura One
Quote:
Originally Posted by capink View Post
  • Fix: When running from Action Chains, notify calibre to update filesizes of modified files.
Thank you. Works perfectly!
azuravian is offline   Reply With Quote
Old 08-29-2023, 03:21 PM   #23
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,092
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Version 0.8.9
  • New Action "Run Command"

This action allows you to run a command on files inside the book. To better illustrate this I will give an example of chain I made which uses ImageMagick convert command to convert jpg and png pictures to a lower quality jpg and changes the colorspace to gray. The action will run this command for the selected files, and replace them with the resulting files. Below is a screenshot of the configuration for this action.

Notes:
  • You must have the commmand installed on your system.
  • Note the use of the placeholders: {inputfile}, {outputfile}.
  • If the resulting output files are of different extension the input files as in the example in the screenshot, you must specify the output extension so that it is appended to the {outputfile}. Also the original filenames inside the book will changed to reflect the new extension.
  • The configuration gives you the option to specify what files to include or exclude. Note that I included all png and jpg images except those that contain the name cover.
  • Using the combination of Action Chains and Editor Chains, you can run this action on multiple books. Refer to the first post of this thread for more on how to combine the two plugins.
Attached Thumbnails
Click image for larger version

Name:	screen.jpg
Views:	112
Size:	106.3 KB
ID:	203664   Click image for larger version

Name:	run_cmd_windows.png
Views:	36
Size:	48.3 KB
ID:	205920  

Last edited by capink; 01-20-2024 at 02:26 PM.
capink is offline   Reply With Quote
Old 08-31-2023, 12:56 PM   #24
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
!! Congratulations!!
For me it will be very useful.
But I have ImageMagick installed correctly (although my knowledge of its use is zero) on Windows 10.
I have copied your screenshot as it is and the thing does not work.
I'm guessing it has to do with {inputfile} and {outputfile}, and it would be great if you could tell me what to do.
Thanks in advance.
jbacelar is offline   Reply With Quote
Old 08-31-2023, 03:40 PM   #25
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,092
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Unfortunately I cannot test on Windows. A quick search suggests that maybe the command on Windows should be:
Code:
magick convert path/to/input/image -quality 80 -colorspace gray /path/to/output/image
If the above command does not work on Windows, then the problem is not in the plugin and you have to figure the right command yourself.

If the command runs successfully on your machine, run it in Editor Chains and post the debug log. You can run the editor in debug mode using the following command:
Code:
calibre-debug --edit-book

Last edited by capink; 08-31-2023 at 05:15 PM.
capink is offline   Reply With Quote
Old 08-31-2023, 06:02 PM   #26
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
Unfortunately it doesn't work with the new command either.
Attached (in case it is of any use) the debug log.
Thanks again for the try.

Spoiler:

C:\Users\JB>calibre-debug --edit-book
DEBUG: 0.0 GetFileName::__init__.py - loading translations
QPA platform: windows
devicePixelRatio: 1.25
logicalDpi: 96.0 x 96.0
physicalDpi: 75.3173745173745 x 75.25925925925925
ApplicationPaletteChange event ignored
Using calibre Qt style: True
ApplicationPaletteChange event received
qt.webenginecontext:
GL Type: disabled
Surface Type: OpenGL
Surface Profile: CompatibilityProfile
Surface Version: 4.5
QSG RHI Backend: OpenGL
Using Supported QSG Backend: yes
Using Software Dynamic GL: no
Using Multithreaded OpenGL: yes
Init Parameters:
* application-name calibre
* browser-subprocess-path C:\Program Files\Calibre2\app\bin\QtWebEngineProcess.exe
* disable-features ConsolidatedMovementXY,InstalledApp,BackgroundFetc h,WebOTP,WebPayments,WebUSB,PictureInPicture
* disable-gpu
* disable-speech-api
* enable-features NetworkServiceInProcess,TracingServiceInProcess
* enable-threaded-compositing
* in-process-gpu
* use-gl disabled
Editor chains: _get_plugins_resources(): start
Editor Chains: _get_plugins_resources(): finished
calling method (on_modules_update) of obj (Tag Actions)
Editor Chains: Tag Actions: running on_modules_update()
calling method (on_modules_update) of obj (Style Actions)
Editor Chains: Style Actions: running on_modules_update()
Editor chains: _call_plugins_on_modules_update(): start
Editor Chains: _call_plugins_on_modules_update(): finished
Editor Chains: SettingsWidgetDialog: Falling back to old constructor call
Editor Chains: Starting chain: Comprimir imágenes
Editor Chains: Comprimir imágenes: starting action No. 1: Run Command
Command error: Return code is 1 when running command for file: OEBPS/Images/autor.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_01.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_02.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_03.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_04.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_05.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_06.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_07.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_08.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_09.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_10.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_11-1.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_11-2.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_12.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_13.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_14.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_15.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_16.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_17.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_18.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_19.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_20.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_21.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/Figura_22.jpg
Command error: Return code is 1 when running command for file: OEBPS/Images/EPL_logo.png
Command error: Return code is 1 when running command for file: OEBPS/Images/ex_libris.png
Editor Chains: chain (Comprimir imágenes) finished in: 0:00:00.385428
jbacelar is offline   Reply With Quote
Old 08-31-2023, 06:42 PM   #27
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,092
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
That's a problem with running the command on Windows. I suggest you open the Windows command line (cmd) and run this command on a test image:

Code:
magick convert path/to/input/image -quality 80 -colorspace gray /path/to/output/image
Take whatever error messages arising from the command to the ImageMagick forums to get help on what went wrong.

Once you get the command working on Windows command line (using cmd.exe), we would be able to investigate whatever problems arises with the plugin.

Last edited by capink; 08-31-2023 at 07:16 PM.
capink is offline   Reply With Quote
Old 09-01-2023, 03:37 AM   #28
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
Code:
C:\Users\JB>magick convert path/to/input/wizard.jpg -quality 80 -colorspace gray /path/to/output/wizard.jpg
convert: unable to open image 'path/to/input/wizard.jpg': No such file or directory @ error/blob.c/OpenBlob/3569.
convert: no images defined `/path/to/output/wizard.jpg' @ error/convert.c/ConvertImageCommand/3354.
Instead with this one:

Code:
C:\Users\JB>magick convert wizard.jpg -quality 80 -colorspace gray wizard.jpg
It has worked perfectly.
jbacelar is offline   Reply With Quote
Old 09-01-2023, 12:13 PM   #29
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,092
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
both /path/to/input and /path/to/output are meant to be replaced with actual paths on your system. If you are doing this and the command is still producing errors, this would be some trouble with ImageMagick on Windows that I wouldn't be be to assist much with. Your best bet, as I said, would be the ImageMagick forums, because for the plugin to work with command, it must accept the full paths.
capink is offline   Reply With Quote
Old 09-07-2023, 03:18 PM   #30
alastortenebris
Junior Member
alastortenebris began at the beginning.
 
alastortenebris's Avatar
 
Posts: 6
Karma: 10
Join Date: May 2023
Device: Android
I'm getting the same issue too (Windows 11).

I have tried running clean-css cli with both directly and with a bat script I made that takes a css file as an input, and neither do anything.

My error log shows the same thing, "Command error: Return code is 1 when running command for file: {insert file name here}"
alastortenebris is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Editor Plugin] LanguageTool Doitsu Plugins 17 04-20-2024 02:21 PM
[Editor Plugin] EpubCheck Doitsu Plugins 146 09-07-2023 01:43 PM
[Editor Plugin] - Enabling 'Customize plugin' dialog directly from the Editor thiago.eec Development 7 01-09-2019 08:05 PM
Sample Plugin for the Editor DiapDealer Editor 77 12-10-2014 07:16 AM
Editor plugin question DiapDealer Development 2 07-28-2014 10:23 PM


All times are GMT -4. The time now is 05:43 AM.


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