随机覆盖图像发生器
racovimge的Python项目详细描述
racovimge是生成随机 占位符书本封面。它允许生成svg或png封面,并且可以 用作python库或命令行实用程序。
安装
pip install --user racovimge
基本用法
importracovimge# generate random svg covercover=racovimge.random('As I Lay Dying','William Faulkner')# generate specific cover and write it to a filewithopen('cover.svg','w')asstream:stream.write(racovimge.cover(title='The Ambassadors',# note that author is optional.# Multiple authors can be passed as a non-str iterator as well.author='Henry James',template='Simple Dark',colors=['#d3dcf2','#829fe4','#6692c3','#4878a4','#00305a'],font='/path/to/otf/or/ttf/file',font_size=120,# Used for the title of the book.font_size_author=70# Used for the authors.))# Passing non-str iterable as title allows for explicit line breaks,# which is useful for longer titlescover=racovimge.random(['Strange Case','of Dr. Jekyll','and Mr. Hyde'],'Robert Louis Stevenson')# generate random png file and write it to file# note that unlike for svg, the file must be opened in binary modewithopen('cover.png','wb')asstream:# font sizes can be set explicitly even for random coversstream.write(racovimge.png_random('The Odyssey','Homer',font_size=200))# specifying keyword arguments for random generators enables limiting the output resultscover=racovimge.random('The Killer Angels','Michael Shaara',templates=['Blocks','Simple Dark','Tiles'],fonts=racovimge.fonts[:4],schemes=racovimge.color_schemes[2:8])
用作命令行实用程序
生成随机封面:
racovimge One Flew Over the Cuckoo's Nest --authors "Ken Kesey"
请注意,与标题不同,必须引用作者姓名。多重 可以提供分隔的作者。
生成PNG封面:
racovimge --png A Moveable Feast -a "Ernest Hemingway"
要生成具有给定前缀的多页封面:
racovimge The War of the Worlds -a "H. G. Wells" --output war --count 10 --png
这将在 当前目录。也可以指定绝对路径:
racovimge The Chronicles of Narnia -o /home/user/books/narnia/cover -c 5
限制
封面模板、配色方案和字体 选择相互结合工作。尽管如此,有些 各种参数的组合仍然会产生美观的效果 取消覆盖。特别是一些字体与较长的 书名不完全适合一些封面模板。 可以通过减小字体大小、显式指定 标题中的换行点,或仅通过生成不同的随机 翻唱谢天谢地,racovimge使后面的过程非常简单,并且 它可以重复多次直到你得到一个掩护 满意。
生成png封面需要在linux系统上安装rsvg。 在windows和macos上,它没有经过测试,不太可能工作。
当前版本的racovimge为0.9,应视为 贝塔。核心功能已经完成,但它仍然包含一个数字 粗糙的边缘。文档可以改进,特别是在 关于命令行实用程序。一些可选的 可以更改参数以更好地适应非默认值。未成年人 也可以修复现有的颜色方案和封面模板。 随着更多的方案、模板和字体可以添加到库中。 不幸的是,图书馆的作者没有时间 这些东西,因此racovimge将保持其当前状态 一段尚未确定的时间。
致谢
racovimge的灵感来源于 calibre电子书管理员。 racovimge还从中借用了一些颜色方案和svg元素。
以下免费字体与racovimge捆绑在一起:Alex Brush, Bellota,Bradley Gratis, Caladea, Crimson, Gidole,Glacial Indifference, Great Vibes, Horta,Liberation Serif,Libre Baskerville, Orkney,Petit Formal Script, Sofia,和 Unique。
racovimge使用的封面模板包含 来自以下设计系列: