![]() |
#1 |
Enthusiast
![]() Posts: 33
Karma: 10
Join Date: Apr 2017
Device: PC
|
DOCX Output setting for image compression
When creating a DOCX from any other eBook format, the following setting is generated by Calibre:
File -> Options -> Advanced -> Image Size and Quality Under this section, there is a checkbox for: "Do not compress images in file" This option is unchecked, meaning images are compressed. I would like Calibre to be able to generate a DOCX with this option checked. Where in the source is this setting generated in Calibre? Note that my Normal.dotm template has this option checked, so any blank DOCX I create will have this option checked. But those DOCX coming from Calibre will not. |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There is no such setting. I am guessing the setting you are referencing comes from Word and it controls how word will compress images when the doc file is saved in it. As far as I know thisis not a setting that can be controlled in the DOCX format itself.
|
![]() |
![]() |
![]() |
#3 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,777
Karma: 30237628
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Into a blank document which has your preferred settings i.e. "Do not compress images in file" is checked, try using Word->Insert->Object>Text File on the DOCX that calibre creates.
LO Writer probably has something similar. Not Tested BR |
![]() |
![]() |
![]() |
#4 | |
Enthusiast
![]() Posts: 33
Karma: 10
Join Date: Apr 2017
Device: PC
|
Quote:
I seem to have asked this question about eight years ago. Whoops! Anyway, for the past eight years, I have been modifying a copy of the code and linking to it. Not many changes are required. Six lines of code in one file and one line of code in another file (plus one line for __init__.py to print a message indicating I am using a code-tweaked version). This code is needed because Calibre does not include the standard settings.xml file within the created DOCX file structure. My main issue is every time there is a new version of Calibre released, I have to download and update the code. So, while I can get Calibre updated that was installed into Windows regularly, I'm still linked to an older version of Calibre until I re-download the matching code, make the appropriate changes, and adjust the environment variable in Windows. Not the end of the world. This would be easier if I could do this in a Word macro. Outside of a brute-force method of inserting the document into a blank document, I don't see how to do this in a macro. I toyed with the idea of modifying the XML files within the DOCX, but automating it seems to be beyond my pay grade. Thanks for the help. |
|
![]() |
![]() |
![]() |
#5 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,777
Karma: 30237628
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Pretty sure you could do it via a Word COM add-in, I'm running a couple of such addins — EPUB Tools and Transtools.
EPUB Tools was last released in Mar 2018, not only does it work on latest Office 365… it works better than it ever did. Function-wise, all the features I use work just like they always did, performance-wise: faster, smoother, less likely to wedge… in fact it's ages since it did. BR |
![]() |
![]() |
![]() |
#6 | |
Enthusiast
![]() Posts: 33
Karma: 10
Join Date: Apr 2017
Device: PC
|
Quote:
When settings.xml is missing from the DOCX, like it is for those generated by Calibre, Word will populate a default settings.xml file within the DOCX file structure that gets written when the document is saved. It also adds an entry to \word\_rels\document.xml.rels to link to the settings.xml file. What I don't know is where Word gets the default format for settings.xml when it does not exist in a Word document that is opened and later saved. My Normal.dotm has a settings.xml file with "<w:doNotAutoCompressPictures/>" buried in the XML. When a new Word document is created via Windows Explorer or by opening a blank document in Word, settings.xml is carried over with the above XML included. If Calibre ever adds the settings.xml file to the output DOCX file structure, then my future edits would be isolated to the single code addition to input the above option. As it is, I think my edits are overlooking a few details when inserting settings.xml into the DOCX file structure so that I can set the above option. Okay, I think I've beaten this into the ground enough. Last edited by mfm-ca; 08-07-2025 at 12:04 PM. |
|
![]() |
![]() |
![]() |
#7 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,777
Karma: 30237628
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
I'm pretty sure I would make use of it. I note that calibre does inject a webSettings.xml file into the DOCX files it creates. BR |
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
webSettings are needed for the actual document content, for instance calibre includes it to allow use of PNG files. settings is not needed for content, for example, the OP's request is for a setting to control the behavior of Word, a particular program used to view DOCX files. As a general rule I avoid this kind of thing as that way lies madness.
I could of course allow users to import their own settings.xml during conversion, but that is an extremely niche feature unuseable by most people, just have a look at the kinds of things present in settings.xml, for example: https://python-docx.readthedocs.io/e.../settings.html |
![]() |
![]() |
![]() |
#9 | |
Enthusiast
![]() Posts: 33
Karma: 10
Join Date: Apr 2017
Device: PC
|
Quote:
I have two options: (1) Keep modifying the Calibre code to insert the settings.xml code along with the code for compressing images option. It is an annoyance, but it works. My only concern is I am not sure I am addressing all of the code that needs to be touched. I've read about "serializing" the XML files, whatever that means. I am currently not doing that with settings.xml, but the DOCX files have been loading into Word without errors and my option has been set. I know enough to be dangerous, but nowhere near enough to be an expert. (2) Within a batch file: (a) let the unmodified Calibre software generate the DOCX; (b) open the DOCX in Word and force a SaveAs which would get the document updated to my version of Word plus insert a default settings.xml file; (c) use a tool like 7-Zip to overwrite the settings.xml file in the DOCX with one that has the compressing images option; (d) execute my normal Word macros to run a first-pass to clean up the DOCX formatting and insert my preferred style set and good quality cover image. |
|
![]() |
![]() |
![]() |
#10 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,777
Karma: 30237628
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
I don't convert to DOCX often enough to warrant automation. I attach one of three of my templates to DOCX produced by calibre and take it from there.
However, go into CoPilot and ask: Quote:
BR Last edited by BetterRed; 08-08-2025 at 06:16 AM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre input docx output epub image issue | JeanDolphin | Conversion | 1 | 12-24-2023 09:40 PM |
Cover image compression | ownedbycats | Calibre | 7 | 01-23-2021 08:41 AM |
2.47 - Image compression not working | jlynton | Calibre | 0 | 12-25-2015 08:40 AM |
MOBI Output Compression? | sirbruce | Calibre | 6 | 06-14-2009 07:10 PM |
MOBI Output Compression? | sirbruce | Calibre | 4 | 03-27-2009 10:51 AM |