本帖最後由 javacomhk 於 2022-8-1 06:03 編輯
在好讀 https://haodoo.net/ 下載的 epub 檔案很方便在手機閱讀,但可惜在 iOS/iPadOS/macOS 的 iBooks App 或 Android/iOS 手機上傳至 Google Play Book 都沒有封面,研究了一下,原來是可以修改加番,方法如下:
例如這本書 倪匡《藍血人》https://haodoo.net/?M=book&P=89
(1) 下載 89.epub 檔案儲存在 Downloads folder 下為
Downloads/89.epub
(2) 解壓 89.epub 在新 folder 89
Mac Terminal 指令為
- cd ~/Downloads
- unzip 89.epub -d 89
複製代碼
(3) 下載 https://haodoo.net/covers/89.jpg 封面圖片儲存在 Downloads folder 下為
Downloads/89/OEBPS/cover.jpg
(4) 修改 Downloads/89/OEBPS/content.opf 並增加以下藍色這3行- <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
- <dc:creator opf:role="aut">倪匡</dc:creator>
- <dc:title>藍血人</dc:title>
- <dc:language>zh-TW</dc:language>
- <dc:identifier id="BookId">www.haodoo.net</dc:identifier>
複製代碼 <meta name="cover" content="cover-image"/>- </metadata>
- <manifest>
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
複製代碼 <item id="cover-image" href="cover.jpg" media-type="image/jpeg"/>
<item id="cover" href="cover.html" media-type="application/xhtml+xml"/>- <item id="style" href="stylesheet.css" media-type="text/css" />
複製代碼 (5) 新增檔案 cover.html 為
Downloads/89/OEBPS/cover.html
內容為- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Cover</title>
- <style type="text/css"> img { max-width: 100%; } </style>
- </head>
- <body>
- <div id="cover-image">
- <img src="cover.jpg" alt="Book Cover"/>
- </div>
- </body>
- </html>
複製代碼 (6) 最後重新壓縮為89a.epub
Mac Terminal 指令為
- cd ~/Downloads/89
- zip -r ~/Downloads/89a.epub mimetype META-INF OEBPS
複製代碼
有興趣的書友,可下載看看加了封面的效果,這兩本有封面嘅 epub 都可在 iOS/iPadOS/macOS 的 iBooks App 或 iOS/Android 的 Google Play Book App 看。
倪匡《藍血人》 89a.epub
倪匡《追龍》144a.epub
倪匡《偷天換日》0319a.epub
如果嫌太麻煩,亦可以用一些 online tools convert 嘅,例如:https://www.onlineconverter.com/change-epub-cover
或者使用 shell script 去自動化加封面,參考
https://www.hkepc.com/forum/viewthread.php?fid=26&tid=2668529 |