有没有办法将 epub 格式转换为图像?
我需要一个工具来以编程方式将 epub 文件转换为一系列图像。输出应该看起来像在规范设备(对于此应用程序,iPad)上截取的屏幕截图。我还没有找到任何工具可以做这样的事情。
所以我真正想要的 (1) 是一个可以做到这一点的工具。但假设我是正确的,不存在这样的工具,是否有(2)一个库(最好是 Perl 模块,但我不是那么挑剔)可以读取和渲染 ePub?
显然,我自己开发的工具可以组合用于解压缩、读取 html、读取 xml、将所有内容按正确顺序排列以及在某些限制内渲染 html 的工具。虽然我不想这样做,但如果这是唯一的选择,我将不得不继续寻找一个工具来完成最后一部分,否则我也必须创建它。
是否有关于 (1) 的任何线索,或者是否有 (2) 的线索?
I need a tool to programmatically convert epub files to a series of images. The output should look like screenshots taken on a canonical device (for this application, an iPad). I haven't been able to find any tools that do something like this.
So what I'd really like (1) is a tool that does that. But assuming that I'm correct that no such tool exists, is there (2) a library (preferably a Perl module, but I'm not that picky) that will read and render ePub?
Obviously, rolling my own I could combine tools for unzipping, reading html, reading xml, putting everything in the right order, and rendering html within certain constraints. Though I'd rather not do that, and if that's the only option I'll have to go on to look for a tool that will do the last part of that or I'll have to create that too.
Any leads on (1), or failing that (2)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
抱歉,如果我要输入的内容只是我的疯狂言论——事实上,我很确定是这样——但也许这样的东西可能会起作用,我有兴趣知道它有多好可能适合您:
使用 Frank (https://github.com/moredip/Frank) 控制 Mac 上的 iOS 模拟器。对其进行编程以打开您需要的 EPUB 文档。
那么您所需要的只是自动拍摄屏幕截图。显然,这些看起来就像是在 iPad(或者 iPhone,如果您愿意的话,iOS 模拟器同时执行这两种操作)中渲染 EPUB。
自动化屏幕截图可能可以使用 AppleScript 来完成,尽管困难的部分可能是让它与 Frank 对话。最坏的情况是,您可以告诉 Frank 在加载每个页面后暂停 5 秒,并告诉 AppleScript 每五秒截取一次屏幕截图。这很糟糕,但如果你绝望的话,它会完成的。弗兰克也有可能以某种方式让屏幕截图发生——我还没有使用它足够多的东西来知道。
Apologies if what I'm about to type is just crazy-talk on my part--in fact, I'm pretty sure it is--but perhaps something like this might work and I'm kind of interested in knowing how well it might work for you:
Use Frank (https://github.com/moredip/Frank) to control the iOS Simulator on a Mac. Program it to open up the EPUB docs you need.
All you need then is something to automate the taking of the screen shots. Obviously, these will look like the EPUBs are being rendered in an iPad (or an iPhone if you wish--the iOS Simulator does both, of course).
Automating the screenshots can probably be done with AppleScript, although the hard part might be getting it to talk to Frank. Worst case, you can tell Frank to pause for 5 seconds after it loads each page and tell AppleScript to take a screen shot every five seconds. That sucks, but if you're desperate, it will get it done. It's also possible Frank can somehow make the screenshots happen--I haven't used it enough to know.
Pandoc 可以从 EPub 转换为 LaTeX(因此转换为 PDF)或任意数量的其他格式。从概念上讲,这应该是类型 (1) 解决方案。
Pandoc can convert from EPub to LaTeX (and therefore to PDF) or to any number of other formats. Conceptually this should be a type (1) solution.
取决于您对“看起来像”的定义 - 您想要用户镶边还是仅针对给定屏幕尺寸的 epub 渲染。
我会检查适合您选择的平台的各种 epub 阅读器,将窗口调整为您喜欢的尺寸,然后将 epub“打印”到输出到图像文件的虚拟打印机 - 在 windows 上我使用 imageprint。
您可以轻松地从 iPad 产品照片中制作一个“框架”,并将屏幕截图放置在其中 - 唯一缺少的就是我所说的用户镶边。
depends on your definition of "look like" - do you want the user-chrome or just the epub rendering for a given screen size.
I would check out the various epub readers for your platform of choice, size the window to your preferred dimensions, and then just "print" the epub to a virtual printer that outputs to image files - on windoze I use imageprint.
You could easily make a "frame" from an iPad product shot and place your screenshots within that - only thing missing would be as I said the user chrome.