ebook-convert - ebook-convert
ebook-convert input_file output_file [options]
Convert an e-book from one format to another.
input_file is the input and output_file is the output. Both must
be specified as the first two arguments to the command.
The output e-book format is guessed from the file extension of
output_file. output_file can also be of the special format .EXT where EXT is
the output file extension. In this case, the name of the output file is
derived from the name of the input file. Note that the filenames must not
start with a hyphen. Finally, if output_file has no extension, then it is
treated as a directory and an "open e-book" (OEB) consisting of
HTML files is written to that directory. These files are the files that
would normally have been passed to the output plugin.
After specifying the input and output file you can customize the
conversion by specifying various options. The available options depend on
the input and output file types. To get help on them specify the input and
output file and then use the -h option.
For full documentation of the conversion system see conversion
Whenever you pass arguments to ebook-convert that have
spaces in them, enclose the arguments in quotation marks. For example:
"/some path/with spaces"
The options and default values for the options change depending on
both the input and output formats, so you should always check with:
ebook-convert myfile.input_format myfile.output_format -h
Below are the options that are common to all conversion, followed
by the options specific to every input and output format.
- 輸入選項
- 輸出選項
- 介面外觀
- 探索式處理
- 搜尋與取代
- 結構偵測
- 目錄
- 詮釋資料
- 除錯
- --input-profile
- 指定輸入設定檔。輸入設定檔會提供轉換系統關於如何轉譯輸入文件中各類資訊的方式。例如關係解析度的長度(以像素計的長度)。選擇有:cybookg3,
cybook_opus, default, hanlinv3, hanlinv5, illiad, irexdr1000, irexdr800,
kindle, msreader, mobipocket, nook, sony, sony300, sony900
- --list-recipes
- 列出內建食譜名稱。您可以從內建食譜建立電子書,就像:ebook-convert
"Recipe Name.recipe" output.epub
- --output-profile
- Specify the output profile. The output profile tells the conversion system
how to optimize the created document for the specified device (such as by
resizing images for the device screen size). In some cases, an output
profile can be used to optimize the output for a particular device, but
this is rarely necessary. Choices are:cybookg3, cybook_opus, default,
generic_eink, generic_eink_hd, generic_eink_large, hanlinv3, hanlinv5,
illiad, ipad, ipad3, irexdr1000, irexdr800, jetbook5, kindle, kindle_dx,
kindle_fire, kindle_oasis, kindle_pw, kindle_pw3, kindle_voyage, kobo,
msreader, mobipocket, nook, nook_color, nook_hd_plus, pocketbook_900,
pocketbook_pro_912, galaxy, sony, sony300, sony900, sony-landscape,
sonyt3, tablet
輸入選項
用來控制匯入 mobi
的檔案處理選項
- --input-encoding
- 指定輸入文件的字元編碼。如果設定這個選項就會覆蓋任何由文件本身宣告的編碼。尤其當文件沒有宣告任何編碼或文件所宣告的編碼有誤時會很有幫助。
輸出選項
用來控制輸出 epub
處理的選項
- --dont-split-on-page-breaks
- Turn off splitting at page breaks. Normally, input files are automatically
split at every page break into two files. This gives an output e-book that
can be parsed faster and with less resources. However, splitting is slow
and if your source file contains a very large number of page breaks, you
should turn off splitting on page breaks.
- --epub-flatten
- 這個選項只有在您想把
EPUB 檔案用在 FBReaderJ
上時才需要。它會將
EPUB
內的檔案系統扁平化,將所有的檔案放在最上層。
- --epub-version
- The version of the EPUB file to generate. EPUB 2 is the most widely
compatible, only use EPUB 3 if you know you actually need it.
- 將產生 EPUB
文件的內容解壓縮到指定文件夾,請注意該文件夾會先被清空。
- --flow-size
- Split all HTML files larger than this size (in KB). This is necessary as
most EPUB readers cannot handle large file sizes. The default of 260KB is
the size required for Adobe Digital Editions. Set to 0 to disable size
based splitting.
- --no-svg-cover
- 不使用 SVG
做為書籍封面。這個選項是用在您的
EPUB 要用在不支援 SVG
的裝置上時,像是 iPhone
或 JetBook
Lite。沒有這個選項,在前述裝置上會以空白頁面來顯示封面。
- --preserve-cover-aspect-ratio
- 當使用 SVG
封面時,該選項會導致封面平鋪滿有效的屏幕區字段,但仍會保持它的縱寬比(寬度和高度的比例)。意思就是說,這可能會在圖像頂邊或底邊處產生空白邊界,但是圖像本身不會被扭曲變形。不選該選項的話,圖像可能會產生輕微的扭曲變形,但優點是不會出現空白邊界。
介面外觀
用來控制介面外觀輸出之選項
- --asciiize
- 把 Unicode 字元轉換爲 ASCII
表達型式。請謹慎使用這個功能,因爲它會把所有的
Unicode 字元取代爲 ASCII
字元。比如:它會把
"Михаил
Горбачёв"
取代為 "Mikhail
Gorbachiov"。並且當一個字元可能有多種表示方式時(比如中文和日文中一些共用的字元),
calibre
會根據當前設定的介面語言類型決定如何去轉換這類字元。
- --base-font-size
- The base font size in pts. All font sizes in the produced book will be
rescaled based on this size. By choosing a larger size you can make the
fonts in the output bigger and vice versa. By default, when the value is
zero, the base font size is chosen based on the output profile you
chose.
- --change-justification
- 更改文本對齊方式。
使用值"left"
將轉換資源中所有的文本爲左對齊。
(如:未對齊)
使用值"justify"
將轉換資源中所有的未對齊的文本爲對齊。使用值"original"(默認)則不更改源文件的對齊方式。請注意,僅部分輸出格式支持對齊方式。
- --embed-all-fonts
- Embed every font that is referenced in the input document but not already
embedded. This will search your system for the fonts, and if found, they
will be embedded. Embedding will only work if the format you are
converting to supports embedded fonts, such as EPUB, AZW3, DOCX or PDF.
Please ensure that you have the proper license for embedding the fonts
used in this document.
- --embed-font-family
- Embed the specified font family into the book. This specifies the
"base" font used for the book. If the input
document specifies its own fonts, they may override this base font. You
can use the filter style information option to remove fonts from the input
document. Note that font embedding only works with some output formats,
principally EPUB, AZW3 and DOCX.
- --expand-css
- By default, calibre will use the shorthand form for various CSS properties
such as margin, padding, border, etc. This option will cause it to use the
full expanded form instead. Note that CSS is always expanded when
generating EPUB files with the output profile set to one of the Nook
profiles as the Nook cannot handle shorthand CSS.
- CSS 樣式表或原生 CSS
的路徑。這個 CSS
會添加到來源檔案的樣式規則中,因此可以用來覆蓋那些規則。
- --filter-css
- 以逗號分隔的 CSS
屬性列表,將移除所有
CSS
樣式規則。這是非常有用的,如果存在的一些樣式信息,防止覆蓋您的的設備上的樣式信息。例如:字體系列,顏色,左邊距,右邊距
- --font-size-mapping
- 將 CSS
字型名稱映射到字型大小(以
pts
計)。舉例來說您可以設為
12,12,14,16,18,20,22,24。這些設定值的對應會從
xx-small 到
xx-large,最後一個大小就會是最大的字型。字型縮放演算法會使用這些大小來適當的縮放字型。預設使用的映射方式是以您所選擇的輸出設定檔為準。
- --keep-ligatures
- 保留輸入文檔中的「印刷連字」。所謂「印刷連字」是指對於ff,
fi,
fl之類的字母組合的一種特殊的展示方式。大部分閱讀器在使用默認字體時無法支持「印刷連字」,所以常常無法正常顯示。默認情況下,calibre會把「印刷連字」轉換成對應的字母組合。本選項用於選擇保留「印刷連字」。
- --line-height
- pt
行高。控制兩行高度距離。僅僅適用於未定義行高的元素。大多數情況下,最小行高值更加有用。默認不進行行高操控。
- --linearize-tables
- 有些設計不良的文件會使用表格來控制頁面文字的排版。在轉換這些文件時常會發生文字超出頁面的問題。這個選項會將表格的內容讀取出來,並重新以直線的方式呈現它。
- --margin-bottom
- Set the bottom margin in pts. Default is 5.0. Setting this to less than
zero will cause no margin to be set (the margin setting in the original
document will be preserved). Note: Page oriented formats such as PDF and
DOCX have their own margin settings that take precedence.
- --margin-left
- Set the left margin in pts. Default is 5.0. Setting this to less than zero
will cause no margin to be set (the margin setting in the original
document will be preserved). Note: Page oriented formats such as PDF and
DOCX have their own margin settings that take precedence.
- --margin-right
- Set the right margin in pts. Default is 5.0. Setting this to less than
zero will cause no margin to be set (the margin setting in the original
document will be preserved). Note: Page oriented formats such as PDF and
DOCX have their own margin settings that take precedence.
- --margin-top
- Set the top margin in pts. Default is 5.0. Setting this to less than zero
will cause no margin to be set (the margin setting in the original
document will be preserved). Note: Page oriented formats such as PDF and
DOCX have their own margin settings that take precedence.
- --minimum-line-height
- 最小行高,元素字體計算值的百分比。calibre
將保證行中所有元素至少有此高度,無論輸入文檔如何定義。設爲零即禁用。默認
120%。首選項中也有此設定,請注意。否則可能出現雙倍行高,達
240%。
- --smarten-punctuation
- Convert plain quotes, dashes and ellipsis to their typographically correct
equivalents. For details, see
https://daringfireball.net/projects/smartypants
- --transform-css-rules
- Path to a file containing rules to transform the CSS styles in this book.
The easiest way to create such a file is to use the wizard for creating
rules in the calibre GUI. Access it in the "Look &
feel->Transform styles" section of the conversion dialog.
Once you create the rules, you can use the
"Export" button to save them to a file.
探索式處理
使用一般樣式修改文件文字與結構。預設為停用。使用
--enable-heuristics
啟用。個別動作可以
--disable-* 選項停用。
- --html-unwrap-factor
- 決定一行字元是否能成爲一個新的段落的因子,有效值爲
0 到 1
之間的小數,預設值是
0.4,即略小於半行的長度。如果文檔中只有很少的行需要消除段落內換行,應當減小這個設定值。
搜尋與取代
以使用者定義的形式修改文件文字與結構。
- --search-replace
- Path to a file containing search and replace regular expressions. The file
must contain alternating lines of regular expression followed by
replacement pattern (which can be an empty line). The regular expression
must be in the Python regex syntax and the file must be UTF-8
encoded.
結構偵測
控制文件結構的自動偵測。
- --chapter
- An XPath expression to detect chapter titles. The default is to consider
<h1> or <h2> tags that contain the words
"chapter", "book",
"section", "prologue",
"epilogue" or "part" as
chapter titles as well as any tags that have
class="chapter". The expression used must evaluate
to a list of elements. To disable chapter detection, use the expression
"/". See the XPath Tutorial in the calibre User
Manual for further help on using this feature.
- --chapter-mark
- 指定如何標記偵測到的章節。「pagebreak」(分頁)會在每個章節前插入分頁符號。「rule」(水平線)會在每個章節前插入水平線。「none」(沒有)會停用章節的標記。「both」(兩者)則會同時加入分頁符號及水平線來標記章節。
- --insert-metadata
- Insert the book metadata at the start of the book. This is useful if your
e-book reader does not support displaying/searching metadata
directly.
- --remove-first-image
- Remove the first image from the input e-book. Useful if the input document
has a cover image that is not identified as a cover. In this case, if you
set a cover in calibre, the output document will end up with two cover
images if you do not specify this option.
- --start-reading-at
- An XPath expression to detect the location in the document at which to
start reading. Some e-book reading programs (most prominently the Kindle)
use this location as the position at which to open the book. See the XPath
tutorial in the calibre User Manual for further help using this
feature.
目錄
控制目錄頁的自動產生過程。預設情況下,如果來源檔案有目錄頁,它會優先使用而不自動產生。
- --level1-toc
- 指定應添加到目錄級別1的所有標籤的
XPath
表達式。如果指定此項,它會優先於其他自動檢測形式。可查閱
calibre 用戶手冊中的 XPath
向導。
- --level2-toc
- XPath
表達式指定所有標籤應添加在二級目錄表。每個條目加入到一級目錄條目下。請參閱
calibre 用戶手冊中 XPath
教學的例子。
- --level3-toc
- XPath
表達式指定所有標籤應添加在三級目錄表。每個條目加入到二級目錄條目下。請參閱
calibre 用戶手冊中 XPath
教學的例子。
- --max-toc-links
- 插入目錄頁的連結最大數量。設定為
0
代表停用。預設值:50。只有在偵測到的章節數目少於這個臨界值時才會把連結加入目錄頁中。
詮釋資料
設定輸出的詮釋資料選項
- --pubdate
- Set the publication date (assumed to be in the local timezone, unless the
timezone is explicitly specified)
- --series-index
- 這個書本在系列裡的索引。
除錯
轉換至偵錯模式的相關選項
- --verbose,
-v
- Level of verbosity. Specify multiple times for greater verbosity.
Specifying it twice will result in full verbosity, once medium verbosity
and zero times least verbosity.